Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEST-321: Create Media Theme deployment #2

Merged
merged 13 commits into from
Aug 18, 2022
Merged

NEST-321: Create Media Theme deployment #2

merged 13 commits into from
Aug 18, 2022

Conversation

DemeSzabolcs
Copy link
Member

@DemeSzabolcs DemeSzabolcs commented Aug 5, 2022

Justification = "It's a console application it doesn't need localization.")]
public static void Main(string[] args)
{
if (args.Length == 3 && bool.TryParse(args[2], out bool clearMediaFolder))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better and more future-proof to use a library for parsing CLI. See Hastlayer.

Copy link
Member Author

@DemeSzabolcs DemeSzabolcs Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please send me a specific example? I couldn't find any.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM found it.

{
// Creating directory for the deployment.
var currentRootDirectory = Directory.GetDirectoryRoot(Directory.GetCurrentDirectory());
var newDirectoryPath = Path.Join(currentRootDirectory, "MediaThemeDeployment_")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should accept a parameter for the target directory. It can fall back to this one if it's not given.

// Determine whether the directory exists.
if (Directory.Exists(newDirectoryPath))
{
WriteLine("That file already exists.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directory

{
dynamic assetJObject = new JObject();
assetJObject.SourcePath = Path.Join(
"_MediaTheme/Assets",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use these texts as constants as I did in the module. For all strings.

// Getting templates.
var pathToTemplates = Path.Join(pathToTheme, "Views");

var allTemplatesPaths = Directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When copying the files and adding them to the recipe, please do a string replace in the filename: change . to _ and - to __.

"Globalization",
"CA1303:Do not pass literals as localized parameters",
Justification = "It's a console application it doesn't need localization.")]
public static void Main(string[] args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For such a huge method I'd recommend creating private methods for clean code.

{
public const string MediaThemeRootDirectory = "_MediaTheme";
public const string MediaThemeDeploymentDirectory = "MediaThemeDeployment_";
public const string MediaThemeWwwRootDirectory = "wwwroot";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public const string MediaThemeWwwRootDirectory = "wwwroot";
public const string LocalThemeWwwRootDirectory = "wwwroot";

public const string MediaThemeRootDirectory = "_MediaTheme";
public const string MediaThemeDeploymentDirectory = "MediaThemeDeployment_";
public const string MediaThemeWwwRootDirectory = "wwwroot";
public const string MediaThemeViewsDirectory = "Views";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public const string MediaThemeViewsDirectory = "Views";
public const string LocalThemeViewsDirectory = "Views";

public const string MediaThemeDeploymentDirectory = "MediaThemeDeployment_";
public const string MediaThemeWwwRootDirectory = "wwwroot";
public const string MediaThemeViewsDirectory = "Views";
public const string MediaThemeTemplatesFolder = "Templates";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public const string MediaThemeTemplatesFolder = "Templates";
public const string MediaThemeTemplatesDirectory = "Templates";

Comment on lines 16 to 17
[Option('i', "default-id", Required = true, HelpText = "Default theme ID.")]
public string? DefaultThemeId { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it base theme instead of default theme?

Readme.md Outdated Show resolved Hide resolved
@barthamark barthamark merged commit c10a772 into dev Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants