Django Private Project Git Repo - Open Source App Repo - django

My team and I are currently working on a django app. We want to keep track of changes to the django project files on a private repo (so that all of the private information is not available) as well as open source the app files on github.
Currently we have two repos:
1) A repo for the project that contains:
/Main Folder
|- .git
|- /djangoproject
|- requirements.txt
|- dev-db.sqlite
|- manage.py
|- .gitignore
The git ignore is told to ignore the second repo which is the app repo and also resides in Main Folder:
2)
/Main Folder
|- /django-app-name // the name of the repo as appearing on github
|- .git
|- /djangoapp
|- models.py
|- urls.py
|- views.py
|- admin.py
|- ....
|- .gitignore
|- LICENSE
|- README.md
|- requirements.txt
This works for our purposes, but it would be really nice to somehow consolidate the two repos so that a single command would work with both. I am just getting started with git, so I don't know all of the awesome features that git contains. Is there a way to be able to track both the private and public portions of the whole django project within a single repo? What is the best way, using git, to have private project settings and an open source app?

As far as I know, the best way to do this is to have a git submodule.
Have look at how git submodules work : http://git-scm.com/book/en/Git-Tools-Submodules

Related

Node.js lambda: how to import common layer utility lib in local development but also work in the cloud

I have a monorepo with a few functions in their own folder. I want to create a common layer with utility functions that I can require/import locally and also after deployment to the cloud. I want to add a layers/ directory to do this, with the folder structure looking something like this:
A
|- node_modules/
|- package.json
|- index.js
B
|- node_modules/
|- package.json
|- index.js
layers
|- nodejs
|- node_modules
|- package.json
|- util.js
I'm not set on the folder structure above and am OK with it changing.
Currently, I only have A and B with their own individual dependency layers (orchestrated using terraform), and they work great locally and deployed.
With the introduction of a common utility layer, the issue is that I can require/import locally but it wouldn't be the same in the cloud (/opt/nodejs/*), but if I change it up to work on the cloud, it won't work locally.
I am not using the serverless framework.

Publish html/js project to github page

I have a simple javascript projet created using npm. The source code is in a public github repository.
Here is the content of the repository
my-project
src
index.html
app.js
package.json
README.md
In my local environment I run it using lite-server by executing npm run dev.
I create gh-pages branch from my main branch, my code was automatically deployed after but when I visit the page it show the content of the README.md file.
How can I point to my index.html page instead so that my simple website is rendered ?
Do I have to absolutely move my index.html to the root directory ? Or is there other way without changing my project folder structre ?
=============== MY SOLUTION ===============
I just had to copy index.html and app.js at the root of the branch gh-pages.
You can only choose the root folder or /docs from repo settings.
https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site

Publish SCSS file into NPM package Vue-cli 3

I am authoring a Vue.js lib on NPM and one of my users is asking me to add my scss file into the build so they can modify it.
How can users modify that scss file and compile it back to my lib?
Would that be a hack like modifying a lib's source code or is that common practice?
If I externalize that scss into a static file (I suspect in public/ folder), how do I include it from my component?
Is there a documentation about it, I looked into Vue-cli, Webpack, and Google and didn't find a guide.
Currently I only export a minified css file into the build and my scss resides in my index.vue of my component.
My project architecture is:
| public/
| src/
| assets/
| components/
|- my-lib/ // Only this folder gets bundled into dist/
|- index.vue
|- app.vue // My app documentation.
In the dist/ folder I get:
mylib.css
mylib.umd.js
mylib.umd.min.js
mylib.common.js
mylib.umd.min.js
demo.html
I bundle my lib (with vue-cli 3) with:
vue-cli-service build --target lib --name mylib ./src/components/mylib/index.vue --dest ./dist

How to ignore nested node modules when running mocha?

I have a project with the following setup:
Project
|- node_modules
|- server
|- client // nested create-react-app
|- node_modules
|- package.json
|-etc
|- package.json
|- etc
From project root, I'd like to run mocha recursively throughout both server and client directories (or any other directory that may be required) looking to *.test.js files, while ignoring all node_modules directories.
This article explained how to run mocha recursively while ignoring node_modules, but it only ignores the top-level node_modules. Mocha fails when it encounters ./client/node_modules.
Is it possible to modify this command to ignore all node_modules directories, not just in the project root?
"test:unit": "mocha --compilers js:babel-core/register \"./{,!(node_modules)/**}/*.test.js\""
Decided to run tests on specific directories, like so:
"test:unit": "mocha --compilers js:babel-core/register ./server/**/*.test.js \"./client/{,!(node_modules)/**}/*.test.js\""

Openshift wrapper vs. project repo

I've tried to find a concrete answer for this but failed. I'm rather new to openshift, django and git so I hope it's not too trivial and not a duplicate.
The situation is as follows:
1. I'm developing a Django based web application and source control it using git on a private bitbucket repo. I have my regular django application source tree as needed.
2. I wish to deploy my app on openshift which comes with a different directory tree. I've been able to successfully run this quickstart:
git://github.com/rancavil/django-openshift-quickstart.git
Basically what I try to achieve is a wrapper directory (and git project) which is based on the repo specified in #2. Within this wrapper one of the subdirectories (wsgi/my_project) should be based on my private repo specified in #1.
I wish to be able to pull recent changes from the private repo and then push and deploy to openshift these changes.
Any help would be greatly appreciated!
I was also struggling with openshift structure. But there is no need for doing the staff like you have proposed.
You can have any structure of a project you want. Openshift will need just wsgi/application or wsgi.py as an entry point. I think that having one more file in your project is hardly a problem.
My current structure for a project (got it running recently) is following:
|- .openshift (directory for build and deployment hooks like syncdb or collectstatic commands)
|- custom_project (directory that is you django project)
\- templates
|- settings.py
|- urls.py
|- manage.py
|- requirements.txt
|- wsgi.py
There is really no need to have project under wsgi folder. However there are few more pitfalls to be aware of. Like creating static folder or setting .htaccess for static files.
Including my wsgi.py:
#!/usr/bin/python
import os
import logging
try:
virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
execfile(virtualenv, dict(__file__=virtualenv))
except (IOError, KeyError):
pass
os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'custom_project.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I have used a lot of resources to make my project running on openshift so I'm also including them for other.
bitbucket and openshit repos: Can I use my existing git repo with openshift?
Slides with necesary steps: http://appsembler.com/blog/paas-bakeoff-comparing-stackato-openshift-dotcloud-and-heroku-for-django-hosting-and-deployment/
And the most important one, the really well written step-by-step tutorial: http://www.paascheatsheet.com/#Introduction