Giter Site home page Giter Site logo

viur-cli's Introduction

A hexagonal logo of the viur-cli

viur-cli

Badge showing current PyPI version Badge displaying the license
Command-line interface for ViUR framework project maintenance.

What does it do?

viur-cli allows to control, maintain, develop and deploy a ViUR project from one central location by using the viur command.

Installation

To use viur-cli in your ViUR projects, install the PyPI package viur-cli.

$ pipenv install --dev viur-cli

Usage

$ viur -h

will show all the commands that are currently supported by viur-cli

$ viur --version 

will show your current viur-cli version

$ viur create myapp

this will create a new project folder, clone the base project and then call viur init to prepare a project.json you can use this to get started quickly with a new viur project from scratch.

$ viur run [profile]

run the appserver and start your app locally. You may specify a target profile.

$ viur check [--dev]

Runs a security check for the python environment and for each npm project registered under builds.

$ viur package {install|update} {vi|scriptor|admin|all} 

handles ViUR ecosystem package operations

Commands:

  • install installs a ViUR package (in a specific version)
  • update updates a ViUR package to the newest version

Arguments:

  • profile profile to install to
  • version version to install
$ viur build {app|clean|release} [option]

Builds ViUR Project or specific apps Commands:

  • app Build a specific application
  • clean Clean up Build Artifacts
  • release Build all relevant applications to deploy the project
$ viur cloud deploy {app|index|cloudfunction} {profile} {--ext|--yes|--name}

This Function deploys the Google Cloud application and / or different .yaml files Scripts:

  • app Deploy application to the Google Appengine
    • index Deploy index.yaml to Google Appenginge
    • cloudfunction Deploy Cloudfunction to Google Appengine Commands:
    • profile The project.json profile you want to Work from
$ viur cloud init {service} {profile} 

This Function makes the init deployment for a ViUR project. This Function needs to be called so that the development server works locally.

$ viur cloud {enable|disable} backup

Enable/ Disable the Backup buckets you need to Backup a cloud project in the Google Cloud Console

$ viur cloud setup {gcloud|gcroles} 

Scripts:

  • gcloud This Function setups your project to work on the gcloud plattform
    • gcroles This function lets you set up Roles for your google appengine Workspace
$ viur cloud get {gcroles} 

Scripts:

  • gcroles This function lets you get Roles for your google appengine Workspace in a readable .json Format
$ viur package {update|install} {vi|admin|scriptor|all} [profile] [version]

Performs operations on packages

Scripts:

  • update Updates an installed package
  • install Installs a declared package

Options:

  • vi
  • admin
  • scriptor
  • all
$ viur env

Show information about your current environment.

$ viur project list

Pretty prints your project.json file on the console.

$ viur update {requirements}

with this you can update your project specific requirements.txt file automatically

The project.json

The project.json is your core project configuration file for every viur related operation. It contains the default viur project profile and it can be expanded with several individual project profiles.

Example project.json

{
    /* 
      The format Key, Value pair defines the project json format, the viur-cli uses
    */
    "format": "2.0.0",
    /*
      The first level contains of your profiles
      "default" is a profile, which is inherited by "develop" and "live" and can be customized for particular versions 
      and/or GAE projects. Therefore, every profile can contain all keys from the "default" profile.*/
    "default": {
        /*
          The builds level declares steps for the `viur build` command.
          It can contain viur components and other components that need to be build before project deployment
        */
        "builds": { 
            "admin": {
                "command": "viur install admin",
                "kind": "exec",
                "version": "4.0.8"
            },
            "npm": {
                "command": "build",
                "kind": "npm",
                "source": ""
            }
        },
        "gcloud": {
            "functions": { //Declarations for a cloud function
                "testfunction1": {
                    "entry-point": "main",
                    "env-vars-file": "env.yaml",
                    "memory": "512MB",
                    "runtime": "python311",
                    "source": "deploy/cloudfunction/function1",
                    "trigger": "http"
                }
            },
            "max-instances": "1",
            "region": "europe-west3"
        },
        "core": "3.5.1",  // viur-core version of your project
        "distribution_folder": "./deploy", // Deploy folder uploaded to GAE
        "sources_folder": "./sources",
        "version": "live-$(year)-$(month)-$(day)", // Version string; Variables can be used here.
        "application_name": "my-live-app-viur3" // Name of the GAE project *4
    },
    "develop": {  
        "application_name": "my-dev-app-viur3", 
        "version": "dev-$(user)"  
    }
}

Viur scripting interface

There is a new core component that enables us to pull and push python scripts from/to a deployed application and run these in a sandbox or even locally. The GUI version is called scriptor and can be accessed via a webinterface, but viur-cli also has a cli for this:

$ viur script {configure|pull|push|run|setup}

Manage your ViUR Scriptor Scripts via the CLI Commands:

  • configure Manage configuration settings.
  • pull Pull contents from server to working_dir.
  • push Push contents of working_dir to server.
  • run Locally run a script located in the working_dir.
  • setup Setup user session with a given username and...

Packaged tools

In order to use the packaged tools, you can run:

$ viur tool {2to3|pyodide|ssl-fix}

Scripts:

  • 2to3 viur porting script
  • pyodide run the get_pyodide command
  • ssl-fix ssl fix for MacOS

for example the 2to3 script helps porting viur2 project to viur3, it can be used to automatically rename some things that are deprecated in viur3 as well, so you can use it whenever a new core version is released for viur3 projects as well:

$ viur tool 2to3 -d .

will dry-run the script in the current directory and not make any changes, only suggestions. If you want to make the changes, leave out the -d argument and if you are a daring go-getter and like to live dangerously, replace the -d with -x, which will write the suggested changes without making a backup of the changed files.

Development

If you want to hack viur-cli, clone this repository next to the folder of your ViUR project.

$ git clone [email protected]:viur-framework/viur-cli.git
$ ls -1
viur-cli
your-project

Then, add it to your project as an editable dependency using

$ cd your-project
$ pipenv install --dev --editable ../viur-cli

Dependencies

viur-cli depends on

License

Copyright © 2024 by Mausbrand Informationssysteme GmbH.
Mausbrand and ViUR are registered trademarks of Mausbrand Informationssysteme GmbH.

This project is free software under the MIT license.
Please see the LICENSE file for details.

viur-cli's People

Contributors

akelch avatar arnegudermann avatar dependabot[bot] avatar grashalmbeisser avatar phorward avatar sveneberth avatar xnopasaranx avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

viur-cli's Issues

Delete Init function

We want to change the workflow, so we don not need to create a new project json from scratch.

Support python 3.10

The installation of viur-cli fails with python 3.10.

Error
$ python -m pip install viur-cli
Defaulting to user installation because normal site-packages is not writeable
Collecting viur-cli
  Using cached viur_cli-0.6.1-py3-none-any.whl (16 kB)
Requirement already satisfied: watchgod==0.7 in /home/sven/.local/lib/python3.10/site-packages (from viur-cli) (0.7)
Requirement already satisfied: pipfile-requirements==0.3.0 in /home/sven/.local/lib/python3.10/site-packages (from viur-cli) (0.3.0)
Requirement already satisfied: click==8.0.3 in /home/sven/.local/lib/python3.10/site-packages (from viur-cli) (8.0.3)
  Using cached viur_cli-0.6-py3-none-any.whl (16 kB)
  Using cached viur_cli-0.5.5-py3-none-any.whl (14 kB)
  Using cached viur_cli-0.5.1-py3-none-any.whl (12 kB)
ERROR: Cannot install viur-cli==0.5.1, viur-cli==0.5.5, viur-cli==0.6 and viur-cli==0.6.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    viur-cli 0.6.1 depends on python-minifier==2.4.2
    viur-cli 0.6 depends on python-minifier==2.4.2
    viur-cli 0.5.5 depends on python-minifier==2.4.2
    viur-cli 0.5.1 depends on python-minifier==2.4.2

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

The support for python 3.10 in the dependency python-minfier was added in 2.5.0. I think an upgrade should solve this issue?

My machine runs with:

$ uname -a
Linux se-pc 5.10.89-1-MANJARO #1 SMP PREEMPT Wed Dec 29 18:09:17 UTC 2021 x86_64 GNU/Linux
$ python -V
Python 3.10.1
$ python -m pip -V
pip 21.3.1 from /usr/lib/python3.10/site-packages/pip (python 3.10)

Workaround

Install viur-cli with the --no-deps flag:

python -m pip install viur-cli --no-deps

and the dependencies manually.

`viur build` as general build command

Instead of creating separate commands viur flare and viur vue for building apps created with a specific solution, a general viur build command should be provided.

Example calls

  • viur build - builds all apps in debug mode
  • viur build myapp - build myapp in debug mode
  • viur build --release - build all apps in release mode
  • viur build myapp --release - build myapp in release mode
  • viur build myapp --watch - build myapp and run in watch mode

project.json

This is how the configuration in project.json might look like:

{
    "default": {
        "distribution_folder": "./deploy",
        "builds": {     // <-- previously was "flare" or "vue"
            "myapp": {
                "source": "./sources/myapp",
                "target": "./deploy/myapp"
            },
            "vi": {
                "source": "./sources/vi/vi",
                "target": "./deploy/vi"
            }
        },
        "sources_folder": "./sources"
    },
    "develop": {
        "application_name": "myproject",
        "version": "dev"
    }
}

viur-build.json

Every app now contains a viur-build.json that is located in the source-folder specified in project.json.

Simplest configuration:

{
    "kind": "flare"  // <-- or "vue", or "flutter"...
}

Specifying the "kind" selects a default-setting in viur-cli for building this app with the specified target-folders and modes. Here, the use of variables might be useful, to construct user-defined built commands. The variables should be a union of the project-specific global config and the app-specific config.

The default-settings can be put into a dict like this:

# default-settings and builders, defined in viur-cli somewhere...
app_builders = {
    "flare": {
        # on this level, either lists for commands or just strings for one command should be possible
        "preprocess": ["get-pyodide.py -t ${distribution_folder}/pyodide"],
        "release": "${flare-py} -s ${source} -t ${target} -ncz",
        "debug": "${flare-py} -s ${source} -t ${target}",
        "watch": "${flare-py} -s ${source} -t ${target} -w",
        "postprocess": []
    },
    "vue": {
          # ...
    },
    "flutter": {
          # ...
    }
}

Configuration can override default-settings, e.g. like so

{
    "kind": "flare",
    "postprocess":  ["${DEFAULT}, "${source}/update-version.py > ${target}/src/__version__.py",
    "debug": "${flare-py} -s ${source} -t ${target} -c"   // <-- this flare app should always be compiled in debug mode
     }
}

profile.json: seperate builds and packages

Seperate builds and packages in project.json so the package module does not interfere with custom builds.

Example:

{
    "default": {
        "application_name": "",
        "builds": {
            "app": {
                "command": "build",
                "kind": "npm",
                "source": "app"
            },
            "pyodide": {
                "clean": "rm -rf ./deploy/pyodide",
                "command": "python sources/viur-vi/vi/flare/tools/get-pyodide.py -t deploy/pyodide/",
                "kind": "exec"
            },
            "vi": {
                "clean": "rm -rf ./deploy/vi",
                "command": "python sources/viur-vi/vi/flare/tools/flare.py -s sources/viur-vi/vi -t deploy/legacy-vi",
                "kind": "package"
            }
        },
        "packages": {
          "admin": "4.1.5",
          "scriptor": "2.1.2",
          "core": "3.6.0b3"
        },
        "distribution_folder": "./deploy",
        "sources_folder": "./sources",
        "version": "$(year)-$(month)-$(day)-$(user)",
        "vue": {}
    },
    "format": "2.0.0",
    "live": {
        "application_name": ""
    }
}

