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

feat: Add upgrade support #54

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
This extension includes a sample Evidence project, along with a `meltano.yml` project file, allowing you to test Evidence with Meltano.

```shell
# install Meltano
pipx install meltano
# install the Meltano project locally
meltano install
# run evidence in dev mode
Expand All @@ -18,6 +20,17 @@ meltano invoke evidence dev
meltano invoke evidence build
```

## Upgrading Evidence Versions

From time to time you may need to upgrade the version of an evidence project.

```shell
# install latest version of evidence
meltano invoke evidence upgrade
# run arbitrary npm commands for evidence
meltano invoke evidence npm {args}
```

## Installing this extension for local development

1. Install the project dependencies with `poetry install`:
Expand Down
27 changes: 26 additions & 1 deletion evidence_ext/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,29 @@ def dev(self) -> None:
"""Run 'npm run dev' in the Evidence home dir."""
with self.config.suppress_config_file():
self._npm.run_and_log(*["--prefix", self.evidence_home, "install"])
self._npm.run_and_log(*["--prefix", self.evidence_home, "run", "dev"])
self._npm.run_and_log(
*[
"--prefix",
self.evidence_home,
"run",
"dev",
"--",
"--host",
"0.0.0.0", # noqa: S104
],
)

def upgrade(self) -> None:
"""Run 'npm' inside Evidence home with install (upgrade) args."""
try:
command_args = [
"--prefix",
self.evidence_home,
"install",
"@evidence-dev/evidence@latest",
"@evidence-dev/core-components@latest",
]
self._npm.run_and_log(*command_args)
except subprocess.CalledProcessError as err:
log_subprocess_error("npm", err, "npm invocation failed")
sys.exit(err.returncode)
6 changes: 6 additions & 0 deletions evidence_ext/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,11 @@ def dev(ctx: typer.Context) -> None: # noqa: ARG001
ext.dev()


@app.command()
def upgrade(ctx: typer.Context) -> None: # noqa: ARG001
"""Run npm install (upgrade) inside the Evidence project directory."""
ext.upgrade()


if __name__ == "__main__":
app()
3 changes: 3 additions & 0 deletions meltano.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,8 @@ plugins:
build-strict:
args: build --strict
executable: evidence_extension
upgrade:
args: upgrade
executable: evidence_extension
config:
home_dir: $MELTANO_PROJECT_ROOT/sample/
6 changes: 4 additions & 2 deletions sample/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"type": "module",
"dependencies": {
"@evidence-dev/components": "^2.5.1",
"@evidence-dev/core-components": "^1.2.1",
"@evidence-dev/evidence": "^20.0.1",
"@evidence-dev/preprocess": "^3.1.1"
},
Expand Down