How to use the mirage.proj.InDir function in mirage

To help you get started, we’ve selected a few mirage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shotastage / mirage-django-lts / mirage / transfer / transfer.py View on Github external
def _check(self, logger):
        
        with proj.InDir(self._to):

            if Path(self._app).is_dir():
                if not mys.log("%s ia already exists.\nAre you sure to replace new one?" % self._app, withConfirm = True):
                    raise FileExistsError
                else:
                    os.system("rm -rf " + self._app)
github shotastage / mirage-django-lts / mirage / transfer / transfer.py View on Github external
def _extract(self, logger):

        with proj.InDir(self._to):
            logger.update("Extracting application...")

            try:
                with zipfile.ZipFile(self._app + ".zip", "r") as contents:
                    contents.extractall()
            except:
                pass
                # zipfile.ZipFile raises No such file or directory: 'hoge.zip'
                # But, zip file is extracted!

            logger.update("Cleaning...")
            #os.remove(self._app + ".zip")
github shotastage / mirage-django-lts / mirage / db / merge.py View on Github external
def _merge(self):
        with proj.MirageEnvironment(proj.MirageEnvironmentLevel.inapp):
            mys.log("Integrate migrations...")

            with proj.InDir("migrations"):
                path_obj = Path(os.getcwd())
                migration_script_path = path_obj.glob("*.py")

                for path in migration_script_path:
                    if not "__init__.py" in str(path):
                        mys.log("Removing " + str(path) + "!")
                        os.remove(path)
                
            with proj.MirageEnvironment(proj.MirageEnvironmentLevel.indjango):
                os.system("python manage.py makemigrations")
github shotastage / mirage-django-lts / mirage / generate / app.py View on Github external
try:
            master_app = self.__detect_master_app()
        except:
            mys.log("Failed to detect master app.", withError = True)


        mys.log("Installing app...")

        with proj.InDir(master_app):
            if os.path.isdir("environment"):
                with proj.InDir("./environment"):
                    self.__insert_app_path(name, "common.py")

            elif os.path.isdir("settings"):
                with proj.InDir("./settings"):
                    self.__insert_app_path(name, "common.py")

            else:
                if os.path.isfile("settings.py"):
                    self.__insert_app_path(name, "settings.py")
                else:
                    mys.log("Failed to install Django app due to missing configuration file.", withError = True)
github shotastage / mirage-django-lts / mirage / generate / app.py View on Github external
def _install_app(self, name):

        try:
            master_app = self.__detect_master_app()
        except:
            mys.log("Failed to detect master app.", withError = True)


        mys.log("Installing app...")

        with proj.InDir(master_app):
            if os.path.isdir("environment"):
                with proj.InDir("./environment"):
                    self.__insert_app_path(name, "common.py")

            elif os.path.isdir("settings"):
                with proj.InDir("./settings"):
                    self.__insert_app_path(name, "common.py")

            else:
                if os.path.isfile("settings.py"):
                    self.__insert_app_path(name, "settings.py")
                else:
                    mys.log("Failed to install Django app due to missing configuration file.", withError = True)
github shotastage / mirage-django-lts / mirage / generate / app.py View on Github external
def _create_url(self, name):
        with proj.InDir("./" + name):
            with open("urls.py", "a") as newscript:
                newscript.write(url_script(name))
github shotastage / mirage-django-lts / mirage / projectstartup / angular_app_create.py View on Github external
email        = mys.log("Email",       withInput = True)
        git_url      = mys.log("Git URL",     withInput = True)
        license_name = mys.log("License",     withInput = True)
        license_url  = mys.log("License Url", withInput = True)
        description  = mys.log("Description", withInput = True)
        copyrightor  = mys.log("Copyrightor", withInput = True, default = author)




        self._create_new_django_app()

        # Create logging instance
        logger = mys.Progress()

        with proj.InDir("./" + self._project_name):

            # Generate .gitignore
            #log("Generating gitignore...")
            logger.write("Generating gitignore...", withLazy = True)
            self._create_template_git_project()

            # Generate README.md
            logger.update("Generating readme...", withLazy = True)
            self._create_docs(author, description, license_name)

            # Generate Miragefile
            logger.update("Generating Miragefile...", withLazy = True)
            self._create_miragefile(version, author, email, git_url,
                                    license_name, license_url, description, copyrightor)

            # Add remote repo
github shotastage / mirage-django-lts / mirage / projectstartup / start_base.py View on Github external
mys.command("./node_modules/.bin/create-react-app shell")
            else:
                mys.command("./node_modules/.bin/create-react-app --scripts-version=react-scripts-ts shell")

            logger.update("Installing additional packages...")
            with proj.InDir("./shell"):
                mys.command("yarn add redux react-redux")
                mys.command("yarn add react-router react-router-dom")

            # Cleaning
            logger.update("Cleaning...", withLazy = True)
            fileable.rm("yarn.lock")
            fileable.rm("package.json")
            fileable.rm("node_modules/")

            with proj.InDir("./shell"):
                fileable.rm(".gitignore")
                fileable.rm("README.md")


        # Completed
        logger.update("Completed!")