Skip to content

Commit

Permalink
fix: add postinstall script and ts file extension
Browse files Browse the repository at this point in the history
Fixes #31
  • Loading branch information
NagariaHussain committed Jan 25, 2024
1 parent 25daf93 commit 51b3db8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doppio/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
from .spa_generator import SPAGenerator
from frappe.commands import get_site, pass_context
from .utils import add_build_command_to_package_json, add_routing_rule_to_hooks
from .utils import add_commands_to_root_package_json, add_routing_rule_to_hooks
from .desk_page import setup_desk_page


Expand Down Expand Up @@ -61,7 +61,7 @@ def add_frappe_ui_starter(name, app):
)
subprocess.run(["yarn"], cwd=Path("../apps", app, name))

add_build_command_to_package_json(app, name)
add_commands_to_root_package_json(app, name)
add_routing_rule_to_hooks(app, name)


Expand Down
8 changes: 5 additions & 3 deletions doppio/commands/spa_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .boilerplates import *
from .utils import (
create_file,
add_build_command_to_package_json,
add_commands_to_root_package_json,
add_routing_rule_to_hooks,
)

Expand Down Expand Up @@ -45,7 +45,7 @@ def generate_spa(self):
self.create_react_files()

# Common to all frameworks
add_build_command_to_package_json(self.app, self.spa_name)
add_commands_to_root_package_json(self.app, self.spa_name)
self.create_www_directory()
self.add_csrf_to_html()

Expand Down Expand Up @@ -172,7 +172,9 @@ def link_controller_files(self):

def setup_proxy_options(self):
# Setup proxy options file
proxy_options_file: Path = self.spa_path / "proxyOptions.js"
proxy_options_file: Path = self.spa_path / (
"proxyOptions.ts" if self.use_typescript else "proxyOptions.js"
)
create_file(proxy_options_file, PROXY_OPTIONS_BOILERPLATE)

def setup_vue_vite_config(self):
Expand Down
3 changes: 2 additions & 1 deletion doppio/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_file(path: Path, content: str = None):
f.write(content)


def add_build_command_to_package_json(app, spa_name):
def add_commands_to_root_package_json(app, spa_name):
app_path = Path("../apps") / app
spa_path: Path = app_path / spa_name
package_json_path: Path = spa_path / "package.json"
Expand Down Expand Up @@ -49,6 +49,7 @@ def add_build_command_to_package_json(app, spa_name):
with app_package_json_path.open("r") as f:
data = json.load(f)

data["scripts"]["postinstall"] = f"cd {spa_name} && yarn install"
data["scripts"]["dev"] = f"cd {spa_name} && yarn dev"
data["scripts"]["build"] = f"cd {spa_name} && yarn build"

Expand Down

0 comments on commit 51b3db8

Please sign in to comment.