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 Package Parameter to Init #254

Conversation

wba2hi
Copy link
Contributor

@wba2hi wba2hi commented Apr 25, 2024

It is now possible to initialize a standard package using velocitas init -p devenv-runtimes. This command will depending on if the devenv-runtimes package is defined in .velocitas.json use the version specified in .velocitas.json or use the latest version if not specified in .velocitas.json.

Using a custom version:
velocitas init -p devenv-runtimes@v3.0.0.

Using a custom package:
velocitas init -p https://github.com/SoftwareDefinedVehicle/devenv-runtimes.git@v3.0.0

If initializing a package which is not part of .velocitas.json it will automatically be added to it. If a package specifies components but no component is referenced in .velocitas.json, all components will be added automatically during initialization.

@wba2hi
Copy link
Contributor Author

wba2hi commented Apr 25, 2024

Tested Scenarios:
velocitas init --package devenv-github-workflows
velocitas init --package devenv-github-templates
velocitas init --package devenv-devcontainer-setup
velocitas init --package devenv-runtimes

velocitas init -p devenv-github-workflows@v5.0.0
velocitas init -p devenv-github-templates@v1.0.4
velocitas init -p devenv-devcontainer-setup@v2.0.0
velocitas init -p devenv-runtimes@v3.0.0

velocitas init -p https://github.com/eclipse-velocitas/devenv-github-workflows.git@v5.0.0
velocitas init -p https://github.com/eclipse-velocitas/devenv-github-templates.git@v1.0.4
velocitas init -p https://github.com/eclipse-velocitas/devenv-devcontainer-setup.git@v2.0.0
velocitas init -p https://github.com/eclipse-velocitas/devenv-runtimes.git@v3.0.0

Use Cases:

'velocitas init -p devenv-runtimes@v3.0.0'

  • if devenv-runtimes:v3.0.0 is already downloaded: don't download again
  • if devenv-runtimes:v3.0.0 is not part of .velocitas.json: add it
  • if no component from devenv-runtimes is part of .velocitas.json: add all components
  • if devenv-runtimes is installed with an older version (e.g. v2.1.0): update version in .velocitas.json and download / install the new version

'velocitas init -p devenv-runtimes'

  • if devenv-runtimes is not part of .velocitas.json: add it with the latest version (currently v3.0.0)
  • if devenv-runtimes is part of .velocitas.json: install devenv-runtimes with specified version

'velocitas init'

  • normal behavior, download / install all packages from .velocitas.json
  • if no components exist in .velocitas.json then add all components from all specified packages during #write

Edge Cases:

  • when checking if components need to be added to .velocitas.json we only check if "any" component was already added there, if any component from a package is already part of .velocitas.json we don't add any components. Meaning, if a new component is added when updating to a new version it is not added
  • validateUsedComponents() - which checks if all components are valid - is only executed during "velocitas init" - We can't verify a complete list of components against a partial list of installed packages. validate should find invalid components inside .velocitas.json however we can only validate all components against all installed components (because we can't read the manifest of non-installed packages) however, if we don't start with a blank manifest installing package wise would always end in an error:

e.g.:
packageA -> CompA
packageB -> CompB
packageC -> CompC

init -p packageB
=> Error: Component not found CompA (and CompC)
init -p packageA
=> Error: Component not found CompC
init -p packageC
=> OK

Did not test:
Partial install of packages paired with other commands e.g.:

  1. velocitas init devenv-runtimes
  2. velocitas sync

@wba2hi wba2hi changed the title Add Package Parameter Add Package Parameter to Init Apr 25, 2024
@wba2hi
Copy link
Contributor Author

wba2hi commented Apr 25, 2024

🤷
grafik

@wba2hi wba2hi closed this Apr 25, 2024
@wba2hi wba2hi reopened this Apr 25, 2024
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
.vscode/launch.json Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/modules/project-config.ts Outdated Show resolved Hide resolved
src/modules/project-config.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
It is now possible to initialize a standard package using
`velocitas init -p devenv-runtimes`. This command will depending on if the
devenv-runtimes package is defined in .velocitas.json use the version specified
in .velocitas.json or use the latest version if not specified in .velocitas.json.

Using a custom version:
`velocitas init -p devenv-runtimes@v3.0.0`.

Using a custom package:
`velocitas init -p https://github.com/SoftwareDefinedVehicle/devenv-runtimes.git@v3.0.0`

If initializing a package which is not part of .velocitas.json it will
automatically be added to it. If a package specifies components but no
component is referenced in .velocitas.json, all components will be added
automatically during initialization.
Changed the @ version annotation of repos to a separate parameter.
This is necessary due to some clashes which we have when providing
a repo using ssh git urls. ssh git repo urls may contain look like
the folllwing: {user}:{password}@github.com/eclipse-velocitas/repo.git
However this paired with the previous version annotation
{repo_url}@v1.2.3 and the fact that both credentials and version
can optionally be provided makes reliably parsing the version out
of the url pretty hard.

If no specifier parameter is used, it will always retrieve the
latest version.
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/modules/project-config.ts Show resolved Hide resolved
src/modules/project-config.ts Outdated Show resolved Hide resolved
src/modules/project-config.ts Outdated Show resolved Hide resolved
src/modules/project-config.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
src/commands/init/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dennismeister93 dennismeister93 left a comment

Choose a reason for hiding this comment

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

lgtm

@dennismeister93 dennismeister93 merged commit 1e19b14 into eclipse-velocitas:main Apr 29, 2024
7 checks passed
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.

[Feature]: Support Installation/Initialization of single packages
2 participants