forge-work


Nameforge-work JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://www.forgepackages.com/
SummaryWork library for Forge
upload_time2023-01-20 02:42:50
maintainer
docs_urlNone
authorDave Gaeddert
requires_python>=3.8,<4.0
licenseMIT
keywords django saas forge framework
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # forge-work

A single command to run everything you need for local Django development.

![Forge work command example](https://user-images.githubusercontent.com/649496/176533533-cfd44dc5-afe5-42af-8b5d-33a9fa23f8d9.gif)

The following processes will run simultaneously (some will only run if they are detected as available):

- [`manage.py runserver` (and migrations)](#runserver)
- [`forge-db start --logs`](#forge-db)
- [`forge-tailwind compile --watch`](#forge-tailwind)
- [`npm run watch`](#package-json)
- [`stripe listen --forward-to`](#stripe)
- [`ngrok http --subdomain`](#ngrok)
- [`celery worker`](#celery)

It also comes with [debugging](#debugging) tools to make local debugging easier with VS Code.

## Installation

### Django + Forge Quickstart

If you use the [Forge Quickstart](https://www.forgepackages.com/docs/forge/quickstart/),
everything you need will be ready and available as `forge work`.

### Install for existing Django projects

First, install `forge-work` from [PyPI](https://pypi.org/project/forge-work/):

```sh
pip install forge-work
```

Now instead of using the basic `manage.py runserver` (and a bunch of commands before and during that process), you can simply do:

```sh
forge work
```

## Development processes

### Runserver

The key process here is still `manage.py runserver`.
But, before that runs, it will also wait for the database to be available and run `manage.py migrate`.

### forge-db

If [`forge-db`](https://github.com/forgepackages/forge-db) is installed, it will automatically start and show the logs of the running database container.

### forge-tailwind

If [`forge-tailwind`](https://github.com/forgepackages/forge-tailwind) is installed, it will automatically run the Tailwind `compile --watch` process.

### package.json

If a `package.json` file is found and contains a `watch` script,
it will automatically run.
This is an easy place to run your own custom JavaScript watch process.

### Stripe

If a `STRIPE_WEBHOOK_PATH` env variable is set then this will add a `STRIPE_WEBHOOK_SECRET` to `.env` (using `stripe listen --print-secret`) and it will then run `stripe listen --forward-to <runserver:port/stripe-webhook-path>`.

### Ngrok

If an `NGROK_SUBDOMAIN` env variable is set then this will run `ngrok http <runserver_port> --subdomain <subdomain>`.
Note that [ngrok](https://ngrok.com/download) will need to be installed on your system already (however you prefer to do that).

### Celery

If a `CELERY_APP` env variable is set, then an autoreloading celery worker will be started automatically.

## Debugging

[View on YouTube →](https://www.youtube.com/watch?v=pG0KaJSVyBw)

Since `forge work` runs multiple processes at once, the regular [pdb](https://docs.python.org/3/library/pdb.html) debuggers can be hard to use.
Instead, we include [microsoft/debugpy](https://github.com/microsoft/debugpy) and an `attach` function to make it even easier to use VS Code's debugger.

First, import and run the `debug.attach()` function:

```python
class HomeView(TemplateView):
    template_name = "home.html"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        # Make sure the debugger is attached (will need to be if runserver reloads)
        from forgework import debug; debug.attach()

        # Add a breakpoint (or use the gutter in VSCode to add one)
        breakpoint()

        return context
```

When you load the page, you'll see "Waiting for debugger to attach...".

Add a new VS Code debug configuration (using localhost and port 5768) by saving this to `.vscode/launch.json` or using the GUI:

```json
// .vscode/launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Forge: Attach to Django",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ],
            "justMyCode": true,
            "django": true
        }
    ]
}
```

Then in the "Run and Debug" tab, you can click the green arrow next to "Forge: Attach to Django" to start the debugger.

In your terminal is should tell you it was attached, and when you hit a breakpoint you'll see the debugger information in VS Code.
If Django's runserver reloads, you'll be prompted to reattach by clicking the green arrow again.

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.forgepackages.com/",
    "name": "forge-work",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "django,saas,forge,framework",
    "author": "Dave Gaeddert",
    "author_email": "dave.gaeddert@dropseed.dev",
    "download_url": "https://files.pythonhosted.org/packages/34/e2/b3083e4dbf25a1d5a8e66bdb84aca588609c8d944e9a349b11cdc3dc5808/forge_work-1.0.0.tar.gz",
    "platform": null,
    "description": "# forge-work\n\nA single command to run everything you need for local Django development.\n\n![Forge work command example](https://user-images.githubusercontent.com/649496/176533533-cfd44dc5-afe5-42af-8b5d-33a9fa23f8d9.gif)\n\nThe following processes will run simultaneously (some will only run if they are detected as available):\n\n- [`manage.py runserver` (and migrations)](#runserver)\n- [`forge-db start --logs`](#forge-db)\n- [`forge-tailwind compile --watch`](#forge-tailwind)\n- [`npm run watch`](#package-json)\n- [`stripe listen --forward-to`](#stripe)\n- [`ngrok http --subdomain`](#ngrok)\n- [`celery worker`](#celery)\n\nIt also comes with [debugging](#debugging) tools to make local debugging easier with VS Code.\n\n## Installation\n\n### Django + Forge Quickstart\n\nIf you use the [Forge Quickstart](https://www.forgepackages.com/docs/forge/quickstart/),\neverything you need will be ready and available as `forge work`.\n\n### Install for existing Django projects\n\nFirst, install `forge-work` from [PyPI](https://pypi.org/project/forge-work/):\n\n```sh\npip install forge-work\n```\n\nNow instead of using the basic `manage.py runserver` (and a bunch of commands before and during that process), you can simply do:\n\n```sh\nforge work\n```\n\n## Development processes\n\n### Runserver\n\nThe key process here is still `manage.py runserver`.\nBut, before that runs, it will also wait for the database to be available and run `manage.py migrate`.\n\n### forge-db\n\nIf [`forge-db`](https://github.com/forgepackages/forge-db) is installed, it will automatically start and show the logs of the running database container.\n\n### forge-tailwind\n\nIf [`forge-tailwind`](https://github.com/forgepackages/forge-tailwind) is installed, it will automatically run the Tailwind `compile --watch` process.\n\n### package.json\n\nIf a `package.json` file is found and contains a `watch` script,\nit will automatically run.\nThis is an easy place to run your own custom JavaScript watch process.\n\n### Stripe\n\nIf a `STRIPE_WEBHOOK_PATH` env variable is set then this will add a `STRIPE_WEBHOOK_SECRET` to `.env` (using `stripe listen --print-secret`) and it will then run `stripe listen --forward-to <runserver:port/stripe-webhook-path>`.\n\n### Ngrok\n\nIf an `NGROK_SUBDOMAIN` env variable is set then this will run `ngrok http <runserver_port> --subdomain <subdomain>`.\nNote that [ngrok](https://ngrok.com/download) will need to be installed on your system already (however you prefer to do that).\n\n### Celery\n\nIf a `CELERY_APP` env variable is set, then an autoreloading celery worker will be started automatically.\n\n## Debugging\n\n[View on YouTube \u2192](https://www.youtube.com/watch?v=pG0KaJSVyBw)\n\nSince `forge work` runs multiple processes at once, the regular [pdb](https://docs.python.org/3/library/pdb.html) debuggers can be hard to use.\nInstead, we include [microsoft/debugpy](https://github.com/microsoft/debugpy) and an `attach` function to make it even easier to use VS Code's debugger.\n\nFirst, import and run the `debug.attach()` function:\n\n```python\nclass HomeView(TemplateView):\n    template_name = \"home.html\"\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n\n        # Make sure the debugger is attached (will need to be if runserver reloads)\n        from forgework import debug; debug.attach()\n\n        # Add a breakpoint (or use the gutter in VSCode to add one)\n        breakpoint()\n\n        return context\n```\n\nWhen you load the page, you'll see \"Waiting for debugger to attach...\".\n\nAdd a new VS Code debug configuration (using localhost and port 5768) by saving this to `.vscode/launch.json` or using the GUI:\n\n```json\n// .vscode/launch.json\n{\n    // Use IntelliSense to learn about possible attributes.\n    // Hover to view descriptions of existing attributes.\n    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"name\": \"Forge: Attach to Django\",\n            \"type\": \"python\",\n            \"request\": \"attach\",\n            \"connect\": {\n                \"host\": \"localhost\",\n                \"port\": 5678\n            },\n            \"pathMappings\": [\n                {\n                    \"localRoot\": \"${workspaceFolder}\",\n                    \"remoteRoot\": \".\"\n                }\n            ],\n            \"justMyCode\": true,\n            \"django\": true\n        }\n    ]\n}\n```\n\nThen in the \"Run and Debug\" tab, you can click the green arrow next to \"Forge: Attach to Django\" to start the debugger.\n\nIn your terminal is should tell you it was attached, and when you hit a breakpoint you'll see the debugger information in VS Code.\nIf Django's runserver reloads, you'll be prompted to reattach by clicking the green arrow again.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Work library for Forge",
    "version": "1.0.0",
    "split_keywords": [
        "django",
        "saas",
        "forge",
        "framework"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6218d5ffd93c6508cff3397e0fc55d91a23747474699419ef63891dc27a2359a",
                "md5": "3c7648f98d9052b007ba0e1932ee5402",
                "sha256": "332079ef548ab3bcd6cf987c0fb01e169cc68032582657d1f5f57975173bfdce"
            },
            "downloads": -1,
            "filename": "forge_work-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3c7648f98d9052b007ba0e1932ee5402",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 6527,
            "upload_time": "2023-01-20T02:42:48",
            "upload_time_iso_8601": "2023-01-20T02:42:48.920945Z",
            "url": "https://files.pythonhosted.org/packages/62/18/d5ffd93c6508cff3397e0fc55d91a23747474699419ef63891dc27a2359a/forge_work-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "34e2b3083e4dbf25a1d5a8e66bdb84aca588609c8d944e9a349b11cdc3dc5808",
                "md5": "105e2f3c3a7ec58c42b102419c00cdd2",
                "sha256": "32308a40843067e21d66ebcb92a3cb909ee667c771f2b4a8c0fae2be43602bda"
            },
            "downloads": -1,
            "filename": "forge_work-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "105e2f3c3a7ec58c42b102419c00cdd2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 6314,
            "upload_time": "2023-01-20T02:42:50",
            "upload_time_iso_8601": "2023-01-20T02:42:50.653962Z",
            "url": "https://files.pythonhosted.org/packages/34/e2/b3083e4dbf25a1d5a8e66bdb84aca588609c8d944e9a349b11cdc3dc5808/forge_work-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-20 02:42:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "forge-work"
}
        
Elapsed time: 0.03184s