Ejemplo n.º 1
0
    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, "base.py")

            elif os.path.isdir("settings"):
                with proj.InDir("./settings"):
                    self.__insert_app_path(name, "base.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)
Ejemplo n.º 2
0
    def main(self):

        # Check
        try:
            self._check_before()
        except:
            return

        # Input information
        mys.log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = mys.log("Project name", withInput=True)
            self._check_namesapce(self._project_name)
        except:
            mys.log("Project \"{0}\" is already exists.".format(
                self._project_name),
                    withError=True,
                    errorDetail=
                    "Please remove duplication of Django project namespace.")
            return

        version = mys.log("App version", withInput=True, default="0.0.1")
        author = mys.log("Author name", withInput=True)
        email = mys.log("Email", withInput=True)
        git_url = mys.log("Git URL", withInput=True)
        license_name = mys.log("License", 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.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()

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

            # Add remote repo
            logger.update("Adding remote repository...", withLazy=True)
            mys.command("git remote add origin " + git_url)

        # Completed
        logger.update("Completed!")
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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...")
Ejemplo n.º 5
0
    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")
Ejemplo n.º 6
0
    def main(self):

        if self._project_name == None:
            log("Please type your new Django CMS application name.")
            self._project_name = log("Django CMS name", withInput=True)

        try:
            self._check(self._project_name)
        except:
            log("Project {0} is already exists.".format(self._project_name),
                withError=True)

        self._create_new_django_app(self._project_name)

        with proj.InDir("./" + self._project_name):
            self._create_template_git_project(self._project_name)
            self._create_docs(self._project_name)
Ejemplo n.º 7
0
 def _create_url(self, name):
     with proj.InDir("./" + name):
         with open("urls.py", "a") as newscript:
             newscript.write(url_script(name))
Ejemplo n.º 8
0
    def main(self):

        # Check
        try:
            self._check_before()
        except:
            return

        # Input information
        mys.log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = mys.log("Project name", withInput=True)
            self._check_namesapce(self._project_name)
        except:
            mys.log("Project \"{0}\" is already exists.".format(
                self._project_name),
                    withError=True,
                    errorDetail=
                    "Please remove duplication of Django project namespace.")
            return

        version = mys.log("App version", withInput=True, default="0.0.1")
        author = mys.log("Author name", withInput=True)
        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
            logger.update("Adding remote repository...", withLazy=True)
            mys.command("git remote add origin " + git_url)

            # Create React App
            self._create_package_json()
            logger.update("Preparing Angular setup tools...", withLazy=True)
            logger.update(
                "Preparing Angular setup tools... ( please wait for a momenet )"
            )
            mys.command("yarn add --dev @angular/cli")

            # To avoid ng inside the project error, remove package.package.json
            os.remove("package.json")

            logger.update(
                "Configuring Angular setup tools to use Yarn package...")
            mys.command(
                "./node_modules/.bin/ng set --global packageManager=yarn")
            logger.update("Creating Angular app...", withLazy=True)
            logger.update(
                "Creating Angular app... ( please wait for a momenet )")
            mys.command("./node_modules/.bin/ng new shell")

            if self._plugins == "--nebular":
                logger.update("Installing Nebular packages...", withLazy=True)
                logger.update(
                    "Installing Nebular packages... ( please wait for a momenet )"
                )
                with proj.InDir("./shell"):
                    mys.command("yarn add @nebular/theme @nebular/auth")

            elif self._plugins == "--material":
                logger.update("Installing material theme packages...")
                with proj.InDir("./shell"):
                    mys.command("yarn add @angular/material @angular/cdk")

            elif self._plugins == "--bootstrap":
                logger.update("Installing Bootstrap theme packages...")
                with proj.InDir("./shell"):
                    mys.command("yarn add ngx-bootstrap")

            # 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!")
Ejemplo n.º 9
0
    def main(self):
        # Check

        try:
            self._check_before()
        except:
            return

        # Input information
        log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = log("Project name", withInput=True)
            self._check_namesapce(self._project_name)
        except:
            log("Project \"{0}\" is already exists.".format(
                self._project_name),
                withError=True,
                errorDetail=
                "Please remove duplication of Django project namespace.")
            return

        version = log("App version", withInput=True, default="0.0.1")
        author = log("Author name", withInput=True)
        email = log("Email", withInput=True)
        git_url = log("Git URL", withInput=True)
        license_name = log("License", withInput=True)
        description = log("Description", withInput=True)
        copyrightor = log("Copyrightor", withInput=True, default=author)

        self._create_new_django_app()

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

            # Generate .gitignore
            log("Generating gitignore...")
            self._create_template_git_project()

            # Generate README.md
            log("Generating readme...")
            self._create_docs()

            # Generate Miragefile
            log("Generating Miragefile...")
            self._create_miragefile(version, author, email, git_url,
                                    license_name, description, copyrightor)

            # Add remote repo
            log("Adding remote repository...")
            command("git remote add origin " + git_url)

            # Make shell directory
            os.mkdir("shell")

        with proj.InDir("./shell"):

            # Generate package.json
            log("Generating package configuration...")
            self._create_package_json(version, description, git_url, author,
                                      email, license_name)

            # Install webpack
            log("Installing assets builder...")
            command("yarn add --dev webpack")

        # Completed
        log("Completed!")
    def main(self):

        # Check
        try:
            self._check_before()
        except:
            return

        # Input information
        mys.log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = mys.log("Project name", withInput=True)
            self._check_namesapce(self._project_name)
        except:
            mys.log("Project \"{0}\" is already exists.".format(
                self._project_name),
                    withError=True,
                    errorDetail=
                    "Please remove duplication of Django project namespace.")
            return

        version = mys.log("App version", withInput=True, default="0.0.1")
        author = mys.log("Author name", withInput=True)
        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
            logger.update("Adding remote repository...", withLazy=True)
            mys.command("git remote add origin " + git_url)

            # Create React App
            logger.update("Creating React app...")
            self._create_package_json()
            mys.command("yarn add --dev create-react-app")

            if self._js_runtime == "--javascript":
                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!")