Conversation
c886047 to
2c2ec72
Compare
| ] | ||
|
|
||
| static override flags = { | ||
| ...Functions.flags, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
typo
| // 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' |
There was a problem hiding this comment.
| 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.') |
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
| tasks: z.array(FunctionConfigSchema).min(1, 'At least one task is required'), | |
| functions: z.array(FunctionConfigSchema).min(1, 'At least one function is required'), |
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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}`) |
There was a problem hiding this comment.
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 || [] |
There was a problem hiding this comment.
config.tasks is guaranteed by MimicConfigSchema
| let tasks = config.tasks || [] | |
| let tasks = config.tasks |
No description provided.