Exemple #1
0
def RunWct(base_dir, dep_dirs, debug=False, prefix=''):
    command = [node_util.GetNodePath(), RUN_WCT]
    command += ['--base', base_dir]
    command += ['--prefix', prefix]
    if debug:
        command += ['--debug']
    for dep in dep_dirs:
        command += ['--dep', dep]
    logging.info('Starting WCT: %r', command)
    return subprocess.call(command)
Exemple #2
0

def _UpdateSysPathIfNeeded():
  _AddToPathIfNeeded(os.path.join(_CATAPULT_PATH, 'common', 'node_runner'))
  _AddToPathIfNeeded(os.path.join(_CATAPULT_PATH, 'common', 'py_utils'))


_UpdateSysPathIfNeeded()


import py_utils
from node_runner import node_util


BASE_ESLINT_CMD = [
  node_util.GetNodePath(),
  os.path.join(node_util.GetNodeModulesPath(), 'eslint', 'bin', 'eslint.js'),
  '--color'
]


DEFAULT_ESLINT_CONFIG = os.path.join(
    py_utils.GetCatapultDir(), 'common', 'eslint', '.eslintrc')


DEFAULT_ESLINT_RULES_DIR = os.path.join(
    py_utils.GetCatapultDir(), 'common', 'eslint', 'rules')


def _CreateEslintCommand(config, rulesdir):
  return BASE_ESLINT_CMD + [
Exemple #3
0
def PackPinpoint(catapult_path, temp_dir, deployment_paths):
    with Chdir(catapult_path):
        _AddToPathIfNeeded(os.path.join(catapult_path, 'common',
                                        'node_runner'))
        from node_runner import node_util
        node_path = node_util.GetNodePath()
        node_modules = node_util.GetNodeModulesPath()

        def PinpointRelativePath(*components):
            return os.path.join('dashboard', 'pinpoint', *components)

        # When packing Pinpoint, we need some extra symlinks in the temporary
        # directory, so we can find the correct elements at bundle time. This is
        # simulating the paths we would be serving as defined in the pinpoint.yaml
        # file.
        os.symlink(
            os.path.join(catapult_path, 'dashboard', 'dashboard', 'pinpoint',
                         'elements'), os.path.join(temp_dir, 'elements'))
        os.symlink(
            os.path.join(catapult_path, 'third_party', 'polymer',
                         'components'), os.path.join(temp_dir, 'components'))
        os.symlink(os.path.join(catapult_path, 'third_party', 'd3'),
                   os.path.join(temp_dir, 'd3'))

        # We don't yet use any webpack in Pinpoint, so let's use the polymer bundler
        # for now.
        bundler_cmd = [
            node_path,
            os.path.join(node_modules, 'polymer-bundler', 'lib', 'bin',
                         'polymer-bundler.js'),
            '--inline-scripts',
            '--inline-css',
            # Exclude some paths from the bundling.
            '--exclude',
            '//fonts.googleapis.com/*',
            '--exclude',
            '//apis.google.com/*',
            # Then set up the rest of the options for the bundler.
            '--out-dir',
            os.path.join(temp_dir, 'bundled'),
            '--root',
            temp_dir,
            '--treeshake',
        ]

        # Change to the temporary directory, and run the bundler from there.
        with Chdir(temp_dir):
            bundler_cmd.extend(
                ['--in-file',
                 PinpointRelativePath('index', 'index.html')])

            logging.info('Bundler Command:\n%s', ' '.join(bundler_cmd))

            proc = subprocess.Popen(bundler_cmd,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
            _, bundler_err = proc.communicate()
            if proc.returncode != 0:
                print('ERROR from bundler:')
                print(bundler_err)
                raise RuntimeError('Vulcanize failed with exit code',
                                   proc.returncode)

            deployment_paths.append(os.path.join(temp_dir, 'bundled'))