Rename `viur-cli` command to just `viur`?

It should be considered to rename the command line tool viur-cli to just viur, as this makes the entire tool more integrative with ViUR itself (to make it a part of ViUR).

Add more explainations to the questions.

After upgrading ViUR-cli to 1.0.3 and running it for the first time, I was very confused and had no idea how to answer these questions:

$ viur run develop
viur-cli tries to find npm applications
Do you want to add / to your apps? [y/N]: y
name []: sources
command [build]: 
Do you want to add /viur-scriptor/ to your apps? [y/N]: y
name [scriptor]: 
command [build]: 
Do you want to add /viur-scriptor/src/usepython/ to your apps? [y/N]: y
name [scriptor_usepython]: 
command [build]: 
  • What is the /?
  • What name does it expect?
  • Do I need usepython? Isn't it part of the scriptor?

Provide viur-cli import tool

viur-cli import command and sub-commands, providing general export tooling for ViUR databases, kinds or specific entities, with the following features:

  • Import from Google Datastore Backup
  • Import from JSON
  • Import from CSV (see #3, csvimport.py)

The features from csvimport.py are necessary, e.g. looking up for keys or codes, replacing values etc. (logics-expressions).

`viur install` should install versions from `project.json`

It is a little bit useless that project.json contains version numbers of admin and scriptor, but these version don't have any further usage.

Therefore, it would be nice to have a way to install the specific versions that are specified in project.json, also to guarantee reproducable builds for specific versions.

My recommendation would be, that calling viur install without any additional parameters checks project.json for versions of admin and scriptor, and installs the specific version. In case there is no entry for scriptor or admin, the specific tool should NOT be installed.

This step can also be part of #80, as it is required for deploying a working version of something.

Integrate tool for sorting index.yaml file

This tool can be used for sorting the deploy/index.yaml file which is present in every ViUR project:

#!/usr/bin/python
import yaml
import logging
from typing import Union


def sort_yaml_file(file_name: str, dst_file_name: Union[str, None] = None):
    if not dst_file_name:
        dst_file_name = file_name

    with open(file_name, "r") as source_file:
        data = yaml.safe_load(source_file)

        if not ("indexes" in data):
            logging.error(f"There is no indexes main in file {file_name}")
            return

        data["indexes"] = sorted(data["indexes"], key=lambda k: k["kind"] if isinstance(k, dict) and "kind" in k else k)

        with open(dst_file_name, "a+") as dst_file:
            dst_file.seek(0)
            dst_file.truncate()
            dst_file.write(
                yaml.dump(data).replace("- kind: ", "\n- kind: ")
            )
            logging.info(f"Successfully sorted the yaml file {file_name} into {dst_file_name}")


if __name__ == "__main__":
    logging.getLogger().setLevel(logging.INFO)
    try:
        sort_yaml_file("index.yaml")
    except FileNotFoundError:
        logging.error("index.yaml not present!")

It should be integrated into viur-cli, or probably app_server.

Provide viur-cli export tool

viur-cli export command and sub-commands, providing general export tooling for ViUR databases, kinds or specific entities, with the following features:

  • Export as Google Datastore Backup
  • Export to JSON
  • Export to CSV

For the tools especially for JSON and CSV export should, it should be considered to use the MEX language integrated into a Mausbrand customer project as domain specific language to describe tabular output formats with conditional output and other tools.

Cannot use viur-cli 1.1.1 in a Python 3.12 environment

When I try to update a pipenv with viur-cli==1.1.1 to Python 3.12, I'm getting dependency mismatch:

CRITICAL:pipenv.patched.pip._internal.resolution.resolvelib.factory:Ignored the following versions that require a different python version: 1.0.0 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.8; 1.1.0 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.8; 2.0.0 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.8; 2.1.0 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.8; 2.1.1 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.8; 2.1.2 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.8; 2.2.1 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.9; 2.3.0 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.9; 2.3.1 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.9; 2.3.2 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.9; 2.4.0 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.10; 2.4.1 Requires-Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <3.10; 2.4.2 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.10; 2.5.0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.11; 2.6.0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.11; 2.7.0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.12; 2.8.0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.12; 2.8.1 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.12; 2.9.0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.12
CRITICAL:pipenv.patched.pip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement python-minifier==2.9.0 (from viur-cli) (from versions: none)
[ResolutionFailure]:   File "/usr/lib/python3.11/site-packages/pipenv/resolver.py", line 645, in _main
[ResolutionFailure]:       resolve_packages(
[ResolutionFailure]:   File "/usr/lib/python3.11/site-packages/pipenv/resolver.py", line 612, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:       ^^^^^^^^
[ResolutionFailure]:   File "/usr/lib/python3.11/site-packages/pipenv/resolver.py", line 592, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:       ^^^^^^^^^^^^^
[ResolutionFailure]:   File "/usr/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 908, in resolve_deps
[ResolutionFailure]:       results, hashes, internal_resolver = actually_resolve_deps(
[ResolutionFailure]:       ^^^^^^^^^^^^^^^^^^^^^^
[ResolutionFailure]:   File "/usr/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 681, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/usr/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 442, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv run pip install <requirement_name> to bypass this mechanism, then run $ pipenv graph to inspect the versions actually installed in the virtualenv.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for python-minifier==2.9.0

Traceback (most recent call last):
  File "/usr/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/vendor/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/cli/command.py", line 546, in update
    do_update(
  File "/usr/lib/python3.11/site-packages/pipenv/routines/update.py", line 59, in do_update
    do_lock(
  File "/usr/lib/python3.11/site-packages/pipenv/routines/lock.py", line 65, in do_lock
    venv_resolve_deps(
  File "/usr/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 849, in venv_resolve_deps
    c = resolve(cmd, st, project=project)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 718, in resolve
    raise RuntimeError("Failed to lock Pipfile.lock!")
RuntimeError: Failed to lock Pipfile.lock!

As python-minifier was a depenceny of the already removed flare.py, this must be removed as well from the package.

Integrate tools from viur-tools into viur-cli

The Repository https://github.com/phorward/viur-tools contains further tools which could be implemented into viur-cli as well.

  • csvimport.py is a generic CSV-importing tool => What about viur-cli import command for that?
  • viur-2to3.py is a draft for porting projects from ViUR2 to ViUR3 => What about a viur-cli 2to3 command?

The other tools like updatedb.sh, copyblobs.py or copydb.py are only relevant to ViUR2 and should be ignored.

Integrate gcloud setup workflows for ViUR projects

This issue is a collection currently resolved in several scripts, which should be merged into viur-cli under a uniform interface / command, e.h. viur-cli maintain.

  • viur-cli setup all should perform the operations from viur-gcloud-setup.sh
  • #70
  • viur-cli setup index for index.yaml sorting and deployment (see #2 as well, maybe can be integrated with this)
  • viur-cli setup queue for queue.yaml deployment
  • viur-cli setup cron for cron.yaml deployment
  • viur-cli setup cicd for setting-up and update CI/CD workflows

Pushing fails for files in importable subfolder

Here is a traceback:

$ viur script push
There is no file named importer.py. Create it? [y/N]: y
Push scripts/importer.py
There is no file named exporter.py. Create it? [y/N]: y
Push scripts/exporter.py
There is no folder named importable/. Create it? [y/N]: y
Push scripts/importable
There is no file named importable/impexp.py. Create it? [y/N]: y
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/cli.py", line 220, in main
    entry = await anext(tree.list(_type, {"path": file}))
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/scriptor/viur.py", line 195, in __anext__
    return await self.__anext__()
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/scriptor/viur.py", line 178, in __anext__
    raise StopAsyncIteration
StopAsyncIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/bin/viur", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/cli.py", line 289, in push
    asyncio.new_event_loop().run_until_complete(main())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/cli.py", line 255, in main
    parent_entry = await anext(tree.list("node", {"path": parent}))
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/scriptor/viur.py", line 195, in __anext__
    return await self.__anext__()
  File "/home/user/.local/share/virtualenvs/project-viur3-s2IdUEXK/lib/python3.10/site-packages/viur_cli/scriptor/scriptor/viur.py", line 178, in __anext__
    raise StopAsyncIteration
StopAsyncIteration

bug: Run `viur cloud setup gcloud` in an empty project folder generates confusing results

Hello!

I'm currently experimenting with Google Cloud Shell and tried to run a viur cloud setup gcloud command in my home folder, with a fake project.json and no deploy folder.

$ viur cloud setup gcloud
Enter PROJECT_ID: xxx-viur3
Check if user is authorized with gcloud....
Operation "operations/acat.p2-799407658776-5713ecae-5dde-4a55-b286-26f9ab92b842" finished successfully.
Operation "operations/acf.p2-799407658776-fbf62221-ce5e-4f8b-a10b-4e2555e5b9b5" finished successfully.
Operation "operations/acat.p2-799407658776-3f617a3e-55aa-4092-97c0-23d40dba8aaf" finished successfully.
Operation "operations/acf.p2-799407658776-1bf01b22-97a1-4745-b735-d1237862a742" finished successfully.
Operation "operations/acf.p2-799407658776-6756081d-adac-4c44-a0db-973e9554a6ad" finished successfully.
Operation "operations/acf.p2-799407658776-8da2776e-f8f0-4194-94f0-86aa6d6e6acf" finished successfully.
Operation "operations/acat.p2-799407658776-e34a8bae-8f06-417c-9eb9-542858c30dce" finished successfully.
/bin/sh: line 1: cd: deploy: No such file or directory
Error executing command: Command 'cd deploy && gcloud app deploy -q --project=xxx-viur3 cron.yaml' returned non-zero exit status 1.
/bin/sh: line 1: cd: deploy: No such file or directory
Error executing command: Command 'cd deploy && gcloud app deploy -q --project=xxx-viur3 queue.yaml' returned non-zero exit status 1.
/bin/sh: line 1: cd: deploy: No such file or directory
Error executing command: Command 'cd deploy && gcloud app deploy -q --project=xxx-viur3 index.yaml' returned non-zero exit status 1.
Check if app engine default credentials are set...
INFO: All done!
You should now be able to run your project locally with
   viur run 
At the first run, it might happen that some functions are
causing error 500 because indexes are not immediately
served. Therefore, maybe wait a few minutes.
Have a nice day.

This result is confusing. Generally, the workflow should in this case be something like viur init to initialize a new, empty base-project. viur cloud setup gcloud should fail immediatelly when there is no deploy folder, with a hint that viur init should be executed first.

viur-cli ui

Add a Webinterface to manage your projects

Inconsistent formats of version numbers in `project.json`

The version numbers in project.json are always stored in different ways:

{
    "default": {
        "core": "3.1.1",  // <-- here it is without v
        "distribution_folder": "./deploy",
        "format": "1.0.0",  // <-- here it is without v
        "pyodide": "v0.19.1",   // <-- here it is with v..
        "sources_folder": "./sources",
        "vi": "v3.0.20"  // <-- here it is with v...
    }
}

Module crawler

This issue is an idea for a module crawler that could be part of viur-cli and performs the following tasks:

  • Log-in to a VIUR system with given credentials (admin-level)
  • Fetch all modules taken from adminInfo / /vi/config
  • The iterate over all modules, with a new session
    • for every module check
      • view
      • list (if possible)
      • add (if possible)*
      • edit*
      • delete (if possible)*
      • index?
  • There might also be an option to perform above steps for given users, which are automatically set from the admin (requires default function to set any user when in admin mode, to avoid providing credentials)
  • Finally, or during execution, a report shall be printed showing which modules allow to read or modify data without user or with a given user.

*) here, a given way must be followed. Maybe grab one item and try to edit it, without any values (amend feature), no data should really be changed

`viur deploy app` should accept for `-y` parameter to avoid annoying prompts

The interactive prompts are annoying and sometimes disturb development flow. I always have to answer these two stupid and annoying questions... I just want to avoid it.

Now:

$ viur deploy app live
✔ No vulnerabilities found.
Do you want to regenerate the requirements.txt located in the ./deploy? [y/N]: 
Services to deploy:

descriptor:                  [/home/neo/xxx/yyy/deploy/app.yaml]
source:                      [/home/neo/xxx/yyy/deploy]
target project:              [yyy]
target service:              [default]
target version:              [2023-11-22-neo]
target url:                  [http://2023-11-22-neo.yyy.ey.r.appspot.com]
target service account:      [[email protected]]


     (add --promote if you also want to make this service available from
     [http://yyy.ey.r.appspot.com])

Do you want to continue (Y/n)?

Wish:

$ viur deploy app live -y
✔ No vulnerabilities found.
requirements.txt successfully generated
Services to deploy:

descriptor:                  [/home/neo/xxx/yyy/deploy/app.yaml]
source:                      [/home/neo/xxx/yyy/deploy]
target project:              [yyy]
target service:              [default]
target version:              [2023-11-22-neo]
target url:                  [http://2023-11-22-neo.yyy.ey.r.appspot.com]
target service account:      [[email protected]]


     (add --promote if you also want to make this service available from
     [http://yyy.ey.r.appspot.com])

Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 12 files to Google Cloud Storage               ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...done.                                             
Deployed service [default] to [http://2023-11-22-neo.yyy.ey.r.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse --project=yyy

Note: The parameter can also be other than -y, I just want this feature.

`viur deploy app` should accept for an optional version-string extension variable

I want to deploy my app under a different version name I would like to adjust with a variable that can be set by command-line.

In project.json, I've got a configuration

    "develop": {
        "application_name": "xxx",
        "version": "$(year)-$(month)-$(day)-$(user)"
    }

now, let's assume I call viur deploy app develop --ext test, then the generated version name should be 2023-11-16-neo-test, but when I omit the --ext, it shall just be 2023-11-16-neo, as it is the case now.

`requests` is missing as dependency

I got this stacktrace after installing viur-cli in a fresh python310 env:

$ viur
Traceback (most recent call last):
  File "/home/sven/.local/bin/viur", line 5, in <module>
    from viur_cli import cli
  File "/home/sven/.local/lib/python3.10/site-packages/viur_cli/__init__.py", line 10, in <module>
    from .scriptor import script
  File "/home/sven/.local/lib/python3.10/site-packages/viur_cli/scriptor/__init__.py", line 1, in <module>
    from .cli import script
  File "/home/sven/.local/lib/python3.10/site-packages/viur_cli/scriptor/cli.py", line 3, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

I think requests is missing here?

viur-cli/setup.cfg

Lines 22 to 27 in 3393e54

install_requires =
watchgod==0.7
python-minifier==2.5.0
app_server==0.9.4
click==8.1.3
pipfile-requirements==0.3.0

`project.json` should be dumped with a trailing newline

Occasionally, when editing settings in project.json, this happens:

--- a/project.json
+++ b/project.json
@@ -34,4 +34,4 @@
         "application_name": "myapp-viur3",
         "version": "$(year)-$(month)-$(day)-$(user)"
     }
-}
\ No newline at end of file
+}

A solution for this would be to simply append an \n each time the file is being stored by viur-cli.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.