export function getCommonCommandOpts()

in src/options.ts [200:269]


export function getCommonCommandOpts() {
  const params = createOption(
    '-p, --params <jsonstring>',
    'JSON object that defines any variables your tests require.'
  ).argParser(JSON.parse);

  const playwrightOpts = createOption(
    '--playwright-options <jsonstring>',
    'JSON object to pass in custom Playwright options for the agent. Options passed will be merged with Playwright options defined in your synthetics.config.js file.'
  ).argParser(parsePlaywrightOptions);

  const pattern = createOption(
    '--pattern <pattern>',
    'RegExp pattern to match journey files in the current working directory (default: /*.journey.(ts|js)$/)'
  );

  const apiDocsLink =
    'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).';
  const auth = createOption('--auth <auth>', apiDocsLink).env(
    'SYNTHETICS_API_KEY'
  );

  const authMandatory = createOption('--auth <auth>', apiDocsLink)
    .env('SYNTHETICS_API_KEY')
    .makeOptionMandatory(true);

  const configOpt = createOption(
    '-c, --config <path>',
    'path to the configuration file (default: synthetics.config.(js|ts))'
  );

  const tags = createOption(
    '--tags <name...>',
    'run/push tests with the tag(s) matching a pattern'
  );
  const match = createOption(
    '--match <name>',
    'run/push tests with a name or tags that matches a pattern'
  );
  const fields = createOption(
    '--fields <jsonstring>',
    'add fields to the monitor(s) in the format { "key": "value"}'
  ).argParser((fieldsStr: string) => {
    const fields = JSON.parse(fieldsStr);
    if (typeof fields !== 'object') {
      throw new Error('Invalid fields format');
    }
    // make sure all values are strings
    return Object.entries(fields).reduce((acc, [key, value]) => {
      if (typeof value !== 'string') {
        acc[key] = JSON.stringify(value);
      } else {
        acc[key] = value;
      }
      return acc;
    }, {});
  });

  return {
    auth,
    authMandatory,
    params,
    playwrightOpts,
    pattern,
    configOpt,
    tags,
    match,
    fields,
  };
}