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

Refactor installer #15

Closed
wants to merge 21 commits into from
Closed

Refactor installer #15

wants to merge 21 commits into from

Conversation

nikolai-laevskii
Copy link

@nikolai-laevskii nikolai-laevskii commented May 24, 2023

Description:

  • Updated installers
  • Refactored DotnetCoreInstaller

Refactoring was conducted only for installer.ts module. The most significant changes are in DotnetCoreInstaller class:

  1. Logic related to the install dir was separated and moved to simple static DotnetInstallDir class
  2. Logic related to the install script was moved to DotnetInstallScript class, which now allows to invoke install-script multiple times and conditionally apply script arguments.

Example of DotnetInstallScript class usage (just an example code, not how it is actually set here)

// Conditionally invoke install script
if (IS_WINDOWS) {
    // initialize DotnetInstallScriptClass
    const installScript: Promise<exec.ExecOutput> = await new DotnetInstallScript()
          // arguments can be inserted via this method
          .useArguments('-Runtime', 'dotnet')
          // version can be set via this method, it's just a syntactic sugar over useArguments that will insert arguments based on version provided
          .useVersion({ type: '-Channel', value: '6.0', qualityFlag: false })
          // useVersion and useArguments methods are chainable
          // script then can be then executed with execute method
          .execute();

    if (installScript.exitCode) { /* handle error */ }
}

const {exitCode, stderr} = await new DotnetInstallScript()
    // arguments do not convert automatically due the ambiguity in casing between some (such as -JSonFile and --jsonfile)
    .useArguments(IS_WINDOWS ? '-Version' : '--version', '6.0.100')
    .execute()

The script preparation is conducted upon calling the constructor and all platform-specific arguments are inserted by default

Related issue:
Related but does not solve actions#387, just conducts necessary preparations for further fix. Should be treated as general refactoring.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

src/installer.ts Show resolved Hide resolved
src/installer.ts Show resolved Hide resolved
src/installer.ts Outdated Show resolved Hide resolved
src/installer.ts Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
@nikolai-laevskii
Copy link
Author

actions#432

@nikolai-laevskii nikolai-laevskii deleted the refactor-installer branch June 6, 2023 11:20
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.

4 participants