Skip to content
Merged
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
151 changes: 13 additions & 138 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-]*$",
"description": "Workflow id"
},
"name": {
"type": "string",
"description": "Workflow name"
Expand Down
8 changes: 6 additions & 2 deletions src/commands/workflow/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ export const exec = new Command<GlobalOptions>()
.arguments('<workflow>')
.action(async (options, workflow) => {
const { dryRun, mode } = options
const cfg = config.get(options as CliOptions) as any
const cfg = config.get(options as CliOptions)

const run = cfg.workflows.find((w: any) => w.name === workflow)
if (!cfg.workflows) {
throw new ValidationError('No workflows defined in config')
}

const run = cfg.workflows.find((w) => w.id === workflow || w.name === workflow)
if (!run) {
throw new ValidationError(`Workflow ${workflow} not found`)
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const ConfigSchema = z.object({
}),
workflows: z.array(
z.object({
id: z.string().regex(new RegExp('^[a-zA-Z0-9][a-zA-Z0-9\\-]*$')).optional().describe('Workflow id'),
name: z.string().describe('Workflow name'),
steps: z.array(
z.object({
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/test.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"workflows": [
{
"id": "compile-client",
"name": "compile client",
"steps": [
{
Expand All @@ -27,6 +28,7 @@
]
},
{
"id": "compile-server",
"name": "compile server",
"steps": [
{
Expand All @@ -43,6 +45,7 @@
]
},
{
"id": "cook-all",
"name": "cook all",
"steps": [
{
Expand All @@ -59,6 +62,7 @@
]
},
{
"id": "package-client",
"name": "package client",
"steps": [
{
Expand All @@ -79,6 +83,7 @@
]
},
{
"id": "package-server",
"name": "package server",
"steps": [
{
Expand Down
3 changes: 3 additions & 0 deletions tests/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Deno.test('renderConfig should deeply replace all placeholders in config object'
metadata: { ts: '2024-02-29T12:34:56Z' },
workflows: [
{
id: 'compile',
name: 'compile',
steps: [
{
Expand All @@ -109,6 +110,7 @@ Deno.test('renderConfig should deeply replace all placeholders in config object'
metadata: { ts: '2024-02-29T12:34:56Z' },
workflows: [
{
id: 'compile',
name: 'compile',
steps: [
{
Expand All @@ -135,6 +137,7 @@ Deno.test('replace paths in template', () => {
metadata: { ts: '2024-02-29T12:34:56Z' },
workflows: [
{
id: 'compile',
name: 'compile',
steps: [
{
Expand Down