예제 #1
0
 def install(self, bit_download):
     bit_directory = f'bits/{bit_download.bit_name}'
     if filesystem.directory_exists(bit_directory):
         filesystem.remove_directory(bit_directory)
     filesystem.create_directory(bit_directory)
     filesystem.unzips(base64.b64decode(bit_download.payload),
                       bit_directory)
예제 #2
0
 def build_tests(self, project, files_or_dirs):
     if not filesystem.directory_exists(constants.BUILD_DIRECTORY):
         filesystem.create_directory(constants.BUILD_DIRECTORY)
     if not files_or_dirs:
         self.__build_tests(project, ['tests'])
     else:
         tests_to_run = self.tests_from_args(project, files_or_dirs)
         self.__build_tests(project, [test.name for test in tests_to_run])
예제 #3
0
 def __copy_mains(self, build_directory, project_descriptor):
     for target, description in project_descriptor.targets.items():
         relative_path_from_root = filesystem.path_to(description.main)
         if relative_path_from_root:
             filesystem.create_directory(
                 f'{build_directory}/{relative_path_from_root}')
         filesystem.copy_file(
             description.main,
             f'{build_directory}/{relative_path_from_root}')
예제 #4
0
 def add_test(self, file_name, fails=False):
     if not filesystem.directory_exists('tests'):
         filesystem.create_directory('tests')
     expect = 'false' if fails else 'true'
     filesystem.create_file(
         f'tests/{file_name}', '#include <cest/cest.h>\n'
         'using namespace cest;\n'
         'describe("Test Case", []() {\n'
         '    it("passes", []() {\n'
         f'        expect(true).toBe({expect});\n'
         '    });\n'
         '});\n')
예제 #5
0
    def pack(self, project_descriptor, build_directory):
        if filesystem.directory_exists(build_directory):
            raise FailedToPackageTemplate(cause='build directory exists')

        filesystem.create_directory(build_directory)
        filesystem.copy_file(PROJECT_DESCRIPTOR_FILE,
                             f'{build_directory}/project.yaml')
        self.__copy_packages(build_directory, project_descriptor)
        self.__copy_mains(build_directory, project_descriptor)
        self.__copy_dockerfiles(build_directory, project_descriptor)
        filesystem.zip(build_directory, f'{project_descriptor.name}')
        filesystem.remove_directory(build_directory)

        return f'{project_descriptor.name}.zip'
예제 #6
0
    def pack(self, project_descriptor, build_directory):
        if not project_descriptor.build_packages():
            raise PackagingFailure(cause='project contains no packages')

        if filesystem.directory_exists(build_directory):
            raise PackagingFailure(cause='build directory exists')

        filesystem.create_directory(build_directory)
        filesystem.copy_file(PROJECT_DESCRIPTOR_FILE,
                             f'{build_directory}/project.yaml')
        for package in project_descriptor.build_packages():
            filesystem.copy_directory(package.path,
                                      f'{build_directory}/{package.path}')
        filesystem.zip(build_directory, f'{project_descriptor.name}')
        filesystem.remove_directory(build_directory)

        return f'{project_descriptor.name}.zip'
예제 #7
0
 def build(self, project):
     if not filesystem.directory_exists(constants.BUILD_DIRECTORY):
         filesystem.create_directory(constants.BUILD_DIRECTORY)
     self.__build(project, [project.name], post_build=self.__post_build(project))
예제 #8
0
 def install(self, template_download, directory):
     if filesystem.directory_exists(directory):
         raise UnableToInstallTemplate
     filesystem.create_directory(directory)
     filesystem.unzips(base64.b64decode(template_download.payload), directory)
예제 #9
0
 def build(self, project, target_name):
     if not filesystem.directory_exists(constants.BUILD_DIRECTORY):
         filesystem.create_directory(constants.BUILD_DIRECTORY)
     self.__build(project, target_name, [project.name])
예제 #10
0
 def create_project_directory(self, project_name):
     filesystem.create_directory(project_name)