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

Add pre / post-installation checks #337

Open
manuel3108 opened this issue May 5, 2024 · 0 comments
Open

Add pre / post-installation checks #337

manuel3108 opened this issue May 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@manuel3108
Copy link
Member

manuel3108 commented May 5, 2024

Topic

core, tests

Description

Currently it is possible to apply the same composer multiple times to a project. Additionally, we don't have a way to detect if a composer is supported on the current computer (external dependencies installed, see tauri which requires rust)

Describe the solution you'd like

I have previously already added some types to get a feeling for all components of a composer. The types are not accurate and do not provide any meaningful enhancements. Everything needs to be re-thinked.

Preconditions

Preconditions need to ensure that a given composer can be used within the given environment. This is especially useful, when considering composers that require some other globally installed tooling to work correctly (#9). Preconditions are workspace independent and can only check for the global environment.

Here is a sample pre installation check to determine if the Tauri adder could be installed:

export const checks = defineComposerChecks({
    options,
    preconditions: [
        {
            name: "rust installed",
            run: ({ execute }) => {
                // execute a shell command and gather it's output and exit code
                const { output, exitCode } = execute("cargo", ["version"]);

                // if the exit code is 0, we can assume that cargo / rust is installed correctly
                return exitCode == 0;
            },
        },
    ],
    preInstallation: [],
    postInstallation: [],
});

Precondition checks should be executed before the composer runs to avoid unnecessary file modifications in case any of the preconditions fails. In case at least one precondition fails, the composers should not install itself and rather fail. The user should be notified with an appropriate error message.

Pre installation checks

Pre installation checks are executed before the adder executes, but after the project has been detected / created and therefore have full access to the workspace (minus the options, as they have not been chosen yet). These checks should identify if

  • the composer is supported in the current environment (svelte / kit)
  • the composer has already been applied or the tool to compose is already setup (i.e. the tailwdincss.config.js file is already present / installed packages already present)

Post installation checks

Should check if a composer was successfully installed, basically they are the same as the pre installation checks, but they are executed after a composer was executed to determine if everything was set up as expected.

Further thoughts

Those ideas are mainly taken from svelte-add (predecessor of svelte-compose) and need to be partially re-thought.

Do we really need the post installation checks?
Is there any reason we would not trust in our code? Additionally we have tests that run when merging PR's that ensure that alle test execute correctly. Those tests not only check that that special files are present and contain special contents, but run explicit integration tests for each possible composer and svelte template possibility.

Do we really need pre installation checks?
Once we got this far, let's think if we need pre installation checks. Should they be optional? For most composers it should be enough to check if any of the dependencies is already present. But what if we have something like #18 (Github pages) that does not apply a dependency? Should we provide pre build checks for checking the dependencies? How should the method definition of those look like?

@manuel3108 manuel3108 added the enhancement New feature or request label May 5, 2024
@manuel3108 manuel3108 self-assigned this May 19, 2024
@manuel3108 manuel3108 mentioned this issue May 19, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant