Exemplo n.º 1
0
    def _build(self, notebook: None = None) -> None:
        """Compile the Bowtie application."""
        packages = self._write_templates(notebook=notebook)

        if not os.path.isfile(os.path.join(_DIRECTORY, 'package.json')):
            packagejson = os.path.join(self._package_dir, 'src/package.json')
            shutil.copy(packagejson, _DIRECTORY)

        if not os.path.isfile(os.path.join(_DIRECTORY, 'webpack.prod.json')):
            webpackprod = os.path.join(self._package_dir, 'src/webpack.prod.js')
            shutil.copy(webpackprod, _DIRECTORY)

        if not os.path.isfile(os.path.join(_DIRECTORY, 'webpack.dev.json')):
            webpackdev = os.path.join(self._package_dir, 'src/webpack.dev.js')
            shutil.copy(webpackdev, _DIRECTORY)

        if run(['yarn', 'install'], notebook=notebook) > 1:
            raise YarnError('Error installing node packages')

        if packages:
            installed = installed_packages()
            new_packages = [x for x in packages if x.split('@')[0] not in installed]

            if new_packages:
                retval = run(['yarn', 'add'] + new_packages, notebook=notebook)
                if retval > 1:
                    raise YarnError('Error installing node packages')
                elif retval == 1:
                    print('Yarn error but trying to continue build')
        retval = run([_WEBPACK, '--config', 'webpack.dev.js'], notebook=notebook)
        if retval != 0:
            raise WebpackError('Error building with webpack')
Exemplo n.º 2
0
    def _build(self, notebook: Optional[str] = None) -> None:
        """Compile the Bowtie application."""
        if node_version() < _MIN_NODE_VERSION:
            raise WebpackError(
                f'Webpack requires at least version {_MIN_NODE_VERSION} of Node, '
                f'found version {node_version}.'
            )

        packages = self._write_templates()

        for filename in ['package.json', 'webpack.prod.js', 'webpack.dev.js']:
            if not (self._build_dir / filename).is_file():
                sourcefile = self._package_dir / 'src' / filename
                shutil.copy(sourcefile, self._build_dir)

        if self._run(['yarn', '--ignore-engines', 'install'], notebook=notebook) > 1:
            raise YarnError('Error installing node packages')

        if packages:
            installed = self._installed_packages()
            new_packages = [x for x in packages if x.split('@')[0] not in installed]

            if new_packages:
                retval = self._run(
                    ['yarn', '--ignore-engines', 'add'] + new_packages, notebook=notebook
                )
                if retval == 1:
                    print('Yarn error but trying to continue build')
                elif retval > 1:
                    raise YarnError('Error installing node packages')
        retval = self._run([_WEBPACK, '--config', 'webpack.dev.js'], notebook=notebook)
        if retval != 0:
            raise WebpackError('Error building with webpack')
Exemplo n.º 3
0
    def _build(self):
        """Compile the Bowtie application."""
        packages = self._write_templates()

        if not os.path.isfile(os.path.join(_DIRECTORY, 'package.json')):
            packagejson = os.path.join(self._package_dir, 'src/package.json')
            shutil.copy(packagejson, _DIRECTORY)

        install = Popen('yarn install', shell=True, cwd=_DIRECTORY).wait()
        if install > 1:
            raise YarnError('Error install node packages')

        packages.discard(None)
        if packages:
            installed = installed_packages()
            packages = [x for x in packages if x.split('@')[0] not in installed]

            if packages:
                packagestr = ' '.join(packages)
                install = Popen('yarn add {}'.format(packagestr),
                                shell=True, cwd=_DIRECTORY).wait()
                if install > 1:
                    raise YarnError('Error install node packages')
                elif install == 1:
                    print('Yarn error but trying to continue build')
        dev = Popen('{} -d'.format(_WEBPACK), shell=True, cwd=_DIRECTORY).wait()
        if dev != 0:
            raise WebpackError('Error building with webpack')
Exemplo n.º 4
0
Arquivo: _app.py Projeto: zz38/bowtie
    def _build(self, notebook: Optional[str] = None) -> None:
        """Compile the Bowtie application."""
        if node_version() < _MIN_NODE_VERSION:
            raise WebpackError(
                f'Webpack requires at least version {_MIN_NODE_VERSION} of Node, '
                f'found version {node_version}.'
            )

        packages = self._write_templates(notebook=notebook)

        if not os.path.isfile(os.path.join(_DIRECTORY, 'package.json')):
            packagejson = os.path.join(self._package_dir, 'src/package.json')
            shutil.copy(packagejson, _DIRECTORY)

        if not os.path.isfile(os.path.join(_DIRECTORY, 'webpack.prod.json')):
            webpackprod = os.path.join(self._package_dir, 'src/webpack.prod.js')
            shutil.copy(webpackprod, _DIRECTORY)

        if not os.path.isfile(os.path.join(_DIRECTORY, 'webpack.dev.json')):
            webpackdev = os.path.join(self._package_dir, 'src/webpack.dev.js')
            shutil.copy(webpackdev, _DIRECTORY)

        if run(['yarn', '--ignore-engines', 'install'], notebook=notebook) > 1:
            raise YarnError('Error installing node packages')

        if packages:
            installed = installed_packages()
            new_packages = [x for x in packages if x.split('@')[0] not in installed]

            if new_packages:
                retval = run(['yarn', '--ignore-engines', 'add'] + new_packages, notebook=notebook)
                if retval > 1:
                    raise YarnError('Error installing node packages')
                elif retval == 1:
                    print('Yarn error but trying to continue build')
        retval = run([_WEBPACK, '--config', 'webpack.dev.js'], notebook=notebook)
        if retval != 0:
            raise WebpackError('Error building with webpack')