Example #1
0
def reload(unhandled_args):
	'''
	Run reload module command
	'''
	if not os.path.isdir(defaults.SRC_DIR):
		raise ForgeError(
			'Source folder "{src}" does not exist - have you run {prog} create yet?'.format(
				src=defaults.SRC_DIR,
				prog=ENTRY_POINT_NAME,
			)
		)
	
	try:
		generate_dynamic = forge_build.import_generate_dynamic()
	except ForgeError:
		# don't have generate_dynamic available yet
		raise ForgeError("Unable to use reload until a build has completed")

	build_to_run = forge_build.create_build(
		"development",
		targets=[],
	)
	generate_dynamic.reload.run_command(
		build_to_run,
		unhandled_args,
	)
Example #2
0
def migrate(unhandled_args):
	'''
	Migrate the app to the next major platform (if possible)
	'''
	if not os.path.isdir(defaults.SRC_DIR):
		raise ForgeError(
			'Source folder "{src}" does not exist - have you run {prog} create yet?'.format(
				src=defaults.SRC_DIR,
				prog=ENTRY_POINT_NAME,
			)
		)
	
	try:
		generate_dynamic = forge_build.import_generate_dynamic()
	except ForgeError:
		# don't have generate_dynamic available yet
		raise ForgeError("Unable to migrate until a build has completed")
	build_to_run = forge_build.create_build(
		"development",
		targets=[],
		extra_args=unhandled_args,
	)
	generate_dynamic.customer_goals.migrate_app(
		generate_dynamic,
		build_to_run,
	)
Example #3
0
def check(unhandled_args):
	'''
	Run basic linting on project JS to save the user some trouble.
	'''
	if not os.path.isdir(defaults.SRC_DIR):
		raise ForgeError(
			'Source folder "{src}" does not exist - have you run {prog} create yet?'.format(
				src=defaults.SRC_DIR,
				prog=ENTRY_POINT_NAME,
			)
		)
	
	try:
		generate_dynamic = forge_build.import_generate_dynamic()
	except ForgeError:
		# don't have generate_dynamic available yet
		LOG.info("Unable to check local settings until a build has completed")
		return
	build_to_run = forge_build.create_build(
		"development",
		targets=[],
		extra_args=unhandled_args,
	)
	generate_dynamic.customer_goals.check_settings(
		generate_dynamic,
		build_to_run,
	)
Example #4
0
	def fetch_instructions(self):
		'''Remove current .template folder and create new one with instructions downloaded

		*N.B.* Assumes working directory is the app dir
		'''
		remote = Remote(self._config)

		temp_dir = None
		try:
			temp_dir = tempfile.mkdtemp(prefix="forge-templates-")
			temp_templates_dir = path.join(temp_dir, self._tmpl_dir)
			temp_instructions_dir = path.join(temp_dir, self._instructions_dir)
			final_templates_dir = self._tmpl_dir

			remote.fetch_generate_instructions(temp_instructions_dir)

			lib.set_file_as_hidden(final_templates_dir)

			# copy config.json across to be compared to next time
			shutil.copy(
					defaults.APP_CONFIG_FILE,
					path.join(temp_templates_dir, "config.json"))

			# XXX: assumption here that instructions dir is inside of
			# the templates dir (currently it is the same)
			# remove old templates
			LOG.info('Removing old templates if present')
			LOG.debug('Removing %s ' % final_templates_dir)
			shutil.rmtree(final_templates_dir, ignore_errors=True)

			LOG.info('Using new templates')
			LOG.debug('Moving %s to %s' % (temp_templates_dir, final_templates_dir))
			shutil.move(temp_templates_dir, final_templates_dir)

			# invalidate any caching of previous generate_dynamic module after
			# fetching templates
			# XXX: might make more sense to just force do_reload=True on every import and
			# get rid of this?
			import_generate_dynamic(do_reload=True)
		finally:
			if temp_dir:
				shutil.rmtree(temp_dir, ignore_errors=True)
    def all(self, target_dir, user_dir, extra_args, config, target):
        """Re-create all local files in built targets

		:param target_dir: the parent directory of the per-platform builds
		:param user_dir: the directory holding user's code
		"""
        generate_dynamic = import_generate_dynamic()
        build_to_run = create_build(target_dir, config=config, extra_args=extra_args, targets=[target])

        generate_dynamic.customer_goals.generate_app_from_template(
            generate_module=generate_dynamic, build_to_run=build_to_run
        )
Example #6
0
def package(unhandled_args):
	#TODO: ensure dev build has been done first (probably lower down?)
	generate_dynamic = forge_build.import_generate_dynamic()
	build_type_dir = 'development'
	build_to_run = forge_build.create_build(
		build_type_dir,
		targets=[forge.settings['platform']],
		extra_args=unhandled_args,
	)

	generate_dynamic.customer_goals.package_app(
		generate_module=generate_dynamic,
		build_to_run=build_to_run,
	)
Example #7
0
def run(unhandled_args):
	_check_working_directory_is_safe()
	build_type_dir = 'development'
	_assert_have_development_folder()
	_assert_have_target_folder(build_type_dir, forge.settings['platform'])

	generate_dynamic = forge_build.import_generate_dynamic()

	build_to_run = forge_build.create_build(
		build_type_dir,
		targets=[forge.settings['platform']],
		extra_args=unhandled_args,
	)

	generate_dynamic.customer_goals.run_app(
		generate_module=generate_dynamic,
		build_to_run=build_to_run,
	)
Example #8
0
	def need_new_templates_for_config(self):
		'''Determine whether we have current templates for the user's configuration.
		
		:rtype: bool
		'''
		if not path.isdir(self._tmpl_dir):
			LOG.debug("{tmpl} is not a directory: don't have templates".format(tmpl=self._tmpl_dir))
			return True
		old_config_filename = path.join(self._tmpl_dir, "config.json")
		if not path.isfile(old_config_filename):
			LOG.debug("{file} does not exist: we need to fetch new templates".format(
				file=old_config_filename))
			return True
		
		generate_dynamic = import_generate_dynamic()
		return generate_dynamic.internal_goals.config_changes_invalidate_templates(
				generate=generate_dynamic,
				old_config_filename=old_config_filename,
				new_config_filename=defaults.APP_CONFIG_FILE,
		)