@weavix/cli 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/index.js +702 -524
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -263,6 +263,7 @@ __export(hosts_exports, {
263
263
  getBuckets: () => getBuckets,
264
264
  getMdsEndpoint: () => getMdsEndpoint,
265
265
  getOAuthTokenUrl: () => getOAuthTokenUrl,
266
+ getPlatformApiPrefix: () => getPlatformApiPrefix,
266
267
  getPlatformBaseUrl: () => getPlatformBaseUrl,
267
268
  getPluginDownloadBase: () => getPluginDownloadBase,
268
269
  getS3Endpoint: () => getS3Endpoint,
@@ -312,30 +313,25 @@ function getPluginDownloadBase(env) {
312
313
  return base;
313
314
  }
314
315
  function getPlatformBaseUrl() {
315
- let cfg = requireConfig();
316
- if (!cfg.api?.platformBaseUrl)
317
- throw new Error(
318
- 'Platform API URL is not configured. Run "weavix config set" to configure.'
319
- );
320
- return cfg.api.platformBaseUrl;
316
+ return readConfig()?.api?.platformBaseUrl ?? PLATFORM_BASE_URL;
317
+ }
318
+ function getPlatformApiPrefix() {
319
+ return "/api/cli/v1";
321
320
  }
322
321
  function getTrackerBaseUrl() {
323
322
  return TRACKER_BASE_URL;
324
323
  }
325
324
  function getOAuthTokenUrl() {
326
- let cfg = requireConfig();
327
- if (!cfg.auth?.oauthUrl)
328
- throw new Error('OAuth URL is not configured. Run "weavix config set" to configure.');
329
- return cfg.auth.oauthUrl;
325
+ return readConfig()?.auth?.oauthUrl ?? OAUTH_TOKEN_URL;
330
326
  }
331
327
  function getUpdateCheckInfo() {
332
328
  return null;
333
329
  }
334
- var TRACKER_BASE_URL, init_hosts = __esm({
330
+ var TRACKER_BASE_URL, PLATFORM_BASE_URL, OAUTH_TOKEN_URL, init_hosts = __esm({
335
331
  "src/distributions/external/hosts.ts"() {
336
332
  "use strict";
337
333
  init_manager();
338
- TRACKER_BASE_URL = "https://api.tracker.yandex.net/v3";
334
+ TRACKER_BASE_URL = "https://api.tracker.yandex.net/v3", PLATFORM_BASE_URL = "https://plugins.cli-api.tracker.yandex.net", OAUTH_TOKEN_URL = "https://oauth.yandex.ru/authorize?response_type=token&client_id=f57901dffe3849cbb3dbb5f616158e28";
339
335
  }
340
336
  });
341
337
 
@@ -2301,14 +2297,34 @@ var init_doctor = __esm({
2301
2297
  }
2302
2298
  });
2303
2299
 
2304
- // src/commands/submit/options.ts
2305
- var import_commander, skipChecksOption, init_options = __esm({
2306
- "src/commands/submit/options.ts"() {
2300
+ // src/distributions/external/auth.ts
2301
+ var auth_exports = {};
2302
+ __export(auth_exports, {
2303
+ getAuthHeader: () => getAuthHeader,
2304
+ getPlatformHeaders: () => getPlatformHeaders
2305
+ });
2306
+ function getAuthHeader() {
2307
+ let token = externalAuthManager.token;
2308
+ return token ? `OAuth ${token}` : null;
2309
+ }
2310
+ function getPlatformHeaders() {
2311
+ let orgId = readConfig()?.api?.platformOrgId;
2312
+ return orgId ? { "X-Org-ID": orgId } : {};
2313
+ }
2314
+ var init_auth = __esm({
2315
+ "src/distributions/external/auth.ts"() {
2307
2316
  "use strict";
2308
- import_commander = require("commander"), skipChecksOption = new import_commander.Option(
2309
- "--skip-checks",
2310
- "skip pre-submit validation (manifest, assets, lint, typecheck, tests, audit)"
2311
- );
2317
+ init_manager();
2318
+ init_authManager();
2319
+ }
2320
+ });
2321
+
2322
+ // src/distribution/auth.ts
2323
+ var impl4, getAuthHeader2, getPlatformHeaders2, init_auth2 = __esm({
2324
+ "src/distribution/auth.ts"() {
2325
+ "use strict";
2326
+ init_flag();
2327
+ impl4 = (init_auth(), __toCommonJS(auth_exports)), { getAuthHeader: getAuthHeader2, getPlatformHeaders: getPlatformHeaders2 } = impl4;
2312
2328
  }
2313
2329
  });
2314
2330
 
@@ -2381,159 +2397,271 @@ var import_picocolors, logger, logger_default, init_logger = __esm({
2381
2397
  }
2382
2398
  });
2383
2399
 
2384
- // src/core/cliConfig/registerCommand.ts
2385
- async function promptString(message, current) {
2386
- return (await (0, import_prompts.input)({
2387
- message: current ? `${message} (current: ${current})` : `${message} (optional)`,
2388
- default: current,
2389
- required: !1
2390
- }))?.trim() || void 0;
2391
- }
2392
- async function runConfigSet(cliName) {
2393
- let existing = readConfig() ?? {};
2394
- logger_default.info(
2395
- "Configure CLI overrides. Empty input clears the value (and falls back to defaults where applicable)."
2396
- );
2397
- let s3Endpoint = await promptString("S3 endpoint", existing.s3?.endpoint), s3Region = await promptString("S3 region", existing.s3?.region), mdsEndpoint = await promptString("MDS endpoint", existing.mds?.endpoint), productionStatic = await promptString(
2398
- "Production bucket (static)",
2399
- existing.buckets?.production?.static
2400
- ), productionConfig = await promptString(
2401
- "Production bucket (config)",
2402
- existing.buckets?.production?.config
2403
- ), pluginDownloadProduction = await promptString(
2404
- "Plugin download base URL",
2405
- existing.pluginDownloadBase?.production
2406
- ), platformBaseUrl = await promptString(
2407
- "Platform API base URL",
2408
- existing.api?.platformBaseUrl
2409
- ), oauthUrl = await promptString("OAuth token URL", existing.auth?.oauthUrl);
2410
- writeConfig({
2411
- s3: { endpoint: s3Endpoint, region: s3Region },
2412
- mds: { endpoint: mdsEndpoint },
2413
- buckets: {
2414
- production: { static: productionStatic, config: productionConfig }
2415
- },
2416
- pluginDownloadBase: { production: pluginDownloadProduction },
2417
- api: { platformBaseUrl },
2418
- auth: { oauthUrl }
2419
- }), logger_default.success(`Configuration saved \u2192 ${getConfigPath()}`), logger_default.info(`Inspect with "${cliName} config show" or revert with "${cliName} config clear".`);
2420
- }
2421
- function runConfigShow(cliName) {
2422
- let cfg = readConfig();
2423
- if (!cfg) {
2424
- logger_default.info(
2425
- `No configuration found at ${getConfigPath()}. Run "${cliName} config set" to create one.`
2426
- );
2427
- return;
2400
+ // src/distribution/hosts.ts
2401
+ var impl5, getS3Endpoint2, getMdsEndpoint2, getS3Region2, getBuckets2, getPluginDownloadBase2, getPlatformBaseUrl2, getPlatformApiPrefix2, getTrackerBaseUrl2, getOAuthTokenUrl2, getUpdateCheckInfo2, init_hosts2 = __esm({
2402
+ "src/distribution/hosts.ts"() {
2403
+ "use strict";
2404
+ init_flag();
2405
+ impl5 = (init_hosts(), __toCommonJS(hosts_exports)), {
2406
+ getS3Endpoint: getS3Endpoint2,
2407
+ getMdsEndpoint: getMdsEndpoint2,
2408
+ getS3Region: getS3Region2,
2409
+ getBuckets: getBuckets2,
2410
+ getPluginDownloadBase: getPluginDownloadBase2,
2411
+ getPlatformBaseUrl: getPlatformBaseUrl2,
2412
+ getPlatformApiPrefix: getPlatformApiPrefix2,
2413
+ getTrackerBaseUrl: getTrackerBaseUrl2,
2414
+ getOAuthTokenUrl: getOAuthTokenUrl2,
2415
+ getUpdateCheckInfo: getUpdateCheckInfo2
2416
+ } = impl5;
2428
2417
  }
2429
- logger_default.info(`Configuration at ${getConfigPath()}:`), logger_default.info(JSON.stringify(cfg, null, 2));
2430
- }
2431
- function runConfigClear() {
2432
- clearConfig(), logger_default.success(`Configuration removed (${getConfigPath()})`);
2433
- }
2434
- function registerConfigCommand(program, cliName) {
2435
- let config = program.command("config").description("manage CLI configuration");
2436
- config.command("set").description("set CLI configuration values interactively").action(() => runConfigSet(cliName)), config.command("show").description("display current CLI configuration").action(() => runConfigShow(cliName)), config.command("clear").description("remove stored CLI configuration").action(runConfigClear);
2437
- }
2438
- var import_prompts, init_registerCommand = __esm({
2439
- "src/core/cliConfig/registerCommand.ts"() {
2418
+ });
2419
+
2420
+ // src/api/constants.ts
2421
+ var init_constants2 = __esm({
2422
+ "src/api/constants.ts"() {
2440
2423
  "use strict";
2441
- import_prompts = require("@inquirer/prompts");
2442
- init_logger();
2443
- init_manager();
2424
+ init_hosts2();
2425
+ init_hosts2();
2444
2426
  }
2445
2427
  });
2446
2428
 
2447
- // src/utils/withErrorHandling.ts
2448
- function withErrorHandling(fn) {
2449
- return async (...args) => {
2429
+ // src/api/requestDebug.ts
2430
+ function redactHeaders(headers) {
2431
+ let result = {};
2432
+ for (let [key, value] of Object.entries(headers))
2433
+ if (key.toLowerCase() === "authorization") {
2434
+ let [scheme] = value.split(" ");
2435
+ result[key] = scheme ? `${scheme} ${REDACTED}` : REDACTED;
2436
+ } else
2437
+ result[key] = value;
2438
+ return result;
2439
+ }
2440
+ function formatDebugBody(body, formData) {
2441
+ if (formData) {
2442
+ let size = "";
2450
2443
  try {
2451
- await fn(...args);
2452
- } catch (error2) {
2453
- error2 instanceof Error && error2.name === "ExitPromptError" && process.exit(0), logger_default.error(error2), printErrorHints(error2), process.exit(1);
2444
+ let length = formData.getLengthSync?.();
2445
+ typeof length == "number" && (size = `, ~${length} bytes`);
2446
+ } catch {
2454
2447
  }
2455
- };
2448
+ return `[multipart/form-data${size}] (binary body, e.g. plugin archive \u2014 not dumped)`;
2449
+ }
2450
+ return typeof body == "string" ? body : "(none)";
2456
2451
  }
2457
- function getErrorMessage2(error2) {
2458
- return error2 instanceof Error ? error2.message : String(error2);
2452
+ function buildFailureDebug(params) {
2453
+ let { method, url, status, headers, body, formData } = params;
2454
+ return [
2455
+ "Platform API request failed \u2014 debug info (Authorization redacted):",
2456
+ ` method: ${method}`,
2457
+ ` url: ${url}`,
2458
+ ` status: ${status ?? "(no HTTP response \u2014 network/transport error)"}`,
2459
+ ` headers: ${JSON.stringify(redactHeaders(headers), null, 2)}`,
2460
+ ` body: ${formatDebugBody(body, formData)}`
2461
+ ].join(`
2462
+ `);
2459
2463
  }
2460
- function printErrorHints(error2) {
2461
- if (error2 instanceof PackageManagerRuntimeError) {
2462
- error2.action && logger_default.info(`Action: ${error2.action}`), logger_default.info(`Run ${CLI_NAME2} doctor from the plugin directory for full local diagnostics.`);
2463
- return;
2464
+ var REDACTED, init_requestDebug = __esm({
2465
+ "src/api/requestDebug.ts"() {
2466
+ "use strict";
2467
+ REDACTED = "****redacted****";
2464
2468
  }
2465
- let message = getErrorMessage2(error2);
2466
- if (isCorepackKeyIdError(message)) {
2467
- logger_default.info(`Action: ${getPackageManagerRuntimeAction(message, "pnpm")}`);
2468
- return;
2469
+ });
2470
+
2471
+ // src/api/platformApiRequest.ts
2472
+ function buildRequestHeaders(headers, formData) {
2473
+ let authHeader = getAuthHeader2();
2474
+ if (!authHeader)
2475
+ throw new Error(`Not authenticated. Run "${CLI_NAME2} login" first.`);
2476
+ let requestHeaders = {
2477
+ Accept: "*/*",
2478
+ Authorization: authHeader,
2479
+ ...getPlatformHeaders2(),
2480
+ ...headers
2481
+ };
2482
+ return formData || (requestHeaders["Content-Type"] = "application/json"), requestHeaders;
2483
+ }
2484
+ function buildRequestBody(method, body, formData) {
2485
+ if (formData) {
2486
+ let formHeaders = formData.getHeaders?.();
2487
+ return {
2488
+ body: formData,
2489
+ headers: formHeaders || {}
2490
+ };
2469
2491
  }
2470
- /\b(manifest\.json|manifest validation|package manager|corepack|pnpm|npm|build|dist)\b/i.test(
2471
- message
2472
- ) && logger_default.info(`Run ${CLI_NAME2} doctor from the plugin directory for local diagnostics.`);
2492
+ return body && method !== "GET" ? { body: JSON.stringify(body) } : {};
2473
2493
  }
2474
- var init_withErrorHandling = __esm({
2475
- "src/utils/withErrorHandling.ts"() {
2494
+ function buildQueryString2(queryParams) {
2495
+ if (!queryParams || Object.keys(queryParams).length === 0)
2496
+ return "";
2497
+ let params = new URLSearchParams();
2498
+ return Object.entries(queryParams).forEach(([key, value]) => {
2499
+ params.append(key, String(value));
2500
+ }), `?${params.toString()}`;
2501
+ }
2502
+ async function parseResponse2(response) {
2503
+ return response.status === 204 || response.headers.get("content-length") === "0" ? void 0 : response.headers.get("content-type")?.includes("application/json") ? await response.json() : await response.text();
2504
+ }
2505
+ async function platformApiRequest(endpoint, options = {}) {
2506
+ let { method = "GET", body, headers = {}, formData, queryParams } = options, requestHeaders = buildRequestHeaders(headers, formData), { body: requestBody, headers: additionalHeaders } = buildRequestBody(
2507
+ method,
2508
+ body,
2509
+ formData
2510
+ ), requestOptions = {
2511
+ method,
2512
+ headers: { ...requestHeaders, ...additionalHeaders },
2513
+ body: requestBody
2514
+ }, queryString = buildQueryString2(queryParams), url = `${getPlatformBaseUrl2()}${getPlatformApiPrefix2()}${endpoint}${queryString}`, controller = new AbortController(), timeout = setTimeout(() => controller.abort(), PLATFORM_API_TIMEOUT_MS), responseStatus;
2515
+ if (isVerboseEnabled() && (logger_default.info(
2516
+ `[platform-api-debug] Request: method=${method} url=${url} hasBody=${!!body} hasFormData=${!!formData} timeoutMs=${PLATFORM_API_TIMEOUT_MS}`
2517
+ ), body !== void 0 && logger_default.info(`[platform-api-debug] Request body: ${JSON.stringify(body)}`), formData)) {
2518
+ let debugPath = writeVerboseArtifact(
2519
+ "requests/latest-form-data.txt",
2520
+ `method=${method}
2521
+ url=${url}
2522
+ headers=${JSON.stringify({ ...requestHeaders, ...additionalHeaders }, null, 2)}
2523
+ formData=present
2524
+ `
2525
+ );
2526
+ logger_default.info(`[platform-api-debug] Saved form-data request metadata to ${debugPath}`);
2527
+ }
2528
+ try {
2529
+ let response = await (0, import_node_fetch2.default)(url, {
2530
+ ...requestOptions,
2531
+ signal: controller.signal
2532
+ });
2533
+ if (responseStatus = response.status, isVerboseEnabled() && logger_default.info(
2534
+ `[platform-api-debug] Response: method=${method} url=${url} status=${response.status} contentType=${response.headers.get("content-type") ?? "n/a"}`
2535
+ ), !response.ok) {
2536
+ let errorText = await response.text(), errorMessage = errorText;
2537
+ try {
2538
+ let errorJson = JSON.parse(errorText);
2539
+ errorJson.message && (errorMessage = errorJson.message);
2540
+ } catch {
2541
+ }
2542
+ throw new Error(`HTTP ${response.status} ${response.statusText}: ${errorMessage}`);
2543
+ }
2544
+ return parseResponse2(response);
2545
+ } catch (error2) {
2546
+ throw logger_default.error(
2547
+ buildFailureDebug({
2548
+ method,
2549
+ url,
2550
+ status: responseStatus,
2551
+ headers: requestOptions.headers,
2552
+ body: requestBody,
2553
+ formData
2554
+ })
2555
+ ), error2 instanceof Error && error2.name === "AbortError" ? new Error(
2556
+ `Platform API request timed out after ${PLATFORM_API_TIMEOUT_MS}ms: ${method} ${url}`
2557
+ ) : error2;
2558
+ } finally {
2559
+ clearTimeout(timeout);
2560
+ }
2561
+ }
2562
+ var import_node_fetch2, PLATFORM_API_TIMEOUT_MS, init_platformApiRequest = __esm({
2563
+ "src/api/platformApiRequest.ts"() {
2476
2564
  "use strict";
2565
+ import_node_fetch2 = __toESM(require("node-fetch"));
2566
+ init_auth2();
2477
2567
  init_meta2();
2478
2568
  init_logger();
2479
- init_packageManager();
2569
+ init_verbose();
2570
+ init_constants2();
2571
+ init_requestDebug();
2572
+ PLATFORM_API_TIMEOUT_MS = Number(process.env.TRACKER_CLI_PLATFORM_TIMEOUT_MS || 3e4);
2480
2573
  }
2481
2574
  });
2482
2575
 
2483
- // src/core/pluginState/pluginStateManager.ts
2484
- var import_fs9, import_promises2, STATE_FILE, load2, save2, update2, pluginStateManager, init_pluginStateManager = __esm({
2485
- "src/core/pluginState/pluginStateManager.ts"() {
2576
+ // src/api/platform.ts
2577
+ async function createPlugin(archiveBuffer, archiveName) {
2578
+ let formData = new import_form_data.default();
2579
+ return formData.append("archive", archiveBuffer, {
2580
+ filename: archiveName,
2581
+ contentType: "application/zip"
2582
+ }), platformApiRequest("/plugins", {
2583
+ method: "POST",
2584
+ formData
2585
+ });
2586
+ }
2587
+ async function updatePluginArchive(pluginId, archiveBuffer, archiveName) {
2588
+ let formData = new import_form_data.default();
2589
+ return formData.append("archive", archiveBuffer, {
2590
+ filename: archiveName,
2591
+ contentType: "application/zip"
2592
+ }), platformApiRequest(`/plugins/${pluginId}/archive`, {
2593
+ method: "PUT",
2594
+ formData
2595
+ });
2596
+ }
2597
+ async function updateCatalogEntry(pluginId, catalogData) {
2598
+ return platformApiRequest(`/plugins/${pluginId}/catalog-entry`, {
2599
+ method: "PUT",
2600
+ body: catalogData
2601
+ });
2602
+ }
2603
+ async function updateCatalogImage(pluginId, imageBuffer, imageName) {
2604
+ let formData = new import_form_data.default();
2605
+ return formData.append("image", imageBuffer, {
2606
+ filename: imageName,
2607
+ contentType: "image/jpeg"
2608
+ }), platformApiRequest(`/plugins/${pluginId}/catalog-image`, {
2609
+ method: "PUT",
2610
+ formData
2611
+ });
2612
+ }
2613
+ async function submitPlugin(pluginId, version) {
2614
+ return platformApiRequest(`/plugins/${pluginId}/submit`, {
2615
+ method: "POST",
2616
+ queryParams: {
2617
+ version
2618
+ }
2619
+ });
2620
+ }
2621
+ async function getPluginInfo(pluginId) {
2622
+ return platformApiRequest(`/plugins/${pluginId}`, {
2623
+ method: "GET"
2624
+ });
2625
+ }
2626
+ async function getMyPlugins() {
2627
+ return platformApiRequest("/plugins/my", {
2628
+ method: "GET"
2629
+ });
2630
+ }
2631
+ async function checkSlugAvailability(slug) {
2632
+ return platformApiRequest(`/slugs/${slug}/available`, {
2633
+ method: "GET"
2634
+ });
2635
+ }
2636
+ var import_form_data, init_platform = __esm({
2637
+ "src/api/platform.ts"() {
2486
2638
  "use strict";
2487
- import_fs9 = require("fs"), import_promises2 = require("fs/promises"), STATE_FILE = ".tracker-plugin", load2 = async () => {
2488
- if (!(0, import_fs9.existsSync)(STATE_FILE))
2489
- return {};
2490
- try {
2491
- let content = await (0, import_promises2.readFile)(STATE_FILE, "utf8");
2492
- return JSON.parse(content);
2493
- } catch {
2494
- return {};
2495
- }
2496
- }, save2 = async (state) => {
2497
- try {
2498
- let content = JSON.stringify(state, null, 4);
2499
- await (0, import_promises2.writeFile)(STATE_FILE, content, "utf8");
2500
- } catch (error2) {
2501
- throw error2 instanceof Error ? new Error(`Error saving ${STATE_FILE}: ${error2.message}`) : new Error(`Error saving ${STATE_FILE}`);
2502
- }
2503
- }, update2 = async (updates) => {
2504
- let updated = { ...await load2(), ...updates };
2505
- return await save2(updated), updated;
2506
- }, pluginStateManager = {
2507
- load: load2,
2508
- save: save2,
2509
- update: update2
2510
- };
2639
+ import_form_data = __toESM(require("form-data"));
2640
+ init_platformApiRequest();
2511
2641
  }
2512
2642
  });
2513
2643
 
2514
- // src/api/utils.ts
2515
- function getIssueStatusLabel(issue) {
2516
- let { key: statusKey, display: statusDisplay } = issue.status;
2517
- return statusKey === "closed" && issue.resolution?.display ? issue.resolution.display : statusDisplay ?? statusKey;
2518
- }
2519
- function getIssueStatusCategory(issue) {
2520
- let statusKey = issue.status.key, resolutionKey = issue.resolution?.key;
2521
- if (statusKey === "closed")
2522
- return resolutionKey === "agreed" ? "approved" : resolutionKey === "rejected" || resolutionKey === "declined" ? "rejected" : "neutral";
2523
- switch (statusKey) {
2524
- case "waitingForApprove":
2525
- case "inProgress":
2526
- return "pending";
2527
- case "resultAcceptance":
2528
- return "acceptance";
2529
- case "testing":
2530
- return "testing";
2531
- case "need_info":
2532
- return "need_info";
2533
- default:
2534
- return "neutral";
2644
+ // src/utils/getPluginId.ts
2645
+ async function getPluginId(pluginId) {
2646
+ if (pluginId)
2647
+ return pluginId;
2648
+ try {
2649
+ let manifest = await manifestManager.load();
2650
+ if (!manifest.id)
2651
+ throw new Error("Plugin ID not found in manifest.json");
2652
+ return manifest.id;
2653
+ } catch {
2654
+ throw new Error("Plugin ID must be provided as argument or present in manifest.json");
2535
2655
  }
2536
2656
  }
2657
+ var init_getPluginId = __esm({
2658
+ "src/utils/getPluginId.ts"() {
2659
+ "use strict";
2660
+ init_manifestManager();
2661
+ }
2662
+ });
2663
+
2664
+ // src/api/utils.ts
2537
2665
  var init_utils = __esm({
2538
2666
  "src/api/utils.ts"() {
2539
2667
  "use strict";
@@ -2541,22 +2669,33 @@ var init_utils = __esm({
2541
2669
  });
2542
2670
 
2543
2671
  // src/utils/pluginDisplay.ts
2544
- function showTrackerPluginList(issues) {
2545
- if (!issues || issues.length === 0) {
2672
+ function showPluginInfo(data) {
2673
+ printHeader("\u{1F4E6} Plugin"), logger_default.newLine(), printPluginId(data.id), printField("Slug", import_picocolors2.default.magenta(data.slug)), printField("Name", import_picocolors2.default.white(data.name)), printField("Status", getStatusBadgeByLabel(data.status.toUpperCase())), data.moderationTicketKey && printField("Moderation", import_picocolors2.default.cyan(data.moderationTicketKey)), data.createdAt && printCreated(data.createdAt), data.updatedAt && printUpdated(data.updatedAt);
2674
+ }
2675
+ function showPluginVersions(versions) {
2676
+ if (!versions || versions.length === 0) {
2677
+ console.info(import_picocolors2.default.dim(" No versions found")), logger_default.newLine();
2678
+ return;
2679
+ }
2680
+ printHeader(`\u{1F9FE} Versions \xB7 ${versions.length}`), logger_default.newLine(), versions.forEach((version, index) => {
2681
+ console.info(` ${import_picocolors2.default.bold(String(index + 1) + ".")} ${import_picocolors2.default.cyan(version.versionId)}`), printField("Status", getStatusBadgeByLabel(version.status.toUpperCase())), printField("Version", import_picocolors2.default.white(version.version)), printCreated(version.createdAt), logger_default.newLine();
2682
+ });
2683
+ }
2684
+ function showPluginList(plugins) {
2685
+ if (!plugins || plugins.length === 0) {
2546
2686
  console.info(import_picocolors2.default.dim(" No plugins found")), logger_default.newLine();
2547
2687
  return;
2548
2688
  }
2549
- printHeader(`\u{1F4CB} Your Plugins \xB7 ${issues.length}`), logger_default.newLine(), issues.forEach((issue) => {
2550
- let slugMatch = issue.summary.match(/^Plugin:\s*(.+)$/), slug = slugMatch ? import_picocolors2.default.magenta(slugMatch[1].trim()) : import_picocolors2.default.dim(issue.summary), statusBadge2 = getTrackerIssueBadge(issue);
2689
+ printHeader(`\u{1F4CB} Your Plugins \xB7 ${plugins.length}`), logger_default.newLine(), plugins.forEach((plugin) => {
2551
2690
  console.info(
2552
- ` ${slug} ${import_picocolors2.default.dim("\xB7")} ${statusBadge2} ${import_picocolors2.default.dim("\xB7")} ${import_picocolors2.default.dim(issue.key)}`
2691
+ ` ${import_picocolors2.default.magenta(plugin.slug)} ${import_picocolors2.default.dim("\xB7")} ${getStatusBadgeByLabel(plugin.status.toUpperCase())} ${import_picocolors2.default.dim("\xB7")} ${import_picocolors2.default.cyan(plugin.id)}`
2553
2692
  ), logger_default.newLine();
2554
2693
  });
2555
2694
  }
2556
- function showTrackerPluginInfo(issue) {
2557
- printHeader("\u{1F4E6} Plugin"), logger_default.newLine(), printField("Issue key", import_picocolors2.default.cyan(issue.key)), printField("Status", getTrackerIssueBadge(issue)), printField("Summary", import_picocolors2.default.white(issue.summary)), issue.createdAt && printCreated(issue.createdAt), issue.updatedAt && printUpdated(issue.updatedAt);
2695
+ function showPluginCreated(data) {
2696
+ printSuccessHeader("\u2705 Plugin Created"), logger_default.newLine(), printPluginId(data.id);
2558
2697
  }
2559
- var import_picocolors2, printHeader, getTrackerIssueBadge, formatDate, printField, printCreated, printUpdated, init_pluginDisplay = __esm({
2698
+ var import_picocolors2, printHeader, printSuccessHeader, getStatusBadgeByLabel, formatDate, printField, printPluginId, printCreated, printUpdated, init_pluginDisplay = __esm({
2560
2699
  "src/utils/pluginDisplay.ts"() {
2561
2700
  "use strict";
2562
2701
  import_picocolors2 = __toESM(require("picocolors"));
@@ -2564,24 +2703,11 @@ var import_picocolors2, printHeader, getTrackerIssueBadge, formatDate, printFiel
2564
2703
  init_logger();
2565
2704
  printHeader = (title) => {
2566
2705
  console.info(import_picocolors2.default.bold(import_picocolors2.default.white(title)));
2567
- }, getTrackerIssueBadge = (issue) => {
2568
- let label = getIssueStatusLabel(issue);
2569
- switch (getIssueStatusCategory(issue)) {
2570
- case "approved":
2571
- return import_picocolors2.default.black(import_picocolors2.default.bgGreen(` ${label} `));
2572
- case "rejected":
2573
- return import_picocolors2.default.white(import_picocolors2.default.bgRed(` ${label} `));
2574
- case "pending":
2575
- return import_picocolors2.default.black(import_picocolors2.default.bgYellow(` ${label} `));
2576
- case "acceptance":
2577
- return import_picocolors2.default.black(import_picocolors2.default.bgCyan(` ${label} `));
2578
- case "testing":
2579
- return import_picocolors2.default.black(import_picocolors2.default.bgMagenta(` ${label} `));
2580
- case "need_info":
2581
- return import_picocolors2.default.black(import_picocolors2.default.bgBlue(` ${label} `));
2582
- default:
2583
- return import_picocolors2.default.black(import_picocolors2.default.bgWhite(` ${label} `));
2584
- }
2706
+ }, printSuccessHeader = (title) => {
2707
+ console.info(import_picocolors2.default.bold(import_picocolors2.default.green(title)));
2708
+ }, getStatusBadgeByLabel = (label) => {
2709
+ let normalized = label.toLowerCase();
2710
+ return normalized.includes("approved") ? import_picocolors2.default.black(import_picocolors2.default.bgGreen(` ${label} `)) : normalized.includes("pending") || normalized.includes("review") ? import_picocolors2.default.black(import_picocolors2.default.bgYellow(` ${label} `)) : normalized.includes("rejected") ? import_picocolors2.default.white(import_picocolors2.default.bgRed(` ${label} `)) : normalized.includes("draft") || normalized.includes("unknown") ? import_picocolors2.default.black(import_picocolors2.default.bgWhite(` ${label} `)) : import_picocolors2.default.black(import_picocolors2.default.bgBlue(` ${label} `));
2585
2711
  }, formatDate = (dateString) => dateString ? new Date(dateString).toLocaleString("ru-RU", {
2586
2712
  year: "numeric",
2587
2713
  month: "2-digit",
@@ -2590,6 +2716,8 @@ var import_picocolors2, printHeader, getTrackerIssueBadge, formatDate, printFiel
2590
2716
  minute: "2-digit"
2591
2717
  }) : "-", printField = (label, value, minWidth = 12) => {
2592
2718
  console.info(` ${import_picocolors2.default.dim(label.padEnd(minWidth))} ${value}`);
2719
+ }, printPluginId = (pluginId) => {
2720
+ printField("Plugin ID", import_picocolors2.default.cyan(pluginId));
2593
2721
  }, printCreated = (createdAt) => {
2594
2722
  printField("Created", import_picocolors2.default.white(formatDate(createdAt)));
2595
2723
  }, printUpdated = (updatedAt) => {
@@ -2598,218 +2726,54 @@ var import_picocolors2, printHeader, getTrackerIssueBadge, formatDate, printFiel
2598
2726
  }
2599
2727
  });
2600
2728
 
2601
- // src/distributions/external/tracker.ts
2602
- function buildIssueSummary(slug) {
2603
- return `Plugin: ${slug}`;
2604
- }
2605
- function buildIssueDescription(params) {
2606
- let { pluginId, slug, version, manifestJson } = params;
2607
- return [
2608
- `**Plugin UUID:** ${pluginId}`,
2609
- `**Slug:** ${slug}`,
2610
- `**Version:** ${version}`,
2611
- "",
2612
- "**Manifest:**",
2613
- "```json",
2614
- manifestJson,
2615
- "```"
2616
- ].join(`
2617
- `);
2618
- }
2619
- async function createPluginIssue(params) {
2620
- let { slug, pluginId, version, manifestJson } = params, body = {
2621
- queue: PLUGINMOD_QUEUE,
2622
- summary: buildIssueSummary(slug),
2623
- description: buildIssueDescription({ pluginId, slug, version, manifestJson }),
2624
- tags: ["tracker-plugin"]
2625
- };
2626
- return externalTrackerApiRequest("/issues", {
2627
- method: "POST",
2628
- body
2629
- });
2630
- }
2631
- async function updatePluginIssue(issueKey, params) {
2632
- return externalTrackerApiRequest(`/issues/${issueKey}`, {
2633
- method: "PATCH",
2634
- body: params
2635
- });
2636
- }
2637
- async function attachFileToIssue(issueKey, fileBuffer, fileName) {
2638
- let formData = new import_form_data.default();
2639
- return formData.append("file", fileBuffer, {
2640
- filename: fileName,
2641
- contentType: "application/zip"
2642
- }), externalTrackerApiRequest(`/issues/${issueKey}/attachments`, {
2643
- method: "POST",
2644
- formData
2645
- });
2646
- }
2647
- async function getIssueTransitions(issueKey) {
2648
- return externalTrackerApiRequest(`/issues/${issueKey}/transitions`, {
2649
- method: "GET"
2650
- });
2651
- }
2652
- async function executeIssueTransition(issueKey, transitionId) {
2653
- await externalTrackerApiRequest(
2654
- `/issues/${issueKey}/transitions/${transitionId}/_execute`,
2655
- {
2656
- method: "POST",
2657
- body: {}
2658
- }
2659
- );
2660
- }
2661
- async function getIssue(issueKey) {
2662
- return externalTrackerApiRequest(`/issues/${issueKey}`, {
2663
- method: "GET"
2664
- });
2665
- }
2666
- async function addIssueComment(issueKey, text) {
2667
- await externalTrackerApiRequest(`/issues/${issueKey}/comments`, {
2668
- method: "POST",
2669
- body: { text }
2670
- });
2671
- }
2672
- async function getMyPluginIssues() {
2673
- return externalTrackerApiRequest("/issues/_search", {
2674
- method: "POST",
2675
- body: {
2676
- filter: {
2677
- queue: "PLUGINMOD",
2678
- createdBy: "me()"
2679
- }
2680
- }
2681
- });
2682
- }
2683
- var import_form_data, PLUGINMOD_QUEUE, init_tracker = __esm({
2684
- "src/distributions/external/tracker.ts"() {
2685
- "use strict";
2686
- import_form_data = __toESM(require("form-data"));
2687
- init_trackerApiRequest();
2688
- PLUGINMOD_QUEUE = "PLUGINMOD";
2689
- }
2690
- });
2691
-
2692
- // src/distributions/external/info.ts
2693
- async function infoExternal(issueKey) {
2694
- let targetIssueKey = issueKey;
2695
- if (targetIssueKey || (targetIssueKey = (await pluginStateManager.load()).trackerIssueKey), !targetIssueKey) {
2696
- logger_default.warning(
2697
- `No issue key provided and plugin has not been submitted yet. Run "${CLI_NAME} submit" first.`
2698
- ), logger_default.suggest(`${CLI_NAME} submit`);
2699
- return;
2700
- }
2701
- logger_default.info(`\u23F3 Fetching plugin info for ${targetIssueKey}...`);
2729
+ // src/commands/info/platform.ts
2730
+ async function infoPlatform(pluginId) {
2731
+ let actualPluginId = await getPluginId(pluginId);
2732
+ logger_default.info(`\u23F3 Fetching plugin info for ID: ${actualPluginId}...`);
2702
2733
  try {
2703
- let issue = await getIssue(targetIssueKey);
2704
- showTrackerPluginInfo(issue);
2734
+ let pluginInfo = await getPluginInfo(actualPluginId);
2735
+ showPluginInfo(pluginInfo), pluginInfo.versions && pluginInfo.versions.length > 0 && (logger_default.newLine(), showPluginVersions(pluginInfo.versions));
2705
2736
  } catch (error2) {
2706
- throw logger_default.error(`Failed to fetch plugin info for ${targetIssueKey}`), error2;
2737
+ throw logger_default.error(`Failed to fetch plugin info for ID: ${actualPluginId}`), error2;
2707
2738
  }
2708
2739
  }
2709
- var init_info = __esm({
2710
- "src/distributions/external/info.ts"() {
2740
+ var init_platform2 = __esm({
2741
+ "src/commands/info/platform.ts"() {
2711
2742
  "use strict";
2712
- init_pluginStateManager();
2743
+ init_platform();
2744
+ init_getPluginId();
2713
2745
  init_logger();
2714
2746
  init_pluginDisplay();
2715
- init_meta();
2716
- init_tracker();
2717
2747
  }
2718
2748
  });
2719
2749
 
2720
- // src/distributions/external/list.ts
2721
- async function listExternal() {
2722
- logger_default.info("\u23F3 Fetching my plugins from Tracker...");
2750
+ // src/commands/list/platform.ts
2751
+ async function listPlatform() {
2752
+ logger_default.info("\u23F3 Fetching my plugins...");
2723
2753
  try {
2724
- let issues = await getMyPluginIssues();
2725
- showTrackerPluginList(issues);
2754
+ let plugins = await getMyPlugins();
2755
+ showPluginList(plugins);
2726
2756
  } catch (error2) {
2727
2757
  throw logger_default.error("Failed to fetch plugins list"), error2;
2728
2758
  }
2729
2759
  }
2730
- var init_list = __esm({
2731
- "src/distributions/external/list.ts"() {
2760
+ var init_platform3 = __esm({
2761
+ "src/commands/list/platform.ts"() {
2732
2762
  "use strict";
2763
+ init_platform();
2733
2764
  init_logger();
2734
2765
  init_pluginDisplay();
2735
- init_tracker();
2736
2766
  }
2737
2767
  });
2738
2768
 
2739
- // src/distributions/external/login.ts
2740
- async function loginExternal() {
2741
- console.info(
2742
- import_picocolors3.default.dim(
2743
- "To get an OAuth token for Yandex Tracker, please contact Tracker support and request one."
2744
- )
2745
- ), console.info("");
2746
- let trimmed = (await (0, import_prompts2.input)({
2747
- message: "Enter your OAuth token:",
2748
- required: !0
2749
- })).trim();
2750
- externalAuthManager.saveAuthData(trimmed), logger_default.success("OAuth token saved successfully."), logger_default.info('You can now use "weavix submit" to submit your plugin for review.');
2751
- }
2752
- function logoutExternal() {
2753
- if (!externalAuthManager.data) {
2754
- logger_default.warning("You are not logged in.");
2755
- return;
2756
- }
2757
- externalAuthManager.removeAuthData(), logger_default.success("Successfully logged out.");
2758
- }
2759
- var import_prompts2, import_picocolors3, init_login = __esm({
2760
- "src/distributions/external/login.ts"() {
2761
- "use strict";
2762
- import_prompts2 = require("@inquirer/prompts"), import_picocolors3 = __toESM(require("picocolors"));
2763
- init_logger();
2764
- init_authManager();
2765
- }
2766
- });
2767
-
2768
- // src/utils/execCommand.ts
2769
- var import_execa, execCommand, init_execCommand = __esm({
2770
- "src/utils/execCommand.ts"() {
2771
- "use strict";
2772
- import_execa = require("execa"), execCommand = async (command, cwd = process.cwd(), env) => {
2773
- await (0, import_execa.execa)(command, {
2774
- cwd,
2775
- shell: !0,
2776
- stdio: "inherit",
2777
- env: env ? { ...process.env, ...env } : void 0
2778
- });
2779
- };
2780
- }
2781
- });
2782
-
2783
- // src/commands/constants/templateCommands.ts
2784
- var pluginCmd, init_templateCommands = __esm({
2785
- "src/commands/constants/templateCommands.ts"() {
2786
- "use strict";
2787
- pluginCmd = {
2788
- install: "npm install",
2789
- build: "npm run build",
2790
- dev: "npm run dev",
2791
- lint: "npm run lint",
2792
- typecheck: "npm run typecheck",
2793
- test: "npm test",
2794
- audit: "npm audit --audit-level=critical"
2795
- };
2796
- }
2797
- });
2798
-
2799
- // src/commands/build.ts
2800
- var build, init_build = __esm({
2801
- "src/commands/build.ts"() {
2769
+ // src/commands/submit/options.ts
2770
+ var import_commander, skipChecksOption, init_options = __esm({
2771
+ "src/commands/submit/options.ts"() {
2802
2772
  "use strict";
2803
- init_execCommand();
2804
- init_logger();
2805
- init_templateCommands();
2806
- build = async ({ environment = "production" } = {}) => {
2807
- logger_default.info("\u{1F528} Building project..."), await execCommand(pluginCmd.install), await execCommand(
2808
- pluginCmd.build,
2809
- process.cwd(),
2810
- environment ? { VITE_DEPLOY_ENV: environment } : void 0
2811
- );
2812
- };
2773
+ import_commander = require("commander"), skipChecksOption = new import_commander.Option(
2774
+ "--skip-checks",
2775
+ "skip pre-submit validation (manifest, assets, lint, typecheck, tests, audit)"
2776
+ );
2813
2777
  }
2814
2778
  });
2815
2779
 
@@ -2836,14 +2800,38 @@ function validateArchiveSources() {
2836
2800
  "Source folder not found. Add ./src before publishing."
2837
2801
  ), ensurePathExists(import_path9.default.resolve(MANIFEST_FILE2), "manifest.json not found in plugin root."), validateMarketplaceAssets();
2838
2802
  }
2839
- var import_fs10, import_path9, MARKETPLACE_DIR, MARKETPLACE_INDEX_FILE, MARKETPLACE_HEADER_IMAGE_FILE, PUBLIC_DIR, PUBLIC_LOGO_FILE, MANIFEST_FILE2, DIST_DIR, SRC_DIR, ensurePathExists, validateManifestPublishingFields, ensureManifestCatalogFields, marketplacePaths, init_marketplace = __esm({
2803
+ async function getMarketplaceCatalogEntry() {
2804
+ let indexPath = import_path9.default.resolve(MARKETPLACE_DIR, MARKETPLACE_INDEX_FILE);
2805
+ ensurePathExists(
2806
+ indexPath,
2807
+ "Marketplace description not found. Add ./marketplace/index.md before uploading."
2808
+ ), await validateManifestPublishingFields();
2809
+ let longDescription = import_fs9.default.readFileSync(indexPath, "utf-8").trim(), manifest = await manifestManager.load();
2810
+ return {
2811
+ name: manifest.name.ru,
2812
+ description: manifest.description.ru,
2813
+ longDescription,
2814
+ tags: manifest.keywords ?? []
2815
+ };
2816
+ }
2817
+ function getMarketplaceHeaderImage() {
2818
+ let imagePath = import_path9.default.resolve(MARKETPLACE_DIR, MARKETPLACE_HEADER_IMAGE_FILE);
2819
+ return ensurePathExists(
2820
+ imagePath,
2821
+ "Marketplace header image not found. Add ./marketplace/header-image.jpg before uploading."
2822
+ ), {
2823
+ buffer: import_fs9.default.readFileSync(imagePath),
2824
+ filename: MARKETPLACE_HEADER_IMAGE_FILE
2825
+ };
2826
+ }
2827
+ var import_fs9, import_path9, MARKETPLACE_DIR, MARKETPLACE_INDEX_FILE, MARKETPLACE_HEADER_IMAGE_FILE, PUBLIC_DIR, PUBLIC_LOGO_FILE, MANIFEST_FILE2, DIST_DIR, SRC_DIR, ensurePathExists, validateManifestPublishingFields, ensureManifestCatalogFields, marketplacePaths, init_marketplace = __esm({
2840
2828
  "src/utils/marketplace.ts"() {
2841
2829
  "use strict";
2842
- import_fs10 = __toESM(require("fs")), import_path9 = __toESM(require("path"));
2830
+ import_fs9 = __toESM(require("fs")), import_path9 = __toESM(require("path"));
2843
2831
  init_manifestManager();
2844
2832
  init_logger();
2845
2833
  MARKETPLACE_DIR = "marketplace", MARKETPLACE_INDEX_FILE = "index.md", MARKETPLACE_HEADER_IMAGE_FILE = "header-image.jpg", PUBLIC_DIR = "public", PUBLIC_LOGO_FILE = "logo.svg", MANIFEST_FILE2 = "manifest.json", DIST_DIR = "dist", SRC_DIR = "src", ensurePathExists = (targetPath, errorMessage) => {
2846
- import_fs10.default.existsSync(targetPath) || (logger_default.error(errorMessage), process.exit(1));
2834
+ import_fs9.default.existsSync(targetPath) || (logger_default.error(errorMessage), process.exit(1));
2847
2835
  }, validateManifestPublishingFields = async () => {
2848
2836
  let manifest = await manifestManager.load();
2849
2837
  ensureManifestCatalogFields(manifest);
@@ -2863,18 +2851,128 @@ var import_fs10, import_path9, MARKETPLACE_DIR, MARKETPLACE_INDEX_FILE, MARKETPL
2863
2851
  }
2864
2852
  });
2865
2853
 
2854
+ // src/utils/buildArchive.ts
2855
+ async function buildArchive() {
2856
+ return validateArchiveSources(), (await manifestManager.load()).manifest_version === void 0 && (logger_default.error(
2857
+ `manifest_version is missing in manifest.json. Run "${CLI_NAME2} up" or add "manifest_version": 1 manually before uploading.`
2858
+ ), process.exit(1)), new Promise((resolve2, reject) => {
2859
+ let archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } }), chunks = [];
2860
+ archive.on("data", (chunk) => chunks.push(chunk)), archive.on("end", () => {
2861
+ let buffer = Buffer.concat(chunks);
2862
+ if (logger_default.info(`\u{1F4E6} Archive created (${buffer.length} bytes)`), isVerboseEnabled()) {
2863
+ let debugPath = writeVerboseArtifact("archive/latest-upload.zip", buffer);
2864
+ logger_default.info(`[platform-api-debug] Saved archive copy to ${debugPath}`);
2865
+ }
2866
+ resolve2(buffer);
2867
+ }), archive.on("error", reject), archive.glob("**/*", {
2868
+ cwd: process.cwd(),
2869
+ ignore: ["node_modules/**", "dist/**"],
2870
+ dot: !1
2871
+ });
2872
+ for (let dotfile of [".npmrc", ".nvmrc"]) {
2873
+ let dotfilePath = import_path10.default.resolve(dotfile);
2874
+ import_fs10.default.existsSync(dotfilePath) && archive.file(dotfilePath, { name: dotfile });
2875
+ }
2876
+ archive.file(import_path10.default.resolve(marketplacePaths.manifestFile), { name: "src/manifest.json" }), archive.glob(
2877
+ "**/*",
2878
+ {
2879
+ cwd: import_path10.default.resolve(marketplacePaths.distDir),
2880
+ dot: !1
2881
+ },
2882
+ { prefix: "dist/" }
2883
+ ), archive.finalize();
2884
+ });
2885
+ }
2886
+ var import_fs10, import_path10, import_archiver, init_buildArchive = __esm({
2887
+ "src/utils/buildArchive.ts"() {
2888
+ "use strict";
2889
+ import_fs10 = __toESM(require("fs")), import_path10 = __toESM(require("path")), import_archiver = __toESM(require("archiver"));
2890
+ init_manifestManager();
2891
+ init_meta2();
2892
+ init_logger();
2893
+ init_marketplace();
2894
+ init_verbose();
2895
+ }
2896
+ });
2897
+
2898
+ // src/utils/execCommand.ts
2899
+ var import_execa, execCommand, init_execCommand = __esm({
2900
+ "src/utils/execCommand.ts"() {
2901
+ "use strict";
2902
+ import_execa = require("execa"), execCommand = async (command, cwd = process.cwd(), env) => {
2903
+ await (0, import_execa.execa)(command, {
2904
+ cwd,
2905
+ shell: !0,
2906
+ stdio: "inherit",
2907
+ env: env ? { ...process.env, ...env } : void 0
2908
+ });
2909
+ };
2910
+ }
2911
+ });
2912
+
2913
+ // src/commands/constants/templateCommands.ts
2914
+ function getPluginCommands(projectRoot = process.cwd()) {
2915
+ return COMMANDS[detectPackageManager(projectRoot)];
2916
+ }
2917
+ var COMMANDS, pluginCmd, init_templateCommands = __esm({
2918
+ "src/commands/constants/templateCommands.ts"() {
2919
+ "use strict";
2920
+ init_packageManager();
2921
+ COMMANDS = {
2922
+ npm: {
2923
+ install: "npm install",
2924
+ build: "npm run build",
2925
+ dev: "npm run dev",
2926
+ lint: "npm run lint",
2927
+ typecheck: "npm run typecheck",
2928
+ test: "npm test",
2929
+ audit: "npm audit --audit-level=critical"
2930
+ },
2931
+ pnpm: {
2932
+ install: "pnpm install",
2933
+ build: "pnpm run build",
2934
+ dev: "pnpm run dev",
2935
+ lint: "pnpm run lint",
2936
+ typecheck: "pnpm run typecheck",
2937
+ test: "pnpm test",
2938
+ audit: "pnpm audit --audit-level=critical"
2939
+ }
2940
+ };
2941
+ pluginCmd = COMMANDS.npm;
2942
+ }
2943
+ });
2944
+
2945
+ // src/commands/build.ts
2946
+ var build, init_build = __esm({
2947
+ "src/commands/build.ts"() {
2948
+ "use strict";
2949
+ init_execCommand();
2950
+ init_logger();
2951
+ init_templateCommands();
2952
+ build = async ({ environment = "production" } = {}) => {
2953
+ logger_default.info("\u{1F528} Building project...");
2954
+ let pluginCmd2 = getPluginCommands();
2955
+ await execCommand(pluginCmd2.install), await execCommand(
2956
+ pluginCmd2.build,
2957
+ process.cwd(),
2958
+ environment ? { VITE_DEPLOY_ENV: environment } : void 0
2959
+ );
2960
+ };
2961
+ }
2962
+ });
2963
+
2866
2964
  // src/utils/pluginPackageScripts.ts
2867
2965
  function readPluginPackageScripts(cwd = process.cwd()) {
2868
- let packageJsonPath = import_path10.default.join(cwd, "package.json");
2966
+ let packageJsonPath = import_path11.default.join(cwd, "package.json");
2869
2967
  return import_fs11.default.existsSync(packageJsonPath) ? JSON.parse(import_fs11.default.readFileSync(packageJsonPath, "utf-8")).scripts ?? {} : null;
2870
2968
  }
2871
2969
  function hasPluginScript(name, cwd = process.cwd()) {
2872
2970
  return !!readPluginPackageScripts(cwd)?.[name];
2873
2971
  }
2874
- var import_fs11, import_path10, init_pluginPackageScripts = __esm({
2972
+ var import_fs11, import_path11, init_pluginPackageScripts = __esm({
2875
2973
  "src/utils/pluginPackageScripts.ts"() {
2876
2974
  "use strict";
2877
- import_fs11 = __toESM(require("fs")), import_path10 = __toESM(require("path"));
2975
+ import_fs11 = __toESM(require("fs")), import_path11 = __toESM(require("path"));
2878
2976
  }
2879
2977
  });
2880
2978
 
@@ -2884,16 +2982,18 @@ async function runSubmitPrechecks(options = {}) {
2884
2982
  logger_default.warning("Skipping pre-submit checks (--skip-checks).");
2885
2983
  return;
2886
2984
  }
2887
- logger_default.separator(), logger_default.info("\u{1F50D} Pre-submit checks"), logger_default.separator(), await runStep("Validate manifest.json", () => manifestManager.validate()), await runStep("Check publishing metadata and assets", async () => {
2985
+ logger_default.separator(), logger_default.info("\u{1F50D} Pre-submit checks"), logger_default.separator();
2986
+ let pluginCmd2 = getPluginCommands();
2987
+ await runStep("Validate manifest.json", () => manifestManager.validate()), await runStep("Check publishing metadata and assets", async () => {
2888
2988
  await validateManifestPublishingFields(), validateMarketplaceAssets();
2889
- }), await runShellStep("Install dependencies", pluginCmd.install), await runShellStep("Run linter", pluginCmd.lint), hasPluginScript("typecheck") ? await runShellStep("Run typecheck", pluginCmd.typecheck) : logger_default.verbose('Skipping typecheck (no "typecheck" script in package.json).'), hasPluginScript("test") ? await runShellStep("Run tests", pluginCmd.test) : logger_default.warning(
2989
+ }), await runShellStep("Install dependencies", pluginCmd2.install), await runShellStep("Run linter", pluginCmd2.lint), hasPluginScript("typecheck") ? await runShellStep("Run typecheck", pluginCmd2.typecheck) : logger_default.verbose('Skipping typecheck (no "typecheck" script in package.json).'), hasPluginScript("test") ? await runShellStep("Run tests", pluginCmd2.test) : logger_default.warning(
2890
2990
  'No "test" script in package.json \u2014 add tests before publishing, or run submit with --skip-checks.'
2891
- ), await runShellStep("Check dependency vulnerabilities", pluginCmd.audit), logger_default.separator(), logger_default.success("Pre-submit checks passed"), logger_default.separator();
2991
+ ), await runShellStep("Check dependency vulnerabilities", pluginCmd2.audit), logger_default.separator(), logger_default.success("Pre-submit checks passed"), logger_default.separator();
2892
2992
  }
2893
- var import_picocolors4, stepStart, stepDone, runStep, runShellStep, init_runSubmitPrechecks = __esm({
2993
+ var import_picocolors3, stepStart, stepDone, runStep, runShellStep, init_runSubmitPrechecks = __esm({
2894
2994
  "src/commands/submit/utils/runSubmitPrechecks.ts"() {
2895
2995
  "use strict";
2896
- import_picocolors4 = __toESM(require("picocolors"));
2996
+ import_picocolors3 = __toESM(require("picocolors"));
2897
2997
  init_manifestManager();
2898
2998
  init_execCommand();
2899
2999
  init_logger();
@@ -2901,128 +3001,222 @@ var import_picocolors4, stepStart, stepDone, runStep, runShellStep, init_runSubm
2901
3001
  init_pluginPackageScripts();
2902
3002
  init_templateCommands();
2903
3003
  stepStart = (label) => {
2904
- console.info(`${import_picocolors4.default.cyan("\u25B8")} ${label}`);
3004
+ console.info(`${import_picocolors3.default.cyan("\u25B8")} ${label}`);
2905
3005
  }, stepDone = (label) => {
2906
- console.info(`${import_picocolors4.default.green("\u2713")} ${label}`), console.info("");
3006
+ console.info(`${import_picocolors3.default.green("\u2713")} ${label}`), console.info("");
2907
3007
  }, runStep = async (label, run) => {
2908
3008
  stepStart(label), await run(), stepDone(label);
2909
3009
  }, runShellStep = async (label, command) => {
2910
- stepStart(label), console.info(import_picocolors4.default.dim(` $ ${command}`)), await execCommand(command), stepDone(label);
3010
+ stepStart(label), console.info(import_picocolors3.default.dim(` $ ${command}`)), await execCommand(command), stepDone(label);
2911
3011
  };
2912
3012
  }
2913
3013
  });
2914
3014
 
2915
- // src/utils/buildArchive.ts
2916
- async function buildArchive() {
2917
- return validateArchiveSources(), (await manifestManager.load()).manifest_version === void 0 && (logger_default.error(
2918
- `manifest_version is missing in manifest.json. Run "${CLI_NAME2} up" or add "manifest_version": 1 manually before uploading.`
2919
- ), process.exit(1)), new Promise((resolve2, reject) => {
2920
- let archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } }), chunks = [];
2921
- archive.on("data", (chunk) => chunks.push(chunk)), archive.on("end", () => {
2922
- let buffer = Buffer.concat(chunks);
2923
- if (logger_default.info(`\u{1F4E6} Archive created (${buffer.length} bytes)`), isVerboseEnabled()) {
2924
- let debugPath = writeVerboseArtifact("archive/latest-upload.zip", buffer);
2925
- logger_default.info(`[platform-api-debug] Saved archive copy to ${debugPath}`);
2926
- }
2927
- resolve2(buffer);
2928
- }), archive.on("error", reject), archive.glob("**/*", {
2929
- cwd: process.cwd(),
2930
- ignore: ["node_modules/**", "dist/**"],
2931
- dot: !1
3015
+ // src/commands/submit/utils/validateSlug.ts
3016
+ function promptForSlug() {
3017
+ return new Promise((resolve2) => {
3018
+ let rl = readline.createInterface({
3019
+ input: process.stdin,
3020
+ output: process.stdout
3021
+ });
3022
+ rl.question("Enter a new slug: ", (answer) => {
3023
+ rl.close(), resolve2(answer.trim());
2932
3024
  });
2933
- for (let dotfile of [".npmrc", ".nvmrc"]) {
2934
- let dotfilePath = import_path11.default.resolve(dotfile);
2935
- import_fs12.default.existsSync(dotfilePath) && archive.file(dotfilePath, { name: dotfile });
2936
- }
2937
- archive.file(import_path11.default.resolve(marketplacePaths.manifestFile), { name: "src/manifest.json" }), archive.glob(
2938
- "**/*",
2939
- {
2940
- cwd: import_path11.default.resolve(marketplacePaths.distDir),
2941
- dot: !1
2942
- },
2943
- { prefix: "dist/" }
2944
- ), archive.finalize();
2945
3025
  });
2946
3026
  }
2947
- var import_fs12, import_path11, import_archiver, init_buildArchive = __esm({
2948
- "src/utils/buildArchive.ts"() {
3027
+ async function validateAndGetUniqueSlug(currentSlug) {
3028
+ let slugToCheck = currentSlug, isValid = !1;
3029
+ for (; !isValid; )
3030
+ try {
3031
+ if ((await checkSlugAvailability(slugToCheck)).available)
3032
+ return isValid = !0, slugToCheck;
3033
+ logger_default.error(`\u274C Slug "${slugToCheck}" is already taken.`), logger_default.info("Please enter a different slug."), slugToCheck = await promptForSlug(), slugToCheck || (logger_default.error("Slug cannot be empty. Please try again."), slugToCheck = currentSlug);
3034
+ } catch (error2) {
3035
+ throw logger_default.error(`Failed to check slug availability: ${error2.message}`), error2;
3036
+ }
3037
+ return slugToCheck;
3038
+ }
3039
+ var readline, init_validateSlug = __esm({
3040
+ "src/commands/submit/utils/validateSlug.ts"() {
2949
3041
  "use strict";
2950
- import_fs12 = __toESM(require("fs")), import_path11 = __toESM(require("path")), import_archiver = __toESM(require("archiver"));
3042
+ readline = __toESM(require("readline"));
3043
+ init_platform();
3044
+ init_logger();
3045
+ }
3046
+ });
3047
+
3048
+ // src/commands/submit/platform.ts
3049
+ async function submitPlatform(options = {}) {
3050
+ await runSubmitPrechecks({ skip: options.skipChecks });
3051
+ let manifest = await manifestManager.load();
3052
+ await build(), logger_default.info("\u{1F4E6} Creating archive...");
3053
+ let archiveBuffer = await buildArchive(), archiveName = `${manifest.slug}-${manifest.version}.zip`, pluginId;
3054
+ if (manifest.id)
3055
+ pluginId = manifest.id, logger_default.info("\u{1F4E4} Updating plugin archive..."), await updatePluginArchive(pluginId, archiveBuffer, archiveName);
3056
+ else {
3057
+ let validatedSlug = await validateAndGetUniqueSlug(manifest.slug);
3058
+ validatedSlug !== manifest.slug && await manifestManager.update({ slug: validatedSlug }), logger_default.info("\u23F3 Creating plugin...");
3059
+ let createdPlugin = await createPlugin(archiveBuffer, archiveName);
3060
+ showPluginCreated(createdPlugin), pluginId = createdPlugin.id, await manifestManager.update({ id: pluginId });
3061
+ }
3062
+ let catalogEntry = await getMarketplaceCatalogEntry();
3063
+ logger_default.info("\u{1F4DD} Updating catalog entry from ./marketplace/index.md..."), await updateCatalogEntry(pluginId, catalogEntry);
3064
+ let headerImage = getMarketplaceHeaderImage();
3065
+ logger_default.info("\u{1F5BC}\uFE0F Uploading catalog image from ./marketplace/header-image.jpg..."), await updateCatalogImage(pluginId, headerImage.buffer, headerImage.filename), await submitPlugin(pluginId, manifest.version), logger_default.success("Plugin submitted for review!"), logger_default.info(` Version : ${manifest.version}`), logger_default.newLine();
3066
+ }
3067
+ var init_platform4 = __esm({
3068
+ "src/commands/submit/platform.ts"() {
3069
+ "use strict";
3070
+ init_platform();
2951
3071
  init_manifestManager();
2952
- init_meta2();
3072
+ init_buildArchive();
2953
3073
  init_logger();
2954
3074
  init_marketplace();
2955
- init_verbose();
3075
+ init_pluginDisplay();
3076
+ init_build();
3077
+ init_runSubmitPrechecks();
3078
+ init_validateSlug();
2956
3079
  }
2957
3080
  });
2958
3081
 
2959
- // src/distributions/external/submit.ts
2960
- async function submitExternal(options = {}) {
2961
- await runSubmitPrechecks({ skip: options.skipChecks });
2962
- let manifest = await manifestManager.load(), issueKey = (await pluginStateManager.load()).trackerIssueKey;
2963
- if (issueKey)
3082
+ // src/core/cliConfig/registerCommand.ts
3083
+ async function promptString(message, current) {
3084
+ return (await (0, import_prompts.input)({
3085
+ message: current ? `${message} (current: ${current})` : `${message} (optional)`,
3086
+ default: current,
3087
+ required: !1
3088
+ }))?.trim() || void 0;
3089
+ }
3090
+ async function runConfigSet(cliName) {
3091
+ let existing = readConfig() ?? {};
3092
+ logger_default.info(
3093
+ "Configure CLI overrides. Empty input clears the value (and falls back to defaults where applicable)."
3094
+ );
3095
+ let s3Endpoint = await promptString("S3 endpoint", existing.s3?.endpoint), s3Region = await promptString("S3 region", existing.s3?.region), mdsEndpoint = await promptString("MDS endpoint", existing.mds?.endpoint), productionStatic = await promptString(
3096
+ "Production bucket (static)",
3097
+ existing.buckets?.production?.static
3098
+ ), productionConfig = await promptString(
3099
+ "Production bucket (config)",
3100
+ existing.buckets?.production?.config
3101
+ ), pluginDownloadProduction = await promptString(
3102
+ "Plugin download base URL",
3103
+ existing.pluginDownloadBase?.production
3104
+ ), platformBaseUrl = await promptString(
3105
+ "Platform API base URL",
3106
+ existing.api?.platformBaseUrl
3107
+ ), oauthUrl = await promptString("OAuth token URL", existing.auth?.oauthUrl);
3108
+ writeConfig({
3109
+ s3: { endpoint: s3Endpoint, region: s3Region },
3110
+ mds: { endpoint: mdsEndpoint },
3111
+ buckets: {
3112
+ production: { static: productionStatic, config: productionConfig }
3113
+ },
3114
+ pluginDownloadBase: { production: pluginDownloadProduction },
3115
+ api: { platformBaseUrl },
3116
+ auth: { oauthUrl }
3117
+ }), logger_default.success(`Configuration saved \u2192 ${getConfigPath()}`), logger_default.info(`Inspect with "${cliName} config show" or revert with "${cliName} config clear".`);
3118
+ }
3119
+ function runConfigShow(cliName) {
3120
+ let cfg = readConfig();
3121
+ if (!cfg) {
3122
+ logger_default.info(
3123
+ `No configuration found at ${getConfigPath()}. Run "${cliName} config set" to create one.`
3124
+ );
3125
+ return;
3126
+ }
3127
+ logger_default.info(`Configuration at ${getConfigPath()}:`), logger_default.info(JSON.stringify(cfg, null, 2));
3128
+ }
3129
+ function runConfigClear() {
3130
+ clearConfig(), logger_default.success(`Configuration removed (${getConfigPath()})`);
3131
+ }
3132
+ function registerConfigCommand(program, cliName) {
3133
+ let config = program.command("config").description("manage CLI configuration");
3134
+ config.command("set").description("set CLI configuration values interactively").action(() => runConfigSet(cliName)), config.command("show").description("display current CLI configuration").action(() => runConfigShow(cliName)), config.command("clear").description("remove stored CLI configuration").action(runConfigClear);
3135
+ }
3136
+ var import_prompts, init_registerCommand = __esm({
3137
+ "src/core/cliConfig/registerCommand.ts"() {
3138
+ "use strict";
3139
+ import_prompts = require("@inquirer/prompts");
3140
+ init_logger();
3141
+ init_manager();
3142
+ }
3143
+ });
3144
+
3145
+ // src/utils/withErrorHandling.ts
3146
+ function withErrorHandling(fn) {
3147
+ return async (...args) => {
2964
3148
  try {
2965
- await getIssue(issueKey);
2966
- } catch {
2967
- issueKey = void 0;
3149
+ await fn(...args);
3150
+ } catch (error2) {
3151
+ error2 instanceof Error && error2.name === "ExitPromptError" && process.exit(0), logger_default.error(error2), printErrorHints(error2), process.exit(1);
2968
3152
  }
2969
- let pluginId = manifest.id ?? (0, import_crypto.randomUUID)();
2970
- manifest.id || await manifestManager.update({ id: pluginId });
2971
- let manifestJson = await manifestManager.loadRaw();
2972
- if (issueKey) {
2973
- logger_default.verbose(`\u23F3 Updating issue ${issueKey} with latest manifest...`);
2974
- let issueDescription = buildIssueDescription({
2975
- pluginId,
2976
- slug: manifest.slug,
2977
- version: manifest.version,
2978
- manifestJson
2979
- });
2980
- await updatePluginIssue(issueKey, { description: issueDescription });
2981
- } else if (options.ticket === !1) {
2982
- logger_default.warning(
2983
- "Tracker issue is required for tracker-backed submit. Skipping ticket creation."
2984
- );
3153
+ };
3154
+ }
3155
+ function getErrorMessage2(error2) {
3156
+ return error2 instanceof Error ? error2.message : String(error2);
3157
+ }
3158
+ function printErrorHints(error2) {
3159
+ if (error2 instanceof PackageManagerRuntimeError) {
3160
+ error2.action && logger_default.info(`Action: ${error2.action}`), logger_default.info(`Run ${CLI_NAME2} doctor from the plugin directory for full local diagnostics.`);
2985
3161
  return;
2986
- } else {
2987
- logger_default.info("\u23F3 Creating plugin issue in Tracker...");
2988
- let issue = await createPluginIssue({
2989
- pluginId,
2990
- slug: manifest.slug,
2991
- version: manifest.version,
2992
- manifestJson
2993
- });
2994
- await pluginStateManager.update({ trackerIssueKey: issue.key }), issueKey = issue.key, logger_default.info(` Tracker issue : ${issueKey}`);
2995
- }
2996
- logger_default.info("\u{1F528} Building plugin..."), await build(), logger_default.info("\u{1F4E6} Creating archive...");
2997
- let archiveBuffer = await buildArchive(), archiveName = `${manifest.slug}-${manifest.version}.zip`;
2998
- logger_default.verbose(`\u2B06\uFE0F Attaching ${archiveName} to ${issueKey}...`), await attachFileToIssue(issueKey, archiveBuffer, archiveName), await addIssueComment(
2999
- issueKey,
3000
- `Updated bundle: \`${archiveName}\` (${archiveBuffer.length} bytes)`
3001
- ), logger_default.verbose(`\u23F3 Fetching available transitions for ${issueKey}...`);
3002
- let transitions = await getIssueTransitions(issueKey), submitTransition = transitions.find(
3003
- (t) => t.display?.toLowerCase().includes(SUBMIT_TRANSITION_DISPLAY) || t.id?.toLowerCase().includes("waitingforapprove") || t.id?.toLowerCase().includes("waiting")
3004
- );
3005
- if (!submitTransition) {
3006
- let available = transitions.map((t) => `"${t.display ?? t.id}"`).join(", ");
3007
- logger_default.error(
3008
- `Could not find a "Waiting for approve" transition on ${issueKey}. Available: ${available}`
3009
- );
3162
+ }
3163
+ let message = getErrorMessage2(error2);
3164
+ if (isCorepackKeyIdError(message)) {
3165
+ logger_default.info(`Action: ${getPackageManagerRuntimeAction(message, "pnpm")}`);
3166
+ return;
3167
+ }
3168
+ /\b(manifest\.json|manifest validation|package manager|corepack|pnpm|npm|build|dist)\b/i.test(
3169
+ message
3170
+ ) && logger_default.info(`Run ${CLI_NAME2} doctor from the plugin directory for local diagnostics.`);
3171
+ }
3172
+ var init_withErrorHandling = __esm({
3173
+ "src/utils/withErrorHandling.ts"() {
3174
+ "use strict";
3175
+ init_meta2();
3176
+ init_logger();
3177
+ init_packageManager();
3178
+ }
3179
+ });
3180
+
3181
+ // src/distributions/external/login.ts
3182
+ async function loginExternal() {
3183
+ let tokenUrl = getOAuthTokenUrl();
3184
+ console.info(
3185
+ import_picocolors4.default.dim("Get your OAuth token at: ") + import_picocolors4.default.cyan(`${ESC}]8;;${tokenUrl}${BEL}${tokenUrl}${ESC}]8;;${BEL}`)
3186
+ ), console.info("");
3187
+ let token = await (0, import_prompts2.input)({
3188
+ message: "Enter your OAuth token:",
3189
+ required: !0
3190
+ }), orgId = await (0, import_prompts2.input)({
3191
+ message: "Enter your Organization ID (X-Org-ID):",
3192
+ required: !0
3193
+ });
3194
+ externalAuthManager.saveAuthData(token.trim());
3195
+ let cfg = readConfig() ?? {};
3196
+ writeConfig({ ...cfg, api: { ...cfg.api, platformOrgId: orgId.trim() } }), logger_default.success("OAuth token and organization ID saved successfully."), logger_default.info('You can now use "weavix submit" to submit your plugin for review.');
3197
+ }
3198
+ function logoutExternal() {
3199
+ if (!externalAuthManager.data) {
3200
+ logger_default.warning("You are not logged in.");
3010
3201
  return;
3011
3202
  }
3012
- logger_default.info("\u{1F680} Submitting plugin for review..."), await executeIssueTransition(issueKey, submitTransition.id), await addIssueComment(issueKey, `Submitted version \`${manifest.version}\` for review.`), logger_default.success("Plugin submitted for review!"), logger_default.info(` Tracker issue : ${issueKey}`), logger_default.info(` Version : ${manifest.version}`), logger_default.newLine();
3203
+ externalAuthManager.removeAuthData();
3204
+ let cfg = readConfig();
3205
+ if (cfg?.api?.platformOrgId) {
3206
+ let nextApi = { ...cfg.api };
3207
+ delete nextApi.platformOrgId, writeConfig({ ...cfg, api: nextApi });
3208
+ }
3209
+ logger_default.success("Successfully logged out.");
3013
3210
  }
3014
- var import_crypto, SUBMIT_TRANSITION_DISPLAY, init_submit = __esm({
3015
- "src/distributions/external/submit.ts"() {
3211
+ var import_prompts2, import_picocolors4, ESC, BEL, init_login = __esm({
3212
+ "src/distributions/external/login.ts"() {
3016
3213
  "use strict";
3017
- import_crypto = require("crypto");
3018
- init_build();
3019
- init_runSubmitPrechecks();
3020
- init_manifestManager();
3021
- init_pluginStateManager();
3022
- init_buildArchive();
3214
+ import_prompts2 = require("@inquirer/prompts"), import_picocolors4 = __toESM(require("picocolors"));
3215
+ init_manager();
3023
3216
  init_logger();
3024
- init_tracker();
3025
- SUBMIT_TRANSITION_DISPLAY = "waiting for approve";
3217
+ init_authManager();
3218
+ init_hosts();
3219
+ ESC = "\x1B", BEL = "\x07";
3026
3220
  }
3027
3221
  });
3028
3222
 
@@ -3036,22 +3230,20 @@ function registerDistributionCommands(program) {
3036
3230
  withErrorHandling(async () => {
3037
3231
  logoutExternal();
3038
3232
  })
3039
- ), program.command("submit").description("build plugin, create a Tracker issue in PLUGINMOD, and submit for review").addOption(skipChecksOption).action(withErrorHandling(submitExternal)), program.command("doctor").description("validate local plugin project, external config and auth").option("--network", "verify OAuth token with Tracker /myself", !1).option("--publish", "treat publish-readiness checks as failures", !1).option("--json", "machine-readable output", !1).action((options) => withErrorHandling(doctor)(options)), program.command("list").description("list all your plugins and their moderation status").action(withErrorHandling(listExternal)), program.command("info [issue-key]").description(
3040
- "show moderation status of a plugin (uses .tracker-plugin issue key if not provided)"
3041
- ).action(withErrorHandling(infoExternal));
3233
+ ), program.command("submit").description("build plugin and submit it to the platform for review").addOption(skipChecksOption).action(withErrorHandling(submitPlatform)), program.command("doctor").description("validate local plugin project, external config and auth").option("--network", "verify OAuth token with Tracker /myself", !1).option("--publish", "treat publish-readiness checks as failures", !1).option("--json", "machine-readable output", !1).action((options) => withErrorHandling(doctor)(options)), program.command("list").description("list all your plugins and their moderation status").action(withErrorHandling(listPlatform)), program.command("info [plugin-id]").description("show plugin status (uses plugin id from manifest if not provided)").action(withErrorHandling(infoPlatform));
3042
3234
  }
3043
3235
  var init_registerCommands = __esm({
3044
3236
  "src/distributions/external/registerCommands.ts"() {
3045
3237
  "use strict";
3046
3238
  init_doctor();
3239
+ init_platform2();
3240
+ init_platform3();
3047
3241
  init_options();
3242
+ init_platform4();
3048
3243
  init_registerCommand();
3049
3244
  init_withErrorHandling();
3050
- init_info();
3051
- init_list();
3052
3245
  init_login();
3053
3246
  init_meta();
3054
- init_submit();
3055
3247
  }
3056
3248
  });
3057
3249
 
@@ -3061,26 +3253,11 @@ init_meta2();
3061
3253
 
3062
3254
  // src/distribution/registerCommands.ts
3063
3255
  init_flag();
3064
- var impl4 = (init_registerCommands(), __toCommonJS(registerCommands_exports)), { registerDistributionCommands: registerDistributionCommands2 } = impl4;
3065
-
3066
- // src/utils/checkUpdate.ts
3067
- var import_node_fetch2 = __toESM(require("node-fetch"));
3068
-
3069
- // src/distribution/hosts.ts
3070
- init_flag();
3071
- var impl5 = (init_hosts(), __toCommonJS(hosts_exports)), {
3072
- getS3Endpoint: getS3Endpoint2,
3073
- getMdsEndpoint: getMdsEndpoint2,
3074
- getS3Region: getS3Region2,
3075
- getBuckets: getBuckets2,
3076
- getPluginDownloadBase: getPluginDownloadBase2,
3077
- getPlatformBaseUrl: getPlatformBaseUrl2,
3078
- getTrackerBaseUrl: getTrackerBaseUrl2,
3079
- getOAuthTokenUrl: getOAuthTokenUrl2,
3080
- getUpdateCheckInfo: getUpdateCheckInfo2
3081
- } = impl5;
3256
+ var impl6 = (init_registerCommands(), __toCommonJS(registerCommands_exports)), { registerDistributionCommands: registerDistributionCommands2 } = impl6;
3082
3257
 
3083
3258
  // src/utils/checkUpdate.ts
3259
+ var import_node_fetch3 = __toESM(require("node-fetch"));
3260
+ init_hosts2();
3084
3261
  init_logger();
3085
3262
  var SEMVER_RE = /^(\d+)\.(\d+)\.(\d+)$/, DIAGNOSTIC_FLAGS = /* @__PURE__ */ new Set(["--version", "-V", "--help", "-h", "help"]), parse = (v) => {
3086
3263
  let m = SEMVER_RE.exec(v);
@@ -3095,7 +3272,7 @@ var SEMVER_RE = /^(\d+)\.(\d+)\.(\d+)$/, DIAGNOSTIC_FLAGS = /* @__PURE__ */ new
3095
3272
  let current = parse(version);
3096
3273
  if (current)
3097
3274
  try {
3098
- let response = await (0, import_node_fetch2.default)(`${info2.registryUrl}/${info2.packageName}/latest`);
3275
+ let response = await (0, import_node_fetch3.default)(`${info2.registryUrl}/${info2.packageName}/latest`);
3099
3276
  if (!response.ok) return;
3100
3277
  let json = await response.json(), latest = parse(json.version);
3101
3278
  if (!latest) return;
@@ -3312,7 +3489,7 @@ async function create() {
3312
3489
  }
3313
3490
 
3314
3491
  // src/commands/debug/index.ts
3315
- var import_fs16 = __toESM(require("fs")), import_path17 = __toESM(require("path"));
3492
+ var import_fs15 = __toESM(require("fs")), import_path17 = __toESM(require("path"));
3316
3493
  init_manifestManager();
3317
3494
 
3318
3495
  // src/core/s3config/constants.ts
@@ -3336,10 +3513,11 @@ var registerCleanup = (cleanup) => {
3336
3513
  init_templateCommands();
3337
3514
 
3338
3515
  // src/commands/debug/utils/createDebugConfig.ts
3339
- var import_fs13 = __toESM(require("fs")), import_path14 = __toESM(require("path"));
3516
+ var import_fs12 = __toESM(require("fs")), import_path14 = __toESM(require("path"));
3340
3517
  init_manifestManager();
3341
3518
 
3342
3519
  // src/utils/convertManifestToConfig.ts
3520
+ init_hosts2();
3343
3521
  function buildPluginDownloadUrl(env, id, version) {
3344
3522
  return env === "debug" ? getPluginDownloadBase2(env) : `${getPluginDownloadBase2(env)}/${id}/${version}`;
3345
3523
  }
@@ -3384,20 +3562,20 @@ var convertManifestToConfig = (manifest, environment) => {
3384
3562
  // src/commands/debug/utils/createDebugConfig.ts
3385
3563
  var createDebugConfig = async () => {
3386
3564
  let manifest = await manifestManager.load(), config = convertManifestToConfig(manifest, "debug"), configPath = import_path14.default.join(process.cwd(), CONFIG_FILE_NAME);
3387
- import_fs13.default.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
3565
+ import_fs12.default.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
3388
3566
  };
3389
3567
 
3390
3568
  // src/commands/debug/utils/lockFile.ts
3391
- var import_fs14 = __toESM(require("fs")), import_path15 = __toESM(require("path")), LOCK_FILE_NAME = ".yaweavix-debug.lock", getLockFilePath = () => import_path15.default.join(process.cwd(), LOCK_FILE_NAME), getRunningDebugPid = () => {
3569
+ var import_fs13 = __toESM(require("fs")), import_path15 = __toESM(require("path")), LOCK_FILE_NAME = ".yaweavix-debug.lock", getLockFilePath = () => import_path15.default.join(process.cwd(), LOCK_FILE_NAME), getRunningDebugPid = () => {
3392
3570
  let lockPath = getLockFilePath();
3393
- if (!import_fs14.default.existsSync(lockPath))
3571
+ if (!import_fs13.default.existsSync(lockPath))
3394
3572
  return null;
3395
3573
  try {
3396
- let pid = JSON.parse(import_fs14.default.readFileSync(lockPath, "utf-8")).pid;
3574
+ let pid = JSON.parse(import_fs13.default.readFileSync(lockPath, "utf-8")).pid;
3397
3575
  return process.kill(pid, 0), pid;
3398
3576
  } catch {
3399
3577
  try {
3400
- import_fs14.default.unlinkSync(lockPath);
3578
+ import_fs13.default.unlinkSync(lockPath);
3401
3579
  } catch {
3402
3580
  }
3403
3581
  return null;
@@ -3405,19 +3583,19 @@ var import_fs14 = __toESM(require("fs")), import_path15 = __toESM(require("path"
3405
3583
  }, createLockFile = () => {
3406
3584
  let lockPath = getLockFilePath(), lockData = {
3407
3585
  pid: process.pid
3408
- }, fd = import_fs14.default.openSync(lockPath, "wx");
3409
- import_fs14.default.writeSync(fd, JSON.stringify(lockData, null, 2)), import_fs14.default.closeSync(fd);
3586
+ }, fd = import_fs13.default.openSync(lockPath, "wx");
3587
+ import_fs13.default.writeSync(fd, JSON.stringify(lockData, null, 2)), import_fs13.default.closeSync(fd);
3410
3588
  }, removeLockFile = () => {
3411
3589
  let lockPath = getLockFilePath();
3412
- import_fs14.default.existsSync(lockPath) && import_fs14.default.unlinkSync(lockPath);
3590
+ import_fs13.default.existsSync(lockPath) && import_fs13.default.unlinkSync(lockPath);
3413
3591
  };
3414
3592
 
3415
3593
  // src/commands/debug/utils/watchManifest.ts
3416
- var import_fs15 = __toESM(require("fs")), import_path16 = __toESM(require("path"));
3594
+ var import_fs14 = __toESM(require("fs")), import_path16 = __toESM(require("path"));
3417
3595
  init_manifestManager();
3418
3596
  init_logger();
3419
3597
  var watchManifest = () => {
3420
- let manifestPath = import_path16.default.join(process.cwd(), "manifest.json"), debounceTimer = null, watcher = import_fs15.default.watch(manifestPath, async (eventType) => {
3598
+ let manifestPath = import_path16.default.join(process.cwd(), "manifest.json"), debounceTimer = null, watcher = import_fs14.default.watch(manifestPath, async (eventType) => {
3421
3599
  eventType === "change" && (debounceTimer && clearTimeout(debounceTimer), debounceTimer = setTimeout(async () => {
3422
3600
  try {
3423
3601
  logger_default.newLine(), logger_default.info("Manifest file changed, validating..."), await manifestManager.validate(), logger_default.info("Regenerating debug config..."), await createDebugConfig(), logger_default.success("Debug config regenerated successfully");
@@ -3444,9 +3622,9 @@ If you lost the terminal tab, you can kill the process with:
3444
3622
  let configPath = import_path17.default.join(process.cwd(), CONFIG_FILE_NAME);
3445
3623
  options.lint && await manifestManager.validate(), await createDebugConfig();
3446
3624
  let watcher = watchManifest(), cleanup = () => {
3447
- watcher.close(), import_fs16.default.existsSync(configPath) && import_fs16.default.unlinkSync(configPath), removeLockFile();
3625
+ watcher.close(), import_fs15.default.existsSync(configPath) && import_fs15.default.unlinkSync(configPath), removeLockFile();
3448
3626
  };
3449
- registerCleanup(cleanup), createLockFile(), logger_default.newLine(), logger_default.info("\u{1F527} Debug mode started!"), logger_default.newLine(), logger_default.info("\u{1F4CC} The plugin is now available in the Tracker interface."), logger_default.info("Open Tracker and check the plugin functionality in the appropriate context."), logger_default.newLine(), logger_default.info("\u26A0\uFE0F Do not try to open localhost in the browser - the plugin works"), logger_default.info("only inside Tracker through a special loading mechanism."), logger_default.newLine(), logger_default.info("\u{1F504} Code changes will be automatically reloaded."), logger_default.info("Press Ctrl+C to stop."), logger_default.newLine(), await execCommand(pluginCmd.dev), cleanup();
3627
+ registerCleanup(cleanup), createLockFile(), logger_default.newLine(), logger_default.info("\u{1F527} Debug mode started!"), logger_default.newLine(), logger_default.info("\u{1F4CC} The plugin is now available in the Tracker interface."), logger_default.info("Open Tracker and check the plugin functionality in the appropriate context."), logger_default.newLine(), logger_default.info("\u26A0\uFE0F Do not try to open localhost in the browser - the plugin works"), logger_default.info("only inside Tracker through a special loading mechanism."), logger_default.newLine(), logger_default.info("\u{1F504} Code changes will be automatically reloaded."), logger_default.info("Press Ctrl+C to stop."), logger_default.newLine(), await execCommand(getPluginCommands().dev), cleanup();
3450
3628
  }
3451
3629
 
3452
3630
  // src/commands/lint.ts
@@ -3455,20 +3633,20 @@ init_execCommand();
3455
3633
  init_logger();
3456
3634
  init_templateCommands();
3457
3635
  async function lint() {
3458
- logger_default.info("\u{1F50D} Running manifest.json validation..."), await manifestManager.validate(), logger_default.info("\u{1F50D} Running code lint check..."), await execCommand(pluginCmd.lint);
3636
+ logger_default.info("\u{1F50D} Running manifest.json validation..."), await manifestManager.validate(), logger_default.info("\u{1F50D} Running code lint check..."), await execCommand(getPluginCommands().lint);
3459
3637
  }
3460
3638
 
3461
3639
  // src/commands/up/index.ts
3462
- var import_fs19 = require("fs"), import_promises5 = require("fs/promises");
3640
+ var import_fs18 = require("fs"), import_promises4 = require("fs/promises");
3463
3641
  init_execCommand();
3464
3642
 
3465
3643
  // src/commands/up/utils/copyTemplateFiles.ts
3466
- var import_fs17 = require("fs"), import_promises3 = require("fs/promises"), import_path18 = __toESM(require("path"));
3644
+ var import_fs16 = require("fs"), import_promises2 = require("fs/promises"), import_path18 = __toESM(require("path"));
3467
3645
  var copyTemplateFiles = async (files) => {
3468
3646
  await Promise.all(
3469
3647
  files.map(async (file) => {
3470
3648
  let templatePath, targetPath, force = !1;
3471
- typeof file == "string" ? (templatePath = getTemplatePath(file), targetPath = `./${file}`) : (templatePath = file.sourcePath ?? getTemplatePath(file.source ?? file.target), targetPath = `./${file.target}`, force = file.force ?? !1), (0, import_fs17.existsSync)(templatePath) && (force || (0, import_fs17.existsSync)(targetPath)) && (await (0, import_promises3.mkdir)(import_path18.default.dirname(targetPath), { recursive: !0 }), await (0, import_promises3.copyFile)(templatePath, targetPath));
3649
+ typeof file == "string" ? (templatePath = getTemplatePath(file), targetPath = `./${file}`) : (templatePath = file.sourcePath ?? getTemplatePath(file.source ?? file.target), targetPath = `./${file.target}`, force = file.force ?? !1), (0, import_fs16.existsSync)(templatePath) && (force || (0, import_fs16.existsSync)(targetPath)) && (await (0, import_promises2.mkdir)(import_path18.default.dirname(targetPath), { recursive: !0 }), await (0, import_promises2.copyFile)(templatePath, targetPath));
3472
3650
  })
3473
3651
  );
3474
3652
  }, overlayFileCopy = (overlayDir, sourceFilename, targetFilename) => ({
@@ -3498,15 +3676,15 @@ async function updateManifestCompatibility() {
3498
3676
  }
3499
3677
 
3500
3678
  // src/commands/up/utils/updatePackageDependencies.ts
3501
- var import_fs18 = require("fs"), import_promises4 = require("fs/promises");
3679
+ var import_fs17 = require("fs"), import_promises3 = require("fs/promises");
3502
3680
  var updatePackageDependencies = async (dependencies) => {
3503
3681
  let packageJsonPath = "./package.json", templatePackageJsonPath = getTemplatePath("package.json");
3504
- if (!(0, import_fs18.existsSync)(packageJsonPath) || !(0, import_fs18.existsSync)(templatePackageJsonPath))
3682
+ if (!(0, import_fs17.existsSync)(packageJsonPath) || !(0, import_fs17.existsSync)(templatePackageJsonPath))
3505
3683
  return;
3506
- let packageJsonContent = await (0, import_promises4.readFile)(packageJsonPath, "utf-8"), templatePackageJsonContent = await (0, import_promises4.readFile)(templatePackageJsonPath, "utf-8"), packageJson = JSON.parse(packageJsonContent), templatePackageJson = JSON.parse(templatePackageJsonContent), updated = !1;
3684
+ let packageJsonContent = await (0, import_promises3.readFile)(packageJsonPath, "utf-8"), templatePackageJsonContent = await (0, import_promises3.readFile)(templatePackageJsonPath, "utf-8"), packageJson = JSON.parse(packageJsonContent), templatePackageJson = JSON.parse(templatePackageJsonContent), updated = !1;
3507
3685
  dependencies.forEach((dep) => {
3508
3686
  packageJson.dependencies?.[dep] && templatePackageJson.dependencies?.[dep] && packageJson.dependencies[dep] !== templatePackageJson.dependencies[dep] && (packageJson.dependencies[dep] = templatePackageJson.dependencies[dep], updated = !0);
3509
- }), updated && await (0, import_promises4.writeFile)(packageJsonPath, JSON.stringify(packageJson, null, 4) + `
3687
+ }), updated && await (0, import_promises3.writeFile)(packageJsonPath, JSON.stringify(packageJson, null, 4) + `
3510
3688
  `, "utf-8");
3511
3689
  };
3512
3690
 
@@ -3518,11 +3696,11 @@ var npmrcPath = "./.npmrc", npmrcTemplateFilename = "npmrc.template", sharedFile
3518
3696
  ];
3519
3697
  async function isNpmrcOutdated() {
3520
3698
  let templatePath = getOverlayTemplatePath(overlayDirName, npmrcTemplateFilename);
3521
- if (!(0, import_fs19.existsSync)(npmrcPath) || !(0, import_fs19.existsSync)(templatePath))
3699
+ if (!(0, import_fs18.existsSync)(npmrcPath) || !(0, import_fs18.existsSync)(templatePath))
3522
3700
  return !1;
3523
3701
  let [currentNpmrc, templateNpmrc] = await Promise.all([
3524
- (0, import_promises5.readFile)(npmrcPath, "utf-8"),
3525
- (0, import_promises5.readFile)(templatePath, "utf-8")
3702
+ (0, import_promises4.readFile)(npmrcPath, "utf-8"),
3703
+ (0, import_promises4.readFile)(templatePath, "utf-8")
3526
3704
  ]);
3527
3705
  return currentNpmrc !== templateNpmrc;
3528
3706
  }
@@ -3535,12 +3713,12 @@ async function up() {
3535
3713
  }
3536
3714
 
3537
3715
  // src/utils/getVersion.ts
3538
- var import_fs20 = require("fs"), import_path19 = require("path"), UNKNOWN_VERSION = "unknown", CANDIDATES = ["..", "../.."], findVersionInPackageJson = (startDir) => {
3716
+ var import_fs19 = require("fs"), import_path19 = require("path"), UNKNOWN_VERSION = "unknown", CANDIDATES = ["..", "../.."], findVersionInPackageJson = (startDir) => {
3539
3717
  for (let rel of CANDIDATES) {
3540
3718
  let path24 = (0, import_path19.resolve)(startDir, rel, "package.json");
3541
- if ((0, import_fs20.existsSync)(path24))
3719
+ if ((0, import_fs19.existsSync)(path24))
3542
3720
  try {
3543
- let pkg = JSON.parse((0, import_fs20.readFileSync)(path24, "utf-8"));
3721
+ let pkg = JSON.parse((0, import_fs19.readFileSync)(path24, "utf-8"));
3544
3722
  if (typeof pkg.version == "string") return pkg.version;
3545
3723
  } catch {
3546
3724
  }