def _setup_livereload(build, target):
	'''setup livereload service'''	

	template = lib.expand_relative_path(build, path.join('.template', 'lib', 'live'))
	live = lib.expand_relative_path(build, path.join('development', 'live'))

	if not path.isdir(live):
		os.mkdir(live)

	with cd(live):
		shutil.copyfile(path.join(template, "package.json"), "package.json")
		shutil.copyfile(path.join(template, "Gruntfile.js"), "Gruntfile.js")
		_npm(build, "install")
def _lookup_or_prompt_for_signing_info(build):
	"""Obtain the required details for signing an APK, first by checking local_config.json
	and then asking the user for anything missing.
	"""

	required_info = {
		'android.profile.keystore': {
			'type': 'string',
			'_filepicker': True,
			'description': 'The location of your release keystore',
			'title': 'Keystore',
			'_order': 1,
		},
		'android.profile.storepass': {
			'type': 'string',
			'_password': True,
			'_sensitive': True,
			'description': 'The password for your release keystore',
			'title': 'Keystore password',
			'_order': 2,
		},
		'android.profile.keyalias': {
			'type': 'string',
			'description': 'The alias of your release key',
			'title': 'Key alias',
			'_order': 3,
		},
		'android.profile.keypass': {
			'type': 'string',
			'_password': True,
			'_sensitive': True,
			'description': 'The password for your release key',
			'title': 'Key password',
			'_order': 4,
		}
	}

	signing_info = lib.get_or_ask_for_local_config(
		build,
		required_info,
		question_title='Enter details for signing your app',
	)

	signing_info['android.profile.keystore'] = lib.expand_relative_path(
		build, signing_info['android.profile.keystore']
	)

	return signing_info
Exemple #3
0
def _lookup_or_prompt_for_signing_info(build):
    """Obtain the required details for signing an APK, first by checking local_config.json
	and then asking the user for anything missing.
	"""

    required_info = {
        'android.profile.keystore': {
            'type': 'string',
            '_filepicker': True,
            'description': 'The location of your release keystore',
            'title': 'Keystore',
            '_order': 1,
        },
        'android.profile.storepass': {
            'type': 'string',
            '_password': True,
            '_sensitive': True,
            'description': 'The password for your release keystore',
            'title': 'Keystore password',
            '_order': 2,
        },
        'android.profile.keyalias': {
            'type': 'string',
            'description': 'The alias of your release key',
            'title': 'Key alias',
            '_order': 3,
        },
        'android.profile.keypass': {
            'type': 'string',
            '_password': True,
            '_sensitive': True,
            'description': 'The password for your release key',
            'title': 'Key password',
            '_order': 4,
        }
    }

    signing_info = lib.get_or_ask_for_local_config(
        build,
        required_info,
        question_title='Enter details for signing your app',
    )

    signing_info['android.profile.keystore'] = lib.expand_relative_path(
        build, signing_info['android.profile.keystore'])

    return signing_info
Exemple #4
0
def _search_for_sdk(build):
    # Some sensible places to look for the Android SDK
    possible_sdk = [
        "C:/Program Files (x86)/Android/android-sdk/",
        "C:/Program Files/Android/android-sdk/", "C:/Android/android-sdk/",
        "C:/Android/android-sdk-windows/", "C:/android-sdk-windows/",
        "/Applications/android-sdk-macosx",
        path.expanduser("~/.forge/android-sdk-linux")
    ]

    user_sdk = build.tool_config.get('android.sdk')

    if user_sdk:
        # if android SDK supplied by user, normalise the path and add
        # it to the list of places to look
        user_sdk = lib.expand_relative_path(build, user_sdk)
        possible_sdk.insert(0, user_sdk)

    for directory in possible_sdk:
        if path.isdir(directory):
            found_sdk = directory if directory.endswith(
                '/') else directory + '/'
            return _create_path_info_from_sdk(found_sdk)
def _search_for_sdk(build):
	# Some sensible places to look for the Android SDK
	possible_sdk = [
		"C:/Program Files (x86)/Android/android-sdk/",
		"C:/Program Files/Android/android-sdk/",
		"C:/Android/android-sdk/",
		"C:/Android/android-sdk-windows/",
		"C:/android-sdk-windows/",
		"/Applications/android-sdk-macosx",
		path.expanduser("~/.forge/android-sdk-linux")
	]

	user_sdk = build.tool_config.get('android.sdk')

	if user_sdk:
		# if android SDK supplied by user, normalise the path and add
		# it to the list of places to look
		user_sdk = lib.expand_relative_path(build, user_sdk)
		possible_sdk.insert(0, user_sdk)

	for directory in possible_sdk:
		if path.isdir(directory):
			found_sdk = directory if directory.endswith('/') else directory + '/'
			return _create_path_info_from_sdk(found_sdk)
Exemple #6
0
def package_web(build):
	interactive = build.tool_config.get('general.interactive', True)
	development = lib.expand_relative_path(build, 'development/web')
	output = lib.expand_relative_path(build, 'release/web/heroku')

	# deploy to Heroku
	with cd(development):
		api_key = _get_heroku_api_key(build)
		chosen_app = _get_app_to_push_to(build, api_key)

		if not path.isdir(output):
			os.makedirs(output)

		with cd(output):
			if not path.isdir('.git'):
				LOG.debug('Creating git repo')
				_git('init')

				LOG.debug('Create dummy first commit')
				with open('.forge.txt', 'w') as forge_file:
					forge_file.write('')
				_git('add', '.')
				_git('commit', '-am', 'first commit')

		# remove all previous files/folders except for .git!
		with cd(output):
			for f in os.listdir('.'):
				if not f == '.git':
					if path.isfile(f):
						os.remove(f)

					elif path.isdir(f):
						shutil.rmtree(f)

		# copy code from development to release!
		with cd(development):
			for f in os.listdir('.'):
				if path.isfile(f):
					shutil.copy2(f, output)
				elif path.isdir(f) and path.basename(f) != '.git':
					shutil.copytree(f, path.join(output, f), ignore=shutil.ignore_patterns('.git'))

		with cd(output):
			# setup with the specified remote
			LOG.debug('Setting up git remote for %s' % chosen_app)

			# remove any previous remote
			try:
				_git('remote', 'rm', 'heroku')
			except WebError:
				pass

			_git('remote', 'add', 'heroku', '[email protected]:%s.git' % chosen_app)

			# commit
			_git('add', '.')
			diff = _git('diff', 'HEAD')
			if not diff.strip():
				# not interactive basically means we're using the trigger toolkit, where 'forge build'
				# doesn't really make sense
				if interactive:
					LOG.warning("No app changes detected: did you forget to forge build?")
				else:
					LOG.warning("No app changes detected, pushing to heroku anyway")
			else:
				_git('commit', '-am', 'forge package web')

			# push
			LOG.info('Deploying to %s.herokuapp.com' % chosen_app)

			# TODO: when running a packaged up toolkit there is no commandline... need to make sure
			# we can use the ssh key earlier somehow and ask for passphrase if not
			# also provide docs on how to use ssh-agent/pageant
			if not interactive:
				LOG.warning('If the packaging process hangs here, you need to set up ssh-agent or Pageant')

			# TODO: show our own one line progress bar when running non-verbosely
			push_output = _git('push', 'heroku', '--all', '--force', command_log_level=logging.INFO)

			if push_output.startswith('Everything up-to-date'):
				remote_output = _git('remote', '-v')
				remote_pattern = re.compile(r'[email protected]:(.*?).git \(fetch\)')

				remote_match = remote_pattern.search(remote_output)
				if remote_match:
					app_url = 'http://%s.herokuapp.com' % remote_match.group(1)
					_open_url(app_url)
					LOG.info('Deployed at %s' % app_url)

			else:
				deploy_pattern = re.compile(r'(http://[^ ]+) deployed to Heroku')
				deploy_match = deploy_pattern.search(push_output)
				if deploy_match:
					_open_url(deploy_match.group(1))
					LOG.info('Deployed at %s' % deploy_match.group(1))
Exemple #7
0
def package_web(build):
    interactive = build.tool_config.get('general.interactive', True)
    development = lib.expand_relative_path(build, 'development/web')
    output = lib.expand_relative_path(build, 'release/web/heroku')

    # deploy to Heroku
    with cd(development):
        api_key = _get_heroku_api_key(build)
        chosen_app = _get_app_to_push_to(build, api_key)

        if not path.isdir(output):
            os.makedirs(output)

        with cd(output):
            if not path.isdir('.git'):
                LOG.debug('Creating git repo')
                _git('init')

                LOG.debug('Create dummy first commit')
                with open('.forge.txt', 'w') as forge_file:
                    forge_file.write('')
                _git('add', '.')
                _git('commit', '-am', 'first commit')

        # remove all previous files/folders except for .git!
        with cd(output):
            for f in os.listdir('.'):
                if not f == '.git':
                    if path.isfile(f):
                        os.remove(f)

                    elif path.isdir(f):
                        shutil.rmtree(f)

        # copy code from development to release!
        with cd(development):
            for f in os.listdir('.'):
                if path.isfile(f):
                    shutil.copy2(f, output)
                elif path.isdir(f) and path.basename(f) != '.git':
                    shutil.copytree(f,
                                    path.join(output, f),
                                    ignore=shutil.ignore_patterns('.git'))

        with cd(output):
            # setup with the specified remote
            LOG.debug('Setting up git remote for %s' % chosen_app)

            # remove any previous remote
            try:
                _git('remote', 'rm', 'heroku')
            except WebError:
                pass

            _git('remote', 'add', 'heroku',
                 '[email protected]:%s.git' % chosen_app)

            # commit
            _git('add', '.')
            diff = _git('diff', 'HEAD')
            if not diff.strip():
                # not interactive basically means we're using the trigger toolkit, where 'forge build'
                # doesn't really make sense
                if interactive:
                    LOG.warning(
                        "No app changes detected: did you forget to forge build?"
                    )
                else:
                    LOG.warning(
                        "No app changes detected, pushing to heroku anyway")
            else:
                _git('commit', '-am', 'forge package web')

            # push
            LOG.info('Deploying to %s.herokuapp.com' % chosen_app)

            # TODO: when running a packaged up toolkit there is no commandline... need to make sure
            # we can use the ssh key earlier somehow and ask for passphrase if not
            # also provide docs on how to use ssh-agent/pageant
            if not interactive:
                LOG.warning(
                    'If the packaging process hangs here, you need to set up ssh-agent or Pageant'
                )

            # TODO: show our own one line progress bar when running non-verbosely
            push_output = _git('push',
                               'heroku',
                               '--all',
                               '--force',
                               command_log_level=logging.INFO)

            if push_output.startswith('Everything up-to-date'):
                remote_output = _git('remote', '-v')
                remote_pattern = re.compile(
                    r'[email protected]:(.*?).git \(fetch\)')

                remote_match = remote_pattern.search(remote_output)
                if remote_match:
                    app_url = 'http://%s.herokuapp.com' % remote_match.group(1)
                    _open_url(app_url)
                    LOG.info('Deployed at %s' % app_url)

            else:
                deploy_pattern = re.compile(
                    r'(http://[^ ]+) deployed to Heroku')
                deploy_match = deploy_pattern.search(push_output)
                if deploy_match:
                    _open_url(deploy_match.group(1))
                    LOG.info('Deployed at %s' % deploy_match.group(1))