# Path: shipwright/_lib/cli.py
# def argparser():
#     def a_arg(parser, *args, **kwargs):
# def parse_registry_logins(registry_logins):
# def _flatten(items):
# def old_style_arg_dict(namespace):
# def main():
# def process_arguments(path, arguments, client_cfg, environ):
#     def default(self, obj):
# def run(path, arguments, client_cfg, environ, new_style_args=None):
# def exit(msg):
# def memo(f, arg, memos={}):
# def pretty_event(evt, show_progress):
# def highlight(name):
#     def highlight_(msg):
# def switch(rec, show_progress):
# class SetJSONEncoder(json.JSONEncoder):
# 
# Path: tests/integration/utils.py
# def commit_untracked(repo, message='WIP'):
#     repo.index.add(repo.untracked_files)
#     repo.index.commit(message)
# 
# def create_repo(path, source=None):
#     if source is not None:
#         shutil.copytree(source, path)
#     repo = git.Repo.init(path)
#     repo.index.add(repo.untracked_files)
#     repo.index.commit('Initial Commit')
#     return repo
# 
# def default_args():
#     return argparse.Namespace(
#         dirty=False,
#         pull_cache=False,
#         registry_login=[],
#     )
# 
# def get_defaults():
#     return {
#         '--account': None,
#         '--dependents': [],
#         '--dump-file': None,
#         '--exact': [],
#         '--exclude': [],
#         '--help': False,
#         '--no-build': False,
#         '--dirty': False,
#         '--upto': [],
#         '--x-assert-hostname': False,
#         '-H': None,
#         'TARGET': [],
#         'build': False,
#         'push': False,
#         'images': False,
#         'tags': ['latest'],
#     }


import json
import pkg_resources
import pytest
from docker import utils as docker_utils
from shipwright._lib import cli as shipw_cli
from .utils import commit_untracked, create_repo, default_args, get_defaults
    repo = create_repo(path)
    tmp.join('.shipwright.json').write(json.dumps({
        'version': 1.0,
        'namespace': 'shipwright',
    }))
    fe = tmp.ensure('frontend', dir=True)
    fe.join('yarn.lock').write('FAKE YARN LOCK!\n', 'a')
    fe.join('Dockerfile-base').write('FROM busybox\n', 'a')
    fe.join('Dockerfile-base').write('COPY yarn.lock /yarn.lock\n', 'a')
    fe.join('src.js').write("var $ = require('jquery')\n", 'a')
    fe.join('Dockerfile').write('FROM shipwright/frontend-base\n', 'a')
    fe.join('Dockerfile').write('COPY src.js /src.js\n', 'a')
    commit_untracked(repo)
    old_tag = repo.head.ref.commit.hexsha[:12]

    client_cfg = docker_utils.kwargs_from_env()
    cli = docker_client

    try:

        shipw_cli.run(
            path=path,
            client_cfg=client_cfg,
            arguments=get_defaults(),
            environ={},
        )

        fe = tmp.join('frontend/src.js')
        fe.write("'import react from 'react';")
        repo.index.add([str(fe)])

# Path: shipwright/_lib/cli.py
# def argparser():
#     def a_arg(parser, *args, **kwargs):
# def parse_registry_logins(registry_logins):
# def _flatten(items):
# def old_style_arg_dict(namespace):
# def main():
# def process_arguments(path, arguments, client_cfg, environ):
#     def default(self, obj):
# def run(path, arguments, client_cfg, environ, new_style_args=None):
# def exit(msg):
# def memo(f, arg, memos={}):
# def pretty_event(evt, show_progress):
# def highlight(name):
#     def highlight_(msg):
# def switch(rec, show_progress):
# class SetJSONEncoder(json.JSONEncoder):
# 
# Path: tests/integration/utils.py
# def commit_untracked(repo, message='WIP'):
#     repo.index.add(repo.untracked_files)
#     repo.index.commit(message)
# 
# def create_repo(path, source=None):
#     if source is not None:
#         shutil.copytree(source, path)
#     repo = git.Repo.init(path)
#     repo.index.add(repo.untracked_files)
#     repo.index.commit('Initial Commit')
#     return repo
# 
# def default_args():
#     return argparse.Namespace(
#         dirty=False,
#         pull_cache=False,
#         registry_login=[],
#     )
# 
# def get_defaults():
#     return {
#         '--account': None,
#         '--dependents': [],
#         '--dump-file': None,
#         '--exact': [],
#         '--exclude': [],
#         '--help': False,
#         '--no-build': False,
#         '--dirty': False,
#         '--upto': [],
#         '--x-assert-hostname': False,
#         '-H': None,
#         'TARGET': [],
#         'build': False,
#         'push': False,
#         'images': False,
#         'tags': ['latest'],
#     }


# Path: tests/integration/test_docker_builds.py
import json
import pkg_resources
import pytest
from docker import utils as docker_utils
from shipwright._lib import cli as shipw_cli
from .utils import commit_untracked, create_repo, default_args, get_defaults

    repo = create_repo(path)
    tmp.join('.shipwright.json').write(json.dumps({
        'version': 1.0,
        'namespace': 'shipwright',
    }))
    fe = tmp.ensure('frontend', dir=True)
    fe.join('yarn.lock').write('FAKE YARN LOCK!\n', 'a')
    fe.join('Dockerfile-base').write('FROM busybox\n', 'a')
    fe.join('Dockerfile-base').write('COPY yarn.lock /yarn.lock\n', 'a')
    fe.join('src.js').write("var $ = require('jquery')\n", 'a')
    fe.join('Dockerfile').write('FROM shipwright/frontend-base\n', 'a')
    fe.join('Dockerfile').write('COPY src.js /src.js\n', 'a')
    commit_untracked(repo)
    old_tag = repo.head.ref.commit.hexsha[:12]

    client_cfg = docker_utils.kwargs_from_env()
    cli = docker_client

    try:

        shipw_cli.run(
            path=path,
            client_cfg=client_cfg,
            arguments=get_defaults(),
            environ={},
        )

        fe = tmp.join('frontend/src.js')
        fe.write("'import react from 'react';")
        repo.index.add([str(fe)])

        commit_untracked(repo)