Skip to content

Commit

Permalink
fix: add fixes from 2.X
Browse files Browse the repository at this point in the history
  • Loading branch information
girardinsamuel committed Jan 8, 2021
2 parents 911638e + 1181101 commit 3012bc2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
venv
venv2
.python-version
.vscode
.idea/
build/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ HTTP_MIDDLEWARE = [
Then install the package to get the `config/inertia.py` in your project:

```bash
python craft inertia:install
python craft install:inertia
```

**Scaffold a base Vue app and a template (optional)**
Expand Down
2 changes: 1 addition & 1 deletion config/inertia.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
| default: app
"""

ROOT_VIEW = "spa_view"
ROOT_VIEW = "app"

"""
|--------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ init: ## Install package dependencies
pip install .
# install dev dependencies (see setup.py)
pip install masonite-inertia[test,dev]
# force correct version of cleo for tests for now
pip install cleo==0.8.1

test: ## Run package tests
python -m pytest tests
ci: ## [CI] Run package tests and lint
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
version="3.0.0a1",
packages=[
"masonite.inertia",
"masonite.inertia.config",
"masonite.inertia.providers",
"masonite.inertia.middleware",
"masonite.inertia.commands",
Expand Down
25 changes: 20 additions & 5 deletions src/masonite/inertia/commands/InstallCommand.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
"""A InstallCommand Command."""
from cleo import Command
import os
from masonite.packages import create_or_append_config
import shutil


package_directory = os.path.dirname(os.path.realpath(__file__))
package_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))


def create_if_not_exists(location, name=False):
if name:
file_name = name
else:
file_name = os.path.basename(location)

# import it into the config directory
config_directory = os.path.join(os.getcwd(), "config")

# if file does not exist
if not os.path.isfile(config_directory + "/" + file_name):
shutil.copyfile(location, config_directory + "/" + file_name)
print("\033[92mConfiguration File Created!\033[0m")
else:
print("\033[93mConfiguration File Already Exists!\033[93m")


class InstallCommand(Command):
Expand All @@ -15,6 +32,4 @@ class InstallCommand(Command):
"""

def handle(self):
create_or_append_config(
os.path.join(package_directory, "../snippets/config/inertia.py")
)
create_if_not_exists(os.path.join(package_root, "config/inertia.py"))
17 changes: 17 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from masonite.testing import TestCase
from cleo import Application
from cleo import CommandTester
from src.masonite.inertia.commands.InstallCommand import InstallCommand


class TestCommands(TestCase):
def setUp(self):
super().setUp()
self.application = Application()
self.application.add(InstallCommand())
cmd = self.application.find("install:inertia")
# self.install_cmd = CommandTester(InstallCommand())
self.install_cmd = CommandTester(cmd)

def test_install_package(self):
self.install_cmd.execute()

0 comments on commit 3012bc2

Please sign in to comment.