Skip to content

Cli: Add mimic config#212

Open
alavarello wants to merge 6 commits intomainfrom
cli/add-mimic-config
Open

Cli: Add mimic config#212
alavarello wants to merge 6 commits intomainfrom
cli/add-mimic-config

Conversation

@alavarello
Copy link
Member

@alavarello alavarello commented Feb 5, 2026

No description provided.

@alavarello alavarello force-pushed the cli/add-mimic-config branch from c886047 to 2c2ec72 Compare February 5, 2026 17:54
@alavarello alavarello changed the title cli/add mimic config Cli: Add mimic config Feb 6, 2026
@alavarello alavarello self-assigned this Feb 6, 2026
@alavarello alavarello marked this pull request as ready for review February 6, 2026 16:21
@alavarello alavarello requested a review from lgalende February 6, 2026 16:22

This comment was marked as outdated.

@mimic-protocol mimic-protocol deleted a comment from Copilot AI Feb 6, 2026
@mimic-protocol mimic-protocol deleted a comment from Copilot AI Feb 6, 2026
@mimic-protocol mimic-protocol deleted a comment from Copilot AI Feb 6, 2026
@mimic-protocol mimic-protocol deleted a comment from Copilot AI Feb 6, 2026
@mimic-protocol mimic-protocol deleted a comment from Copilot AI Feb 6, 2026
]

static override flags = {
...Functions.flags,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is redundant because Codegen.flags and Compile.flags already include Functions.flags, but I'd keep it anyway. To be explicit.

static override examples = ['<%= config.bin %> <%= command.id %> --directory ./tests']

static override flags = {
...Functions.flags,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment saying that exclude and include commands only affect the build, but not the test execution per se?

cmd.error(`Could not find ${flags['config-file']}`, { code: 'ConfigNotFound' })
}

// If doesn't exists return the default with the flags the user added
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
// If doesn't exists return the default with the flags the user added
// If doesn't exist, return the default with the flags the user added

throw new Error('Method not implemented.')
}

static override description = 'Filters tasks based on a mimic.yaml configuration file'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static override description = 'Filters tasks based on a mimic.yaml configuration file'
static override description = `Filters functions based on a ${Functions.MIMIC_CONFIG_FILE} configuration file`

export default class Functions extends Command {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
run(): Promise<any> {
throw new Error('Method not implemented.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to have a command that can't be run.
We should at least hide it from the user. In other words, mimic --help shouldn't show functions command.
And/or, we could log a message instead of throwing an error. Something like:

console.log('The "functions" command is not intended to be run directly')

Same with authenticate.

})

export const MimicConfigSchema = z.object({
tasks: z.array(FunctionConfigSchema).min(1, 'At least one task is required'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tasks: z.array(FunctionConfigSchema).min(1, 'At least one task is required'),
functions: z.array(FunctionConfigSchema).min(1, 'At least one function is required'),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we create mimic.yaml containing default config on init?
This way, users easily know the expected structure.
We have the docs site for that tho...

description: `Do not read ${Functions.MIMIC_CONFIG_FILE}; use defaults and explicit flags instead`,
default: false,
}),
include: Flags.string({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I run: yarn mimic codegen --include f1 f2 where f1 is defined in mimic.yaml but f2 isn't, the command only runs for f1 and silently ignores f2.
Should we include a message saying something like f2 not found?
Same with exclude.

): Promise<void> {
const functions = Functions.filterFunctions(cmd, flags)
for (const func of functions) {
log.startAction(`Starting ${cmdActions} for function ${func.name}`)
Copy link
Member

@lgalende lgalende Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit
When running a single function manually, the log is e.g.: Starting compilation for function ... ✔️ (note the space between "..." and "✔️")
this is because func.name = ''.
In this case, shall we show func.function instead?

try {
const config = MimicConfigSchema.parse(rawConfig)

let tasks = config.tasks || []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.tasks is guaranteed by MimicConfigSchema

Suggested change
let tasks = config.tasks || []
let tasks = config.tasks

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.

2 participants