-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add addpikey and removeapikey management commands
- Loading branch information
Showing
3 changed files
with
76 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
{ | ||
"name": "frontend", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@fortawesome/fontawesome-free": "^6.5.1", | ||
"chart.js": "^4.4.2", | ||
"mdb-react-ui-kit": "git+https://oauth2:[api-key-redacted]@git.mdbootstrap.com/mdb/react/mdb5/prd/mdb5-react-ui-kit-pro-essential", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.56", | ||
"@types/react-dom": "^18.2.19", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.5", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.1.4" | ||
} | ||
} | ||
"name": "frontend", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@fortawesome/fontawesome-free": "^6.5.1", | ||
"chart.js": "^4.4.2", | ||
"mdb-react-ui-kit": "git+https://oauth2:[api-key-redacted]@git.mdbootstrap.com/mdb/react/mdb5/prd/mdb5-react-ui-kit-pro-essential", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.56", | ||
"@types/react-dom": "^18.2.19", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.5", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# mastertheorem/management/commands/addapikey.py | ||
|
||
from django.core.management.base import BaseCommand | ||
import os | ||
|
||
class Command(BaseCommand): | ||
help = 'Adds the MDB Pro API key to package.json and package-lock.json' | ||
|
||
def handle(self, *args, **kwargs): | ||
api_key = os.getenv('MDB_PRO_KEY') | ||
for filename in ['package.json', 'package-lock.json']: | ||
file_path = f'frontend/{filename}' | ||
with open(file_path, 'r') as file: | ||
content = file.read() | ||
|
||
updated_content = content.replace('[api-key-redacted]', api_key) | ||
|
||
if content != updated_content: | ||
with open(file_path, 'w') as file: | ||
file.write(updated_content) | ||
self.stdout.write(self.style.SUCCESS(f'Successfully added the API key to {filename}.')) | ||
else: | ||
self.stdout.write(self.style.SUCCESS(f'No changes made to {filename}.')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# mastertheorem/management/commands/removeapikey.py | ||
|
||
from django.core.management.base import BaseCommand | ||
import os | ||
|
||
class Command(BaseCommand): | ||
help = 'Removes the MDB Pro API key from package.json and package-lock.json' | ||
|
||
def handle(self, *args, **kwargs): | ||
api_key = os.getenv('MDB_PRO_KEY') | ||
for filename in ['package.json', 'package-lock.json']: | ||
file_path = f'frontend/{filename}' | ||
with open(file_path, 'r') as file: | ||
content = file.read() | ||
|
||
updated_content = content.replace(api_key, '[api-key-redacted]') | ||
|
||
if content != updated_content: | ||
with open(file_path, 'w') as file: | ||
file.write(updated_content) | ||
self.stdout.write(self.style.SUCCESS(f'Successfully removed the API key from {filename}.')) | ||
else: | ||
self.stdout.write(self.style.SUCCESS(f'No changes made to {filename}.')) |