{"version":3,"file":"verify.cjs","names":[],"sources":["../../src/commands/verify.ts"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport buildDebug from 'debug';\n\nimport { PLUGIN_CATEGORY, PLUGIN_PREFIX } from '@verdaccio/core';\n\nimport { verifyPlugin } from '../verify-plugin';\n\nconst debug = buildDebug('verdaccio:plugin:verifier:cli');\nconst VALID_CATEGORIES = Object.values(PLUGIN_CATEGORY);\n\nexport class VerifyCommand extends Command {\n  public static paths = [Command.Default];\n\n  static usage = Command.Usage({\n    description: 'Verify that a Verdaccio plugin can be loaded and passes sanity checks',\n    details: `\n      This command uses the same plugin loader that Verdaccio runs at startup\n      (\\`asyncLoadPlugin\\` from \\`@verdaccio/loaders\\`) to verify that a plugin\n      can be resolved, instantiated, and passes the required sanity checks\n      for its category.\n\n      The plugin is identified by its short name (as it appears in \\`config.yaml\\`),\n      and the loader applies the prefix automatically. For example, \\`my-auth\\`\n      resolves to \\`verdaccio-my-auth\\` in the plugins folder or \\`node_modules\\`.\n\n      Scoped packages (e.g. \\`@myorg/my-plugin\\`) are used as-is without a prefix.\n\n      Enable debug output with the DEBUG environment variable:\n        DEBUG=verdaccio:plugin:verifier* verdaccio-plugin-verifier my-auth --category authentication\n    `,\n    examples: [\n      [\n        'Verify an auth plugin from a plugins folder',\n        'verdaccio-plugin-verifier my-auth --category authentication --plugins-folder ./plugins',\n      ],\n      [\n        'Verify a storage plugin installed via npm',\n        'verdaccio-plugin-verifier my-storage --category storage',\n      ],\n      [\n        'Verify a scoped plugin with a custom prefix',\n        'verdaccio-plugin-verifier @myorg/my-plugin --category middleware --prefix mycompany',\n      ],\n    ],\n  });\n\n  private pluginPath = Option.String({\n    required: true,\n    name: 'plugin',\n  });\n\n  private category = Option.String('--category,-c', {\n    required: true,\n    description: `Plugin category: ${VALID_CATEGORIES.join(', ')}`,\n  });\n\n  private pluginsFolder = Option.String('--plugins-folder,-d', {\n    description: 'Absolute path to the plugins directory (maps to config.plugins)',\n  });\n\n  private prefix = Option.String('--prefix,-p', {\n    description: `Plugin name prefix (default: \"${PLUGIN_PREFIX}\")`,\n  });\n\n  public async execute(): Promise<number> {\n    debug('command invoked with plugin=%o category=%o', this.pluginPath, this.category);\n    debug('pluginsFolder=%o prefix=%o', this.pluginsFolder, this.prefix);\n\n    if (!VALID_CATEGORIES.includes(this.category)) {\n      this.context.stderr.write(\n        `Error: Invalid category \"${this.category}\". Must be one of: ${VALID_CATEGORIES.join(', ')}\\n`\n      );\n      return 1;\n    }\n\n    const result = await verifyPlugin({\n      pluginPath: this.pluginPath,\n      category: this.category,\n      pluginsFolder: this.pluginsFolder,\n      prefix: this.prefix,\n    });\n\n    if (result.success) {\n      this.context.stdout.write(\n        `Plugin \"${result.pluginName}\" verified successfully for category \"${result.category}\" (${result.pluginsLoaded} instance(s) loaded)\\n`\n      );\n      return 0;\n    }\n\n    this.context.stderr.write(`Plugin verification failed: ${result.error}\\n`);\n    if (result.diagnostics && result.diagnostics.length > 0) {\n      this.context.stderr.write('\\nDiagnostics:\\n');\n      for (const step of result.diagnostics) {\n        const icon = step.pass ? 'PASS' : 'FAIL';\n        this.context.stderr.write(`  [${icon}] ${step.phase}: ${step.message}\\n`);\n      }\n    }\n    return 1;\n  }\n}\n"],"mappings":";;;;;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,+BAA+B;AACxD,IAAM,mBAAmB,OAAO,OAAO,gBAAA,eAAe;AAEtD,IAAa,gBAAb,cAAmC,UAAA,QAAQ;CACzC,OAAc,QAAQ,CAAC,UAAA,QAAQ,OAAO;CAEtC,OAAO,QAAQ,UAAA,QAAQ,MAAM;EAC3B,aAAa;EACb,SAAS;;;;;;;;;;;;;;;EAeT,UAAU;GACR,CACE,+CACA,wFACF;GACA,CACE,6CACA,yDACF;GACA,CACE,+CACA,qFACF;EACF;CACF,CAAC;CAED,aAAqB,UAAA,OAAO,OAAO;EACjC,UAAU;EACV,MAAM;CACR,CAAC;CAED,WAAmB,UAAA,OAAO,OAAO,iBAAiB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