示例#1
0
  def npm(self, packages):
    """
    Description:
    ------------

    :param packages:
    """
    if self.envs is not None:
      for env in self.envs:
        subprocess.run(env, shell=True, cwd=self._vue_app_path)
    packages = node.npm_packages(packages)
    subprocess.run('npm install %s' % " ".join(packages), shell=True, cwd=self._vue_app_path)
示例#2
0
文件: react.py 项目: ylwb/epyk-ui
    def npm(self, packages):
        """
    Description:
    ------------
    This will add the npm requirements to the Angular app but also update directly the angular.json for anything needed
    at the start of the application.

    Attributes:
    ----------
    :param packages: List. The packages names to install
    """
        if self.envs is not None:
            for env in self.envs:
                subprocess.run(env, shell=True, cwd=self._react_app_path)
        packages = node.npm_packages(packages)
        subprocess.run('npm install %s' % " ".join(packages),
                       shell=True,
                       cwd=self._react_app_path)
示例#3
0
    def npm(self, packages: list):
        """
    Description:
    ------------
    This will add the npm requirements to the Angular app but also update directly the angular.json for anything needed
    at the start of the application.

    This is mainly used for generic and common libraries like Jquery and Jquery UI

    Attributes:
    ----------
    :param list packages: The packages names to install
    """
        if self.envs is not None:
            for env in self.envs:
                subprocess.run(env,
                               shell=True,
                               cwd=os.path.join(self._app_path,
                                                self._app_name))
        packages = node.npm_packages(packages)
        subprocess.run('npm install %s' % " ".join(packages),
                       shell=True,
                       cwd=os.path.join(self._app_path, self._app_name))
        map_modules = {
            "jquery": "./node_modules/jquery/dist/jquery.min.js",
            "chart.js": "./node_modules/chart.js/dist/Chart.js",
            "jquery-ui-dist": "./node_modules/jquery-ui-dist/jquery-ui.js",
        }
        angular_conf_path = os.path.join(self._app_path, self._app_name,
                                         "angular.json")
        with open(angular_conf_path) as f:
            angular_conf = json.load(f)
        config_updated = False
        scripts = angular_conf["projects"][
            self._app_name]["architect"]['build']['options']["scripts"]
        for mod, path in map_modules.items():
            if mod in packages:
                if path not in scripts:
                    config_updated = True
                    scripts.append(path)
        if config_updated:
            with open(angular_conf_path, "w") as f:
                json.dump(angular_conf, f, indent=2)