diff --git a/django_email_foundation/api.py b/django_email_foundation/api.py index b955b8d..1ecb6dc 100644 --- a/django_email_foundation/api.py +++ b/django_email_foundation/api.py @@ -13,15 +13,18 @@ class Checks: FOLDERS = ('pages', 'layouts', 'partials', 'helpers', 'assets', 'data') CHECKS = ( - ('npm_or_yarn_installed', 'The "npm" or "yarn" is not installed or is not in your $PATH'), + ('npm_or_yarn_installed', + 'The "npm" or "yarn" is not installed or is not in your $PATH'), ('required_node_packages', 'Some of the required modules are not installed in "node_modules". Please run ' '"./manage.py install_requires"'), - ('templates_source_path', 'It is necessary to define DEF_TEMPLATES_SOURCE_PATH in your settings'), + ('templates_source_path', + 'It is necessary to define DEF_TEMPLATES_SOURCE_PATH in your settings'), ('templates_dir_structure', 'The templates directory must have a valid structure. It must contain the pages,' ' layouts, partials and helpers folders. You can run ' '"./manage.py create_basic_structure" to build this structure, ' 'and to add a basic layout '), - ('templates_target_path', 'It is necessary to define DEF_TEMPLATES_TARGET_PATH in your settings'), + ('templates_target_path', + 'It is necessary to define DEF_TEMPLATES_TARGET_PATH in your settings'), ('static_target_path', 'You must to set the DEF_STATIC_TARGET_PATH setting'), ('exists_pages', 'You do not have any template in your \'pages\' folder. Please, create one before run the ' 'email builder command'), @@ -38,7 +41,8 @@ def exists_pages(self) -> bool: return True try: - walk = os.listdir(os.path.join(self.get_templates_source_path(), 'pages')) + walk = os.listdir(os.path.join( + self.get_templates_source_path(), 'pages')) except FileNotFoundError: return False @@ -153,7 +157,9 @@ def install_required_packages(self) -> bool: settings.DEF_NPM_YARN_INSTALL_COMMAND, ] + list(settings.DEF_NODE_PACKAGES_REQUIRED) - exit_code = subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH) + exit_code = subprocess.call(command, + cwd=settings.DEF_NODE_MODULES_PATH, + shell=True) if exit_code != 0: return False @@ -183,19 +189,23 @@ def run_watch(self): '--ignore_files={}'.format(','.join(settings.DEF_IGNORE_FILES)), '--preview_url={}'.format(self.preview_url), ) - subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH) + # subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH) + subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH, + shell=True) def create_basic_structure(self) -> Optional[str]: """ It creates the basic foundation for emails (or panini) structure in your source path folder. :return: If some error occurs, the method return the description. """ - source_default_templates = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'default_templates') + source_default_templates = os.path.join(os.path.dirname( + os.path.realpath(__file__)), 'default_templates') for folder in Checks.FOLDERS: source_path = '{}/{}'.format(source_default_templates, folder) - target_path = '{}/{}'.format(Checks.get_templates_source_path(), folder) + target_path = '{}/{}'.format( + Checks.get_templates_source_path(), folder) # If the target path already exists, it's not necessary to create it. if os.path.isdir(target_path): diff --git a/django_email_foundation/settings.py b/django_email_foundation/settings.py index dfb70f7..54590b2 100644 --- a/django_email_foundation/settings.py +++ b/django_email_foundation/settings.py @@ -17,22 +17,40 @@ DEF_NODE_MODULES_PATH = getattr(settings, 'DEF_NODE_MODULES_PATH', os.getcwd()) # A list with a node modules required packages +# DEF_NODE_PACKAGES_REQUIRED = ( +# 'gulp-debug@4.0.0', +# 'gulp-htmlmin@1.3.0', +# 'gulp-imagemin@2.4.0', +# 'gulp-inline-css@3.3.1', +# 'gulp-load-plugins@1.5.0', +# 'gulp-open@3.0.1', +# 'gulp-replace@0.5.4', +# 'gulp-sass@2.3.2', +# 'gulp-uncss@1.0.6', +# 'gulp@4.0.0', +# 'inky@1.3.6', +# 'lazypipe@1.0.2', +# 'node-sass@4.9.3', +# 'panini@1.3.0', +# 'siphon-media-query@1.0.0', +# ) + DEF_NODE_PACKAGES_REQUIRED = ( - 'gulp@4.0.0', - 'panini@1.3.0', - 'inky@1.3.6', - 'gulp-open@3.0.1', - 'gulp-debug@4.0.0', - 'gulp-load-plugins@1.5.0', - 'gulp-sass@2.3.2', - 'gulp-inline-css@3.3.1', - 'gulp-uncss@1.0.6', - 'node-sass@4.9.3', - 'gulp-imagemin@2.4.0', - 'siphon-media-query@1.0.0', - 'lazypipe@1.0.2', - 'gulp-htmlmin@1.3.0', - 'gulp-replace@0.5.4', + "gulp-debug@4.0.0", + "gulp-htmlmin@5.0.1", + "gulp-imagemin@6.2.0", + "gulp-inline-css@3.4.0", + "gulp-load-plugins@2.0.1", + "gulp-open@3.0.1", + "gulp-replace@1.0.0", + "gulp-sass@4.0.2", + "gulp-uncss@1.0.6", + "gulp@4.0.2", + "inky@1.3.7", + "lazypipe@1.0.2", + "node-sass@4.13.0", + "panini@1.6.3", + "siphon-media-query@1.0.0" ) # Path for email templates. This settings is required for start run the email builder.