def generate_client(self):
        """ Generates the SDK code custom PHP code generator """
        cmd = " ".join([
            'php',
            '-f',
            os.sep.join([self._root_dir, 'src', 'generator', self._config['generators']['php']]),
            os.path.join(self._templates_dir, 'phtml'),
            os.sep.join([self._config_dir, 'swagger-codegen-config.json']),
            self._repo_dir
        ])

        print("Generate PHP client command: " + cmd)

        command = Command(cmd)
        command.run()

        return not command.returned_errors()
    def generate_sdk(self):
        """ Generates the SDK code using the swagger codegen library """
        cmd = ' '.join([
            'java', '-jar', '{swagger_exec}'.format(
                swagger_exec=self._config['repos']['core']['swagger_cli']),
            'generate', '-l', 'csharp', '-i', '{spec_file}'.format(
                spec_file=self._config['repos']['core']['swagger_spec']), '-t',
            '{templates_dir}'.format(
                templates_dir=os.path.join(self._templates_dir, 'mustache')),
            '-c', '{config_file}'.format(config_file=os.path.join(
                self._config_dir, 'swagger-codegen-config.json')), '-o',
            '{sdk_folder}'.format(sdk_folder=self._repo_dir),
            '-DmodelTests=false',
            '--additional-properties packageTitle="Salesforce Marketing Cloud C# SDK"',
            '--additional-properties packageCompany="Salesforce"',
            '--additional-properties packageProductName="Salesforce Marketing Cloud C# SDK"',
            '--additional-properties packageDescription="The Salesforce Marketing Cloud C# SDK"',
            '--additional-properties packageAuthors="Salesforce"',
            '--additional-properties packageCopyright="Copyright Salesforce {year}"'
            .format(year=datetime.now().year)
        ])

        command = Command(cmd)
        command.run()

        print(command.get_output())

        return not command.returned_errors()
    def run_tests(self):
        chdir(self._package_folder)

        # Vars
        config_file = os.sep.join([self._package_folder, 'phpunit.xml.dist'])
        test_suite = ','.join(self._config['repos']['sdk']['tests'])

        # logging the working directory for debug
        print('----- Tests: -----')
        print('Configuration file: ' + config_file)

        # Command to run the unit tests
        cmd = '{phpunit} -c {config_file} --testsuite={testsuite}'.format(
            phpunit=os.sep.join([self._package_folder, os.sep.join(['vendor', 'bin', 'phpunit'])]),
            config_file=config_file,
            testsuite=test_suite
        )

        command = Command(cmd)
        command.run()

        chdir(self._root_dir)  # Get back to previous directory

        if command.returned_errors():
            print('Unit tests FAILED')
            print(command.get_output())
            return 255

        return 0
示例#4
0
    def generate_sdk(self):
        """ Generates the SDK code using the swagger codegen library """
        cmd = ' '.join([
            'java',
            '-jar',
            '{swagger_exec}'.format(swagger_exec=self._config['repos']['core']['swagger_cli']),
            'generate',
            '-l',
            'java',
            '-i',
            '{spec_file}'.format(spec_file=self._config['repos']['core']['swagger_spec']),
            '-t',
            '{templates_dir}'.format(templates_dir=os.path.join(self._templates_dir, 'mustache')),
            '-c',
            '{config_file}'.format(config_file=os.path.join(self._config_dir, 'swagger-codegen-config.json')),
            '-o',
            '{sdk_folder}'.format(sdk_folder=self._repo_dir)
        ])

        command = Command(cmd)
        command.run()

        print(command.get_output())

        return not command.returned_errors()
示例#5
0
    def build_client_generator(self):
        chdir(os.path.join(self._root_dir, 'src', 'generator', self._config['generators']['java']))
        print('Building client generator...')
        cmd = 'mvn package'

        command = Command(cmd)
        command.run()

        print(command.get_output())

        return not command.returned_errors()
    def build_client_generator(self):
        chdir(
            os.path.join(self._root_dir, 'src', 'generator',
                         self._config['generators']['csharp']))
        cmd = 'dotnet build -p:Configuration=Release'

        command = Command(cmd)
        command.run()

        print(command.get_output())

        return not command.returned_errors()
示例#7
0
    def generate_client(self):
        """ Generates the SDK codebase custom Client class """
        chdir(os.path.join(self._root_dir, 'src', 'generator', self._config['generators']['java'], 'target'))

        cmd = 'java -jar {client_generator_jar_name} {java_sdk_api_folder}'.format(
            client_generator_jar_name=self._config['generators']['jarName'],
            java_sdk_api_folder=os.path.join(self._repo_dir, self._config["repos"]["sdk"]["apiFolderPath"]))

        command = Command(cmd)
        command.run()

        print(command.get_output())

        return not command.returned_errors()
    def update_dependencies(self):
        chdir(self._package_folder)

        command = Command('php -f {cli} update'.format(cli=self._config['repos']['core']['composer_cli']))
        command.run()

        chdir(self._root_dir)  # Get back to previous directory

        print('----- Dependencies update log -----')
        print(command.get_output())

        if command.returned_errors():
            return 255

        return 0
    def generate_client(self):
        """ Generates the SDK codebase custom Client class """
        chdir(
            os.path.join(self._root_dir, 'src', 'generator',
                         self._config['generators']['csharp'],
                         self._config['generators']['csharp'], 'bin',
                         'Release', 'netcoreapp2.2'))
        cmd = 'dotnet client-generator.dll generate -l csharp -i {csharp_sdk_api_folder}'.format(
            csharp_sdk_api_folder=os.path.join(
                self._repo_dir, 'src', self._config["repos"]["sdk"]
                ["packageName"], 'Api'))

        command = Command(cmd)
        command.run()

        print(command.get_output())

        return not command.returned_errors()
    def install_dependencies(self):
        chdir(self._package_folder)

        command = Command('php -f {cli} install'.format(cli=self._config['repos']['core']['composer_cli']))
        command.run()

        output = command.get_output()

        chdir(self._root_dir)  # Get back to previous directory

        print('----- Dependencies install log -----')
        print(output)

        if command.returned_errors():
            return 255

        if output.find('You may be getting outdated dependencies. Run update to update them.') != -1:
            return self.update_dependencies()

        return 0
示例#11
0
def validate_spec():
    open_api_spec_path = os.path.join(TRAVIS_BUILD_DIR, 'resources',
                                      'sfmc-openapi-v2.json')
    swagger_codegen_cli_path = os.path.join(TRAVIS_BUILD_DIR, 'bin',
                                            'swagger-codegen-cli.jar')

    cmd = ' '.join([
        'java', '-jar',
        '{swagger_exec}'.format(swagger_exec=swagger_codegen_cli_path),
        'validate', '-i', '{spec_file}'.format(spec_file=open_api_spec_path)
    ])

    command = Command(cmd)
    command.run()

    print(command.get_output())

    if not command.returned_errors():
        return 0
    return 255