Skip to content

feat: add shared runner metadata and centralize runner detection#41

Merged
viferga merged 1 commit intometacall:masterfrom
Ishita-190:Ishita
Feb 25, 2026
Merged

feat: add shared runner metadata and centralize runner detection#41
viferga merged 1 commit intometacall:masterfrom
Ishita-190:Ishita

Conversation

@Ishita-190
Copy link
Contributor

@Ishita-190 Ishita-190 commented Feb 20, 2026

Fixes: #40

Files changed: language.ts, package.ts, package.spec.ts
In language.ts

  • Runner union
  • RunnerInfo interface
  • Runners map (file patterns, install commands, display name, language mapping)
  • detectRunnersFromFiles(files) helper

In package.ts

  • findRunners now uses shared detection from language metadata

In package.spec.ts

  • Coverage for detectRunnersFromFiles

Checklist:

  • npm test
  • npm run lint
  • npx tsc --noEmit

All tests are working properly:

image

Note: findRunners now returns Set<Runner> instead of Set<string>. Runtime behavior is unchanged.

I'll have to modify the following files in https://github.com/metacall/faas to move runner logic to protocol:

  • package.json : bump @metacall/protocol dependency to the new Runner exports
  • src/install.ts – remove duplicated runner definitions and use protocol instead
const runnerList = ['nodejs', 'python', 'ruby', 'csharp'];

const targetFiles = {
  nodejs: 'package.json',
  python: 'requirements.txt',
  ruby: 'Gemfile',
  csharp: 'project.json'
};

export const findRunners = async (dir: string): Promise<Runner[]> => { ... };

To:

import { detectRunners, Runner, Runners } from '@metacall/protocol';

const findDependencies = async (
  dir: string,
  runners: Runner[]
): Promise<Record<Runner, string[]>> => {
  const dependencies = {} as Record<Runner, string[]>;

  for (const runner of runners) {
    const patterns = Runners[runner].filePatterns;

    dependencies[runner] = await findFilesRecursively(
      dir,
      fileName => patterns.some(re => re.test(fileName))
    );
  }

  return dependencies;
};
  • src/app.ts – update runner typing from string[] to runner[]
import { Deployment, MetaCallJSON } from '@metacall/protocol/deployment';

export interface Resource {
  ...
  runners: string[];
}

to:

import { Deployment, MetaCallJSON } from '@metacall/protocol/deployment';
import { Runner } from '@metacall/protocol';

export interface Resource {
  ...
  runners: Runner[];
}
import { findRunners } from '../utils/install';

resource.runners = await findRunners(resource.path);

To:

import { detectRunners } from '@metacall/protocol';

resource.runners = await detectRunners(resource.path);
eventHandler('field', (name: keyof Resource, val: string) => {
  if (name === 'runners') {
    resource.runners = JSON.parse(val) as string[];
  } else if (name === 'jsons') {
    ...
  }
});

to:

import { Runner, Runners } from '@metacall/protocol';

const isRunner = (value: string): value is Runner =>
  value in Runners;

eventHandler('field', (name: keyof Resource, val: string) => {
    try {
        if (name === 'runners') {
            const parsed: unknown = JSON.parse(val);

            if (!Array.isArray(parsed) || !parsed.every(isRunner)) {
                throw new AppError('Invalid runners field, expected Runner[]', 400);
            }

            resource.runners = parsed;
        } else if (name === 'jsons') {
            resource.jsons = JSON.parse(val) as MetaCallJSON[];
        } else {
            resource[name] = val;
        }
    } catch (error) {
        if (error instanceof AppError) {
            throw error;
        }
        throw new AppError('Invalid JSON payload', 400);
    }
});

@viferga
Copy link
Member

viferga commented Feb 25, 2026

It seems to work. Now we should tag a new version and update the place where it is duplicated by using @metacall/protocl instead.

@viferga viferga merged commit 089d2f2 into metacall:master Feb 25, 2026
1 check passed
@Ishita-190
Copy link
Contributor Author

@viferga yes, I'll start working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: add canonical runner metadata and detection helpers

2 participants