Skip to content

Commit

Permalink
add create workspace in empty folder
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-nikonov committed Jan 10, 2025
1 parent aaa17e9 commit 8f36d3d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
4 changes: 3 additions & 1 deletion clio/Command/AddSchema.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Clio.Common;
using CommandLine;
using System.Net.Security;

namespace Clio.Command;

Expand Down Expand Up @@ -50,5 +51,6 @@ public override int Execute(AddSchemaOptions options){
}

#endregion



}
2 changes: 0 additions & 2 deletions clio/Command/CreateWorkspaceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public class CreateWorkspaceCommandOptions : WorkspaceOptions

#region Properties: Public

[Option('a', "AppCode", Required = false, HelpText = "Application code")]
public string AppCode { get; set; }

internal override bool RequiredEnvironment => false;

Expand Down
41 changes: 40 additions & 1 deletion clio/Command/RestoreWorkspaceCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Clio.Command
{
using System;
using System.IO;
using Clio.Common;
using Clio.Workspaces;
using CommandLine;
Expand All @@ -22,6 +23,9 @@ public WorkspaceOptions() {
[Option("IsCreateSolution", Required = false, HelpText = "True if you need to create the Solution", Default = true)]
public bool? IsCreateSolution { get; set; }

[Option('a', "AppCode", Required = false, HelpText = "Application code")]
public string AppCode { get; set; }

}

[Verb("restore-workspace", Aliases = new string[] { "restorew", "pullw", "pull-workspace" },
Expand All @@ -42,15 +46,17 @@ public class RestoreWorkspaceCommand : Command<RestoreWorkspaceOptions>

private readonly IWorkspace _workspace;
private readonly ILogger _logger;
private readonly CreateWorkspaceCommand _createWorkspaceCommand;

#endregion

#region Constructors: Public

public RestoreWorkspaceCommand(IWorkspace workspace, ILogger logger) {
public RestoreWorkspaceCommand(IWorkspace workspace, ILogger logger, CreateWorkspaceCommand createWorkspaceCommand) {
workspace.CheckArgumentNull(nameof(workspace));
_workspace = workspace;
_logger = logger;
_createWorkspaceCommand = createWorkspaceCommand;
}

#endregion
Expand All @@ -62,12 +68,45 @@ public override int Execute(RestoreWorkspaceOptions options) {
_workspace.Restore(options);
_logger.WriteInfo("Done");
return 0;
} catch (FileNotFoundException ex) {
return _createWorkspaceCommand.Execute(CloneFromRestoreOptions(options));
} catch (Exception e) {
_logger.WriteError(e.Message);
return 1;
}
}

private CreateWorkspaceCommandOptions CloneFromRestoreOptions(RestoreWorkspaceOptions options) {
return new CreateWorkspaceCommandOptions {
IsNugetRestore = options.IsNugetRestore,
IsCreateSolution = options.IsCreateSolution,
AppCode = options.AppCode,
Uri = options.Uri,
Password = options.Password,
Login = options.Login,
IsNetCore = options.IsNetCore,
Environment = options.Environment,
Maintainer = options.Maintainer,
DevMode = options.DevMode,
WorkspacePathes = options.WorkspacePathes,
DeveloperModeEnabled = options.DeveloperModeEnabled,
Safe = options.Safe,
ClientId = options.ClientId,
ClientSecret = options.ClientSecret,
AuthAppUri = options.AuthAppUri,
IsSilent = options.IsSilent,
RestartEnvironment = options.RestartEnvironment,
DbServerUri = options.DbServerUri,
DbUser = options.DbUser,
DbPassword = options.DbPassword,
BackUpFilePath = options.BackUpFilePath,
DbWorknigFolder = options.DbWorknigFolder,
DbName = options.DbName,
Force = options.Force,
CallbackProcess = options.CallbackProcess
};
}

#endregion

}
Expand Down
1 change: 1 addition & 0 deletions clio/Package/BasePackageInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private string InstallPackageOnServer(string fileName, EnvironmentSettings envir
PackageInstallOptions packageInstallOptions) {
string packageName = UploadPackage(filePath, environmentSettings);
string packageCode = packageName.Split('.')[0];
_logger.WriteInfo($"{environmentSettings.Uri}");
if (!CreateBackupPackage(packageCode, filePath, environmentSettings)) {
return (false, "Dont created backup.");
}
Expand Down
2 changes: 1 addition & 1 deletion clio/Workspace/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void PublishZipToFolder(string zipFileName, string destionationFolderPath
_workspaceInstaller.Publish(WorkspaceSettings.Packages, zipFileName, destionationFolderPath, overrideFile);
}



public string PublishToFolder(string workspacePath, string appStorePath, string appName, string appVersion, string branch = null) {
var hasBranch = !string.IsNullOrEmpty(branch);
Expand Down

0 comments on commit 8f36d3d

Please sign in to comment.