Skip to content

Commit

Permalink
Merge pull request #7236 from NipunaRanasinghe/main
Browse files Browse the repository at this point in the history
Improve connector template workflow
  • Loading branch information
NipunaRanasinghe authored Oct 7, 2024
2 parents 5d77128 + 730c95a commit 9ae53e2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/apply-library-repo-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ on:
workflow_dispatch:
inputs:
template_type:
description: 'Template type'
description: 'Select the type of template to apply to the target repository.'
default: 'Generated Connector Template (Standard)'
type: choice
options:
- Generated Connector Template (Standard)
target_repo:
description: 'Target repository to apply the template'
description: 'The repository where the selected template will be applied.'
required: true
example: 'module-ballerinax-openai.chat'
module_name:
description: 'Module name of the library used in Ballerina.toml'
description: 'The module name as defined in the Ballerina.toml file.'
required: true
example: 'openai.chat'
ballerina_version:
description: 'Compatible Ballerina version to be used for the library'
description: 'The Ballerina version that the library should be compatible with.'
required: true
example: '2201.9.0'
module_version:
description: 'Library module version'
description: 'The version number of the library module.'
required: true
default: '0.1.0'
example: '1.0.0'
target_branch:
description: 'Target branch'
description: 'The branch in the target repository where changes will be applied.'
required: false
default: 'main'
library_name:
description: 'Descriptive name of the library to be used in the documentation (If not provided, module name will be used)'
description: 'A descriptive name for the library, used in the documentation. If not provided, the module name will be used instead.'
required: false
example: 'OpenAI Chat'
default: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/ci.yml)
[![Trivy](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/trivy-scan.yml)
[![GraalVM Check](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/build-with-bal-test-native.yml)
[![GraalVM Check](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/{{REPO_NAME}}/actions/workflows/build-with-bal-test-graalvm.yml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/{{REPO_NAME}}.svg)](https://github.com/ballerina-platform/{{REPO_NAME}}/commits/master)
[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/{{MODULE_NAME_CC}}.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%{{MODULE_NAME_CC}})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Examples

The `ballerinax/{{MODULE_NAME_CC}}` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-{{MODULE_NAME_CC}}/tree/main/examples), covering use cases like cache management, session management, and rate limiting.
The `ballerinax/{{MODULE_NAME_CC}}` connector provides practical examples illustrating usage in various scenarios.

[//]: # (TODO: Add examples)
1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ import ballerina/lang.regexp;
import ballerina/log;
import ballerina/time;

// Define the file extensions that are considered as template files
public type TemplateFileExt "bal"|"md"|"json"|"yaml"|"yml"|"toml"|"gradle"|"properties"|"gitignore"|"txt";
// Define file extensions to be accepted as template files
public type TemplateFileType "bal"|"md"|"json"|"yaml"|"yml"|"toml"|"gradle"|"properties"|"gitignore"|"txt"|"jar"|"sh"|"bat"|"LICENSE"|"CODEOWNERS";

# This function generates a connector template with the given metadata.
#
# + path - The relative path to the directory where the connector template is located
# + moduleName - The name of the module to be used the `Ballerina.toml` file and the Ballerina central
# + repoName - The name of the repository to be used in the `Ballerina.toml` file
# + moduleVersion - The version of the module to be used in the `Ballerina.toml` file
# + balVersion - The Ballerina version to be used
# + connectorName - The descriptive name of the connector to be used in the generated files
# + return - An error if an error occurs while generating the connector template
public function main(string path, string moduleName, string repoName, string moduleVersion, string balVersion, string connectorName) returns error? {
log:printInfo("Generating connector template with the following metadata:");
log:printInfo("Module Name: " + moduleName);
Expand Down Expand Up @@ -57,7 +66,7 @@ function processDirectory(string dir, map<string> placeholders) returns error? {

function processFile(string filePath, map<string> placeholders) returns error? {
string ext = getExtension(filePath);
if ext !is TemplateFileExt {
if ext !is TemplateFileType {
log:printInfo("Skipping file: " + filePath);
return;
}
Expand Down

0 comments on commit 9ae53e2

Please sign in to comment.