A template repository for creating new Flows apps with best practices and CI/CD built-in.
- Use this template - Click "Use this template" button to create a new repository
- Run setup -
npm run setup
to customize placeholders automatically - Implement your logic - Add blocks and customize configuration
- Set up CI/CD - Configure branch protection and deployment
- Release - Tag and release your app
├── .github/workflows/ci.yml # CI/CD pipeline
├── .gitignore # Git ignore rules
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── main.ts # App definition
├── types.ts # Type definitions
├── blocks/ # Block implementations
│ ├── index.ts # Block registry and exports
│ └── exampleBlock.ts # Example block implementation
├── setup.sh # Automated setup script
└── README.md # This file
Find and replace these placeholders throughout the codebase:
{{APP_NAME}}
- Your app name (e.g., "Slack Integration"){{APP_DESCRIPTION}}
- Brief description of your app
Files to update:
package.json
- name and description fieldsmain.ts
- app name and descriptiontypes.ts
- JSDoc commentsREADME.md
- update this file
In main.ts
, modify the config
object:
config: {
type: "object",
properties: {
apiKey: {
type: "string",
title: "API Key",
description: "Your service API key",
secret: true // This makes it a password field
},
baseUrl: {
type: "string",
title: "Base URL",
description: "API base URL",
default: "https://api.example.com"
}
},
required: ["apiKey"] // Required fields
}
The template includes a clean block structure. Blocks are organized in the blocks/
directory:
- Create the block file (e.g.,
blocks/myNewBlock.ts
):
import { AppBlock, EventInput } from "@slflows/sdk";
export const myNewBlock: AppBlock = {
name: "Your Action Name",
description: "What your block does",
category: "Your Category",
inputs: {
default: {
name: "Input Name",
description: "What users need to provide",
config: {
// Define your input schema here
type: "object",
properties: {
message: {
type: "string",
title: "Message",
description: "Input description",
},
},
required: ["message"],
},
onEvent: async (input: EventInput, { events }) => {
// Your logic here
const message = input.params.message as string;
const apiKey = input.app.config.apiKey as string;
// Call your external API, process data, etc.
// Just emit the result directly - don't wrap in success object
await events.emit({
result: "your result",
});
},
},
},
outputs: {
default: {
name: "Output Name",
description: "What your block returns",
default: true,
type: {
// Define your output schema here
type: "object",
properties: {
result: { type: "string" },
},
required: ["result"],
} as any,
},
},
};
- Register the block in
blocks/index.ts
:
import { myNewBlock } from "./myNewBlock.ts";
export const blocks = {
example: exampleBlock,
myNew: myNewBlock, // Add your block here
} as const;
export { myNewBlock }; // Export for external use
That's it! The block will automatically be included in your app via Object.values(blocks)
in main.ts
.
- Node.js 20+
- npm
npm install
npm run setup # Interactive setup to customize template
npm run setup # Customize template placeholders
npm run typecheck # Type checking
npm run format # Code formatting
npm run bundle # Create deployment bundle
- Run type checking:
npm run typecheck
- Format code:
npm run format
- Create bundle:
npm run bundle
Note: Initial npm run typecheck
will show SDK import errors until you customize the template. This is expected - the SDK will be available when the app runs in the Flows environment.
The template includes a complete CI/CD pipeline in .github/workflows/ci.yml
:
- Triggers: All branch pushes (except main)
- Steps: Type check, format validation, bundling
- Quality Gates: Must pass all checks to merge
- Triggers: Semver tags (v1.0.0, v2.1.3, etc.)
- Process:
- Runs full CI validation
- Creates GitHub release with bundle
- Updates version registry (
versions.json
) - Pushes registry to main branch
The pipeline automatically maintains a versions.json
file:
{
"versions": [
{
"version": "1.0.0",
"artifactUrl": "https://github.com/user/repo/releases/download/v1.0.0/bundle.tar.gz",
"artifactChecksum": "sha256:abc123..."
}
]
}
Configure branch protection for main
:
- Require pull request reviews
- Require status checks (CI)
- Allow GitHub Actions bot to bypass (for version registry updates)
- Enable "Template repository" if this will be reused
- Configure secrets if needed for external services
- Set up branch protection rules
- Ensure main is clean: All changes merged and CI passing
- Create and push tag:
git tag v1.0.0 git push origin v1.0.0
- Automated process: CI creates release and updates registry
- Verify: Check GitHub releases and
versions.json
in main
Follow Semantic Versioning:
v1.0.0
- Major release (breaking changes)v1.1.0
- Minor release (new features)v1.0.1
- Patch release (bug fixes)
- Keep
main.ts
focused on app definition - Use
types.ts
for all TypeScript definitions - Document your blocks and configuration clearly
- Let errors bubble up naturally - don't catch and wrap them
- Use descriptive error messages
- The framework will handle error catching and reporting
- Mark sensitive config fields as
secret: true
- Never log API keys or sensitive data
- Validate all inputs
- Test your blocks manually before releasing
- Verify configuration schema works as expected
- Test the complete deployment pipeline
CI fails on format check
npm run format
git add .
git commit -m "Fix formatting"
Bundle creation fails
- Check TypeScript errors:
npm run typecheck
- Verify all imports are correct
- Ensure
main.ts
exports default app
Release creation fails
- Verify branch protection allows GitHub Actions bot
- Check repository permissions
- Ensure tag follows semver format (v1.0.0)
Version registry not updating
- Check GitHub Actions bot has push access to main
- Verify workflow permissions in repository settings
- Check for conflicts in versions.json
When creating a new app from this template:
- Run
npm install && npm run setup
for automated setup - Customize app configuration schema in
main.ts
- Implement your block logic in
blocks/
- Update block names, descriptions, and categories
- Define proper input/output schemas
- Test locally with
npm run typecheck
andnpm run bundle
- Update this README with app-specific information
- Set up repository branch protection
- Create first release with
git tag v1.0.0
Template Version: 1.0.0