Skip to content

Commit

Permalink
Added suggested config file
Browse files Browse the repository at this point in the history
  • Loading branch information
gzukowski committed Jan 3, 2024
1 parent a55e5fa commit 1da0f26
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
23 changes: 11 additions & 12 deletions js/clickup-add-issues/clickupClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { request } from "https";
import { ClientRequest } from "http";
import * as cuSettings from "./cudata.json";

import { IObjectLogger } from "@scramjet/types";

type stringToValue = {
[key: string]: string[];
Expand All @@ -15,25 +15,24 @@ type CuRequestType = {
tags: Array<string>;
}


const tagsMap: stringToValue = {
"transformhub": [],
"cloud-platform-panel" : ["front", "panel"],
// Other entries can be added
};
export class ClickupClient {
listId: string;
token: string;
tagsMap: stringToValue;
logger: IObjectLogger;

constructor(token:string) {
constructor(token: string, config: any, logger: IObjectLogger) {
this.listId = cuSettings.listId;
this.token = token;
console.log(token);
this.tagsMap = config;
this.logger = logger;
this.logger.info(`Read token ${this.token}`);
this.logger.info(`Read config ${JSON.stringify(config)}`);
}
sendRequest(issue :CuRequestType) {
const body = JSON.stringify({
name: issue.name,
tags:tagsMap[issue.source],
tags: this.tagsMap[issue.source] || [],
description: issue.description,
});

Expand All @@ -49,8 +48,8 @@ export class ClickupClient {
};

const req: ClientRequest = request(options, (res) => {
console.log("statusCode:", res.statusCode);
console.log("headers:", res.headers);
this.logger.info(`statusCode: ${res.statusCode}`);
this.logger.info(`headers: ${res.headers}`);

res.on("data", (d) => {
process.stdout.write(d);
Expand Down
3 changes: 2 additions & 1 deletion js/clickup-add-issues/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { ClickupClient } from "./clickupClient";
const mod: (TransformApp | { requires: string, contentType: string})[] = [
{ requires: "issue", contentType: "application/x-ndjson" },
function(input: Streamable<any>, apiKey: string) {
const clickupClient = new ClickupClient(apiKey);
const config = this.config ? this.config : undefined;
const clickupClient = new ClickupClient(apiKey, config, this.logger);

const onError = (error: any) => { console.error(error); };
(input as StringStream)
Expand Down
5 changes: 4 additions & 1 deletion js/git-read-issues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ npm run build:refapps
cd ..
//deploy a compiled package with a parameters
//replace api key with your github api key
si seq deploy git-read-issues.tar.gz --args '["apikey"]'
si seq deploy git-read-issues.tar.gz --args '["apikey"]' // this runs the sequence without any tags specified

si seq deploy git-read-issues.tar.gz --args '["apikey"]' -f path-to-your-config.json // this runs the sequence with the tags specified in the config.json file
//"source" in the sample config.json file defines for which repository specific tags should be set
```

## Clickup-add-issues
Expand Down
5 changes: 5 additions & 0 deletions js/git-read-issues/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"source_1": ["tag1"],
"source_2" : ["tag1", "tag2"]

}
3 changes: 3 additions & 0 deletions js/git-read-issues/src/ghdata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"repos": [
{

"owner": "owner",

"repo": "repo"

}
]
}

0 comments on commit 1da0f26

Please sign in to comment.