public async Task ExecuteAsync(IPluginJobContext context) { if (!CliUtils.ParseArgs(_options, context.Args)) { return; } if (_isHelp) { PrintUsage(); return; } var pluginId = string.Empty; if (context.Extras != null && context.Extras.Length > 0) { pluginId = context.Extras[0]; } var pluginPath = string.IsNullOrEmpty(pluginId) ? _settingsManager.ContentRootPath : PathUtils.Combine(_pathManager.GetPluginPath(pluginId)); var(plugin, errorMessage) = await PluginUtils.ValidateManifestAsync(pluginPath); if (plugin == null) { await WriteUtils.PrintErrorAsync(errorMessage); return; } var zipPath = Package(_pathManager, plugin); var fileSize = FileUtils.GetFileSizeByFilePath(zipPath); await WriteUtils.PrintSuccessAsync($"Packaged: {zipPath} ({fileSize})"); }
public async Task ExecuteAsync(IPluginJobContext context) { if (!CliUtils.ParseArgs(_options, context.Args)) { return; } if (_isHelp) { PrintUsage(); return; } var(status, failureMessage) = _apiService.GetStatus(); if (status == null) { await WriteUtils.PrintErrorAsync(failureMessage); return; } var pluginId = string.Empty; if (context.Extras != null && context.Extras.Length > 0) { pluginId = context.Extras[0]; } var pluginPath = string.IsNullOrEmpty(pluginId) ? _settingsManager.ContentRootPath : PathUtils.Combine(_pathManager.GetPluginPath(pluginId)); var(plugin, errorMessage) = await PluginUtils.ValidateManifestAsync(pluginPath); if (plugin == null) { await WriteUtils.PrintErrorAsync(errorMessage); return; } if (!string.IsNullOrEmpty(_version)) { SemVersion.TryParse(plugin.Version, out var pluginVersion); string versionChanged; if (_version == "major") { versionChanged = pluginVersion.Change(pluginVersion.Major + 1).ToString(); } else if (_version == "minor") { versionChanged = pluginVersion.Change(pluginVersion.Major, pluginVersion.Minor + 1).ToString(); } else if (_version == "patch") { versionChanged = pluginVersion.Change(pluginVersion.Major, pluginVersion.Minor, pluginVersion.Patch + 1).ToString(); } else if (PluginUtils.IsSemVersion(_version)) { versionChanged = _version; } else { await WriteUtils.PrintErrorAsync($"Invalid plugin version '{_version}'"); return; } if (versionChanged != plugin.Version) { await PluginUtils.UpdateVersionAsync(pluginPath, versionChanged); (plugin, errorMessage) = await PluginUtils.ValidateManifestAsync(pluginPath); if (plugin == null) { await WriteUtils.PrintErrorAsync(errorMessage); return; } } } var packageId = PluginUtils.GetPackageId(plugin.Publisher, plugin.Name, plugin.Version); var zipPath = PluginPackageJob.Package(_pathManager, plugin); var fileSize = FileUtils.GetFileSizeByFilePath(zipPath); await Console.Out.WriteLineAsync($"Packaged: {zipPath}"); await Console.Out.WriteLineAsync($"Publishing {packageId} ({fileSize})..."); bool success; (success, failureMessage) = _apiService.PluginPublish(plugin.Publisher, zipPath); if (success) { await WriteUtils.PrintSuccessAsync($"Published {packageId}, your plugin will live at {CloudUtils.Www.GetPluginUrl(plugin.PluginId)} (might take a few minutes for it to show up)."); } else { await WriteUtils.PrintErrorAsync(failureMessage); } }