Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
description: Use Bun instead of Node.js, npm, pnpm, or vite.
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
alwaysApply: false
---

Default to using Bun instead of Node.js.

- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
- Use `bun test` instead of `jest` or `vitest`
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
- Bun automatically loads .env, so don't use dotenv.

## APIs

- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
- `Bun.redis` for Redis. Don't use `ioredis`.
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
- `WebSocket` is built-in. Don't use `ws`.
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
- Bun.$`ls` instead of execa.

## Testing

Use `bun test` to run tests.

```ts#index.test.ts
import { test, expect } from "bun:test";

test("hello world", () => {
expect(1).toBe(1);
});
```

## Frontend

Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.

Server:

```ts#index.ts
import index from "./index.html"

Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => {
return new Response(JSON.stringify({ id: req.params.id }));
},
},
},
// optional websocket support
websocket: {
open: (ws) => {
ws.send("Hello, world!");
},
message: (ws, message) => {
ws.send(message);
},
close: (ws) => {
// handle close
}
},
development: {
hmr: true,
console: true,
}
})
```

HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.

```html#index.html
<html>
<body>
<h1>Hello, world!</h1>
<script type="module" src="./frontend.tsx"></script>
</body>
</html>
```

With the following `frontend.tsx`:

```tsx#frontend.tsx
import React from "react";

// import .css files directly and it works
import './index.css';

import { createRoot } from "react-dom/client";

const root = createRoot(document.body);

export default function Frontend() {
return <h1>Hello, world!</h1>;
}

root.render(<Frontend />);
```

Then, run index.ts

```sh
bun --hot ./index.ts
```

For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
4 changes: 2 additions & 2 deletions .github/scripts/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ main() {

# Always run formatter to ensure consistent formatting
echo "🔧 Running formatter to ensure consistent formatting..."
if command -v bun >/dev/null 2>&1; then
bun fmt >/dev/null 2>&1 || echo "⚠️ Warning: bun fmt failed, but continuing..."
if command -v bun > /dev/null 2>&1; then
bun fmt > /dev/null 2>&1 || echo "⚠️ Warning: bun fmt failed, but continuing..."
else
echo "⚠️ Warning: bun not found, skipping formatting"
fi
Expand Down
25 changes: 24 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,33 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template=
### Every Template Must Have

- `main.tf` - Complete Terraform configuration
- `README.md` - Documentation with frontmatter
- `README.md` - Documentation with required frontmatter and sections

Templates don't require test files like modules do, but should be manually tested before submission.

Template README files must include:

1. Frontmatter with:
```yaml
---
display_name: "Template Name" # Required - Name shown on Registry website
description: "What it does" # Required - Brief description
icon: "../../../../.icons/platform.svg" # Required - Icon path
verified: false # Optional - Set by maintainers only
tags: ["platform", "use-case"] # Required - Descriptive tags
platform: "aws" # Required - Infrastructure platform
requirements: ["aws-cli"] # Required - Prerequisites
workload: "development" # Required - Type of workload
---
```

2. Required sections:
- Prerequisites - Required setup and dependencies
- Infrastructure/Resources - What gets provisioned
- Usage/Examples - How to use the template
- Cost and Permissions - Resource costs and required permissions
- Variables - All configuration options

### README Frontmatter

Module README frontmatter must include:
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,25 @@ More information [about Coder Modules can be found here](https://coder.com/docs/

The easiest way to discover new modules and templates is by visiting [the official Coder Registry website](https://registry.coder.com/). The website is a full mirror of the Coder Registry repo, and it is where .tar versions of the various resources can be downloaded from, for use within your Coder deployment.

Note that while Coder has a baseline set of requirements for allowing an external PR to be published, Coder cannot vouch for the validity or functionality of a resource until that resource has been flagged with the `verified` status. [All modules under the Coder namespace](https://github.com/coder/registry/tree/main/registry/coder) are automatically verified.
### Quality Standards

All modules and templates must meet our quality standards to be published:

1. **Validation**: All READMEs must pass automated validation:
- Required frontmatter fields
- Proper document structure
- Required sections based on type (module vs template)

2. **Verification**: While we validate submissions, we can't verify functionality until marked as `verified`:
- [All modules under the Coder namespace](https://github.com/coder/registry/tree/main/registry/coder) are automatically verified
- Community submissions require review and testing
- Look for the `verified` flag in frontmatter

3. **Documentation**: Clear documentation is required:
- Prerequisites and setup requirements
- Infrastructure details and costs
- Usage examples and variables
- Platform requirements and permissions

### Getting started with modules

Expand Down
14 changes: 14 additions & 0 deletions cmd/readmevalidation/coderresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ func validateCoderResourceReadme(rm coderResourceReadme) []error {
for _, err := range validateCoderResourceIconURL(rm.frontmatter.IconURL) {
errs = append(errs, addFilePathToError(rm.filePath, err))
}

// For templates, perform additional validation
if rm.resourceType == "templates" {
templateReadme, err := parseTemplateReadme(readme{
filePath: rm.filePath,
rawText: rm.body,
})
if err != nil {
errs = append(errs, err)
} else {
templateErrs := validateTemplateReadme(templateReadme)
errs = append(errs, templateErrs...)
}
}

return errs
}
Expand Down
10 changes: 7 additions & 3 deletions cmd/readmevalidation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ func main() {
if err != nil {
errs = append(errs, err)
}
err = validateAllCoderResourceFilesOfType("modules")
if err != nil {
errs = append(errs, err)

// Validate both modules and templates
for _, resourceType := range supportedResourceTypes {
err = validateAllCoderResourceFilesOfType(resourceType)
if err != nil {
errs = append(errs, err)
}
}

if len(errs) == 0 {
Expand Down
Loading
Loading