clixdev
Advanced tools
+1
-1
| Metadata-Version: 2.1 | ||
| Name: clixdev | ||
| Version: 0.3.8.3 | ||
| Version: 0.3.8.4 | ||
| Summary: https://clix.dev command line tool. | ||
@@ -5,0 +5,0 @@ Author-email: Eris Verne <erisverne7@gmail.com> |
+1
-1
@@ -7,3 +7,3 @@ [build-system] | ||
| name = "clixdev" | ||
| version = "0.3.8.3" | ||
| version = "0.3.8.4" | ||
| authors = [ | ||
@@ -10,0 +10,0 @@ { name="Eris Verne", email="erisverne7@gmail.com" }, |
| Metadata-Version: 2.1 | ||
| Name: clixdev | ||
| Version: 0.3.8.3 | ||
| Version: 0.3.8.4 | ||
| Summary: https://clix.dev command line tool. | ||
@@ -5,0 +5,0 @@ Author-email: Eris Verne <erisverne7@gmail.com> |
@@ -5,5 +5,6 @@ import os | ||
| import requests | ||
| from pathlib import Path | ||
| # from pathlib import Path | ||
| from .trace import MANAGE, REQUIREMENTS, WSGI, URLS, SETTINGS, VIEWS, MODELS, ADMIN, README, APP_URLS | ||
| # URLS, REQUIREMENTS, README, ADMIN | ||
| from .trace import MANAGE, WSGI, SETTINGS, BASE_SETTINGS, VIEWS, BASE_MODELS, APP_URLS | ||
@@ -19,3 +20,2 @@ | ||
| secret_key = res.get('misc').get('secret_key') | ||
| project_name = res.get('misc').get('project_name') | ||
@@ -31,4 +31,5 @@ working_dir = os.getcwd() + '/' + args[0] + '/' + project_name + '/' if args[0] else os.getcwd() + '/' + project_name + '/' | ||
| 'manage.py': MANAGE(project_name), | ||
| project_name + '/': [('__init__.py', ''), ('wsgi.py', WSGI(project_name)), ('settings.py', SETTINGS(project_name, res.get('apps'), res.get('settings'), secret_key)), ('urls.py', URLS(res.get('apps')))], | ||
| project_name + '/': [('__init__.py', ''), ('wsgi.py', WSGI(project_name)), ('settings.py', SETTINGS(res.get('settings'),))], | ||
| } | ||
| # , ('urls.py', URLS(res.get('apps'))) | ||
| # 'README.md': README(), | ||
@@ -75,3 +76,3 @@ # 'requirements.txt': REQUIREMENTS(), | ||
| # syncs usr/local/.clix/project_token folder | ||
| # creates clixdev.__path__/apps/clix/* | ||
| def sync(terminal_token, project_token, *args): | ||
@@ -110,4 +111,8 @@ res = requests.post('https://api.clix.dev/api/package/sync', | ||
| f = open(clixdev.__path__[0] + '/apps/clix' + '/models.py', 'w') | ||
| f.write(MODELS(res.get('apps')[0])) | ||
| f.write(BASE_MODELS(res.get('apps')[0])) | ||
| f.close() | ||
| f = open(clixdev.__path__[0] + '/apps/clix' + '/settings.py', 'w') | ||
| f.write(BASE_SETTINGS(res.get('misc').get('project_name'), res.get('misc').get('secret_key'))) | ||
| f.close() | ||
@@ -114,0 +119,0 @@ f = open(clixdev.__path__[0] + '/apps/clix' + '/apps.py', 'w') |
+34
-60
@@ -23,9 +23,4 @@ def MANAGE(proj_name): | ||
| # deprecated at beta | ||
| def URLS(apps): | ||
| # routes = [f"from {app['name']} import urls as {app['name']}_urls\n" for app in apps] | ||
| # includes = [] | ||
| # for app in apps: | ||
| # includes.append(f"\tpath('{app['base_url']}', include({app['name']}_urls)),\n") | ||
| return f"""from clixdev.apps.clix import urls | ||
@@ -41,34 +36,13 @@ from django.contrib import admin | ||
| """ | ||
| # removed due to beta | ||
| # {''.join(routes)} | ||
| # {''.join(includes)} | ||
| def SETTINGS(proj_name, apps, settings, secret_key): | ||
| settings = [setting[0]+ ' = ' + setting[1] + '\n' for setting in settings.values()] | ||
| # \t{','.join("'" + app['name'] + "'" for app in apps)}, | ||
| return f"""from pathlib import Path | ||
| from datetime import timedelta | ||
| def BASE_SETTINGS(proj_name, secret_key): | ||
| return f"""import {proj_name} | ||
| # Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
| BASE_DIR = Path(__file__).resolve().parent.parent | ||
| BASE_DIR = {proj_name}.__path__[0] | ||
| # Quick-start development settings - unsuitable for production | ||
| # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ | ||
| # SECURITY WARNING: keep the secret key used in production secret! | ||
| SECRET_KEY = '{secret_key}' | ||
| # SECURITY WARNING: don't run with debug turned on in production! | ||
| DEBUG = True | ||
| ALLOWED_HOSTS = [] | ||
| #### SETTINGS #### | ||
| {''.join([setting for setting in settings])} | ||
| # Application definition | ||
| INSTALLED_APPS = [ | ||
@@ -95,3 +69,3 @@ \t'django.contrib.admin', | ||
| ROOT_URLCONF = '{proj_name}.urls' | ||
| ROOT_URLCONF = 'clixdev.apps.clix.urls' | ||
@@ -116,18 +90,9 @@ TEMPLATES = [ | ||
| # Database | ||
| # https://docs.djangoproject.com/en/3.1/ref/settings/#databases | ||
| DATABASES = {{ | ||
| \t'default': {{ | ||
| \t\t'ENGINE': 'django.db.backends.sqlite3', | ||
| \t\t'NAME': BASE_DIR / 'db.sqlite3', | ||
| \t\t'NAME': BASE_DIR / '{proj_name}/db.sqlite3', | ||
| \t}} | ||
| }} | ||
| # Password validation | ||
| # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators | ||
| AUTH_PASSWORD_VALIDATORS = [ | ||
@@ -148,6 +113,2 @@ \t{{ | ||
| # Internationalization | ||
| # https://docs.djangoproject.com/en/3.1/topics/i18n/ | ||
| LANGUAGE_CODE = 'en-us' | ||
@@ -163,11 +124,22 @@ | ||
| STATIC_URL = '/static/' | ||
| """ | ||
| # Static files (CSS, JavaScript, Images) | ||
| # https://docs.djangoproject.com/en/3.1/howto/static-files/ | ||
| STATIC_URL = '/static/' | ||
| def SETTINGS(settings): | ||
| settings = [setting[0]+ ' = ' + setting[1] + '\n' for setting in settings.values()] | ||
| return f"""from clixdev.apps.clix.settings import * | ||
| """ | ||
| DEBUG = True | ||
| ALLOWED_HOSTS += [] | ||
| #### SETTINGS #### | ||
| {''.join([setting for setting in settings])} | ||
| INSTALLED_APPS += [] | ||
| MIDDLEWARE += [] | ||
| """ | ||
| def WSGI(proj_name): | ||
@@ -186,3 +158,3 @@ return f"""import os | ||
| endpoints = app['endpoints'] | ||
| defs = ["import json\nfrom django.http import JsonResponse\nfrom django.views.decorators.csrf import csrf_exempt\n\nfrom clixdev.apps.clix.models import *"] | ||
| defs = ["from django.http import JsonResponse\nfrom clixdev.apps.clix.models import *\nfrom django.views.decorators.csrf import csrf_exempt"] | ||
@@ -193,7 +165,7 @@ for endpoint in endpoints: | ||
| response = endpoint.get('response') | ||
| responses = ''.join([f'"{k}": "{v}",' for k, v in response.items()]) | ||
| responses = ''.join([f'"{k}": "{v}",' for k, v in response.items()]) if len(response.items()) > 0 else '' | ||
| csrf = '@csrf_exempt\n' if req.get('host') == 'localhost' else '' | ||
| header_code = '\n\t\t\theaders = request.headers' if len(endpoint.get('headers').get('body').items()) > 0 else '' | ||
| param_code = '\n\t\t\tparams = kwargs.items()' if len(endpoint.get('params').items()) > 0 else '' | ||
| body_code = '\n\t\t\tbody = json.loads(request.body)\n\n' if len(endpoint.get('body').get('payload')) > 0 else '\n' if header_code != '' else '' | ||
| header_code = '\theaders = request.headers' if len(endpoint.get('headers').get('body').items()) > 0 else '' | ||
| params_code = '\n\tparams = kwargs.items()' if len(endpoint.get('params').items()) > 0 and header_code != '' else '\tparams = kwargs.items()' if len(endpoint.get('params').items()) > 0 and header_code == '' else '' | ||
| body_code = '\n\tbody = json.loads(request.body)' if len(endpoint.get('body').get('payload')) > 0 and (header_code != '' or params_code != '') else '\tbody = json.loads(request.body)' if len(endpoint.get('body').get('payload')) > 0 and params_code == '' else '' | ||
@@ -206,6 +178,7 @@ defs.append(f""" | ||
| {csrf}def {misc.get('token')}(request, *args, **kwargs): | ||
| \treturn JsonResponse({{}}) | ||
| {header_code}{params_code}{body_code} | ||
| \treturn JsonResponse({{{responses}}}) | ||
| """) | ||
| # removed for beta | ||
| # \ttry:{header_code}{param_code}{body_code} | ||
| # \t#### Add Your Logic Here #### | ||
@@ -222,3 +195,3 @@ # \tif request.method == '{req.get('method')}': | ||
| def MODELS(app): | ||
| def BASE_MODELS(app): | ||
| app_name = app.get('name') | ||
@@ -276,3 +249,2 @@ _class = "" | ||
| # add your models here | ||
| {_class} | ||
@@ -284,10 +256,12 @@ """ | ||
| endpoints = app['endpoints'] | ||
| urls = [f"from django.urls import path\n\nfrom clix.views import *\n\nurlpatterns = ["] | ||
| urls = [ | ||
| f"from django.urls import path\n\nfrom django.contrib import admin\n\nfrom clix.views import *\n\nurlpatterns = [\n\tpath('admin/', admin.site.urls),"] | ||
| for endpoint in endpoints: | ||
| urls.append( | ||
| f"""\tpath('{endpoint.get('request').get('uri')}{'/' if len(endpoint['params']) > 0 else ''}{'/'.join(['<'+param[0]+'>' for param in endpoint['params'].values() if param[0]])}', {endpoint.get('misc').get('token')}),""") | ||
| f"""\tpath('api/{endpoint.get('request').get('uri')}{'/' if len(endpoint['params']) > 0 else ''}{'/'.join(['<'+param[0]+'>' for param in endpoint['params'].values() if param[0]])}', {endpoint.get('misc').get('token')}),""") | ||
| return '\n'.join(urls) + "\n]" | ||
| # deprecated at beta | ||
| def ADMIN(app): | ||
@@ -294,0 +268,0 @@ # models = app.get('models') |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
24740
-1.91%405
-2.64%