Skip to content

Commit d03fc06

Browse files
author
Luke Goodfellow
committed
add contributions, updated format style, and applied style
1 parent 2c99bfc commit d03fc06

File tree

5 files changed

+220
-182
lines changed

5 files changed

+220
-182
lines changed

.devcontainer/devcontainer.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// For format details, see https://aka.ms/devcontainer.json.
22
{
3-
"name": "Codefresh Support Package",
4-
"image": "denoland/deno:1.39.1",
5-
"onCreateCommand": "apt-get update && apt-get install git zip -y",
6-
"mounts": [
7-
"type=bind,source=${localEnv:HOME}/.ssh,target=/root/.ssh,readonly"
8-
],
9-
"customizations": {
10-
"vscode": {
11-
"settings": {
12-
"deno.enable": true,
13-
"deno.lint": true,
14-
"deno.unstable": false
15-
},
16-
"extensions": [
17-
"denoland.vscode-deno",
18-
"davidanson.vscode-markdownlint"
19-
]
20-
}
3+
"name": "Codefresh Support Package",
4+
"image": "denoland/deno:1.39.1",
5+
"onCreateCommand": "apt-get update && apt-get install git zip -y",
6+
"mounts": [
7+
"type=bind,source=${localEnv:HOME}/.ssh,target=/root/.ssh,readonly"
8+
],
9+
"customizations": {
10+
"vscode": {
11+
"settings": {
12+
"deno.enable": true,
13+
"deno.lint": true,
14+
"deno.unstable": false
15+
},
16+
"extensions": [
17+
"denoland.vscode-deno",
18+
"davidanson.vscode-markdownlint"
19+
]
2120
}
21+
}
2222
}

CONTRIBUTIONS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Contributing to Our Project
2+
3+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4+
5+
- Fixing a bug
6+
- Proposing new features
7+
- Correct misspellings
8+
- etc.
9+
10+
## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
11+
12+
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
13+
14+
1. Fork the repo and create your branch from `main`.
15+
2. If you've added code that should be tested, add tests.
16+
3. If you've changed APIs, update the documentation.
17+
4. Ensure the test suite passes.
18+
5. Make sure your code lints.
19+
6. Issue that pull request!
20+
21+
## Any contributions you make will be under the MIT Software License
22+
23+
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
24+
25+
## Development
26+
27+
- We utilize Dev Containers for development and VS Code as our IDE.
28+
- VSCode extension is `ms-vscode-remote.remote-containers`.
29+
- Docker needs to be installed to run the containers.
30+
- If extensions are stuck on installing utilize `ctrl + shift + p` and utilize `Developer: Reload Window` command.
31+
- 2 spaces for indentation rather than tabs.
32+
- You can try running `deno lint` && `deno fmt` for style unification.
33+
- suggest running this command under `/src`.
34+
- Update [VERSIONS](./VERSION) file when you need a new release version.
35+
36+
## License
37+
38+
By contributing, you agree that your contributions will be licensed under its MIT License.

deno.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"fmt": {
3-
"indentWidth": 4,
4-
"lineWidth": 160,
5-
"singleQuote": true,
6-
"semiColons": true
7-
},
8-
"tasks": {
9-
"pre-compile": "rm -rf ./bin && mkdir ./bin",
10-
"compile:linux": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_linux_x86_64 --target=x86_64-unknown-linux-gnu ./src/main.js",
11-
"compile:windows": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_windows_x86_64 --target=x86_64-pc-windows-msvc ./src/main.js",
12-
"compile:apple_x86_64": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_darwin_x86_64 --target=x86_64-apple-darwin ./src/main.js",
13-
"compile:apple_arm64": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_darwin_arm64 --target=aarch64-apple-darwin ./src/main.js",
14-
"compile": "deno task pre-compile && deno task compile:linux && deno task compile:windows && deno task compile:apple_x86_64 && deno task compile:apple_arm64"
15-
}
2+
"fmt": {
3+
"indentWidth": 2,
4+
"lineWidth": 160,
5+
"singleQuote": true,
6+
"semiColons": true
7+
},
8+
"tasks": {
9+
"pre-compile": "rm -rf ./bin && mkdir ./bin",
10+
"compile:linux": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_linux_x86_64 --target=x86_64-unknown-linux-gnu ./src/main.js",
11+
"compile:windows": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_windows_x86_64 --target=x86_64-pc-windows-msvc ./src/main.js",
12+
"compile:apple_x86_64": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_darwin_x86_64 --target=x86_64-apple-darwin ./src/main.js",
13+
"compile:apple_arm64": "deno compile --config=./deno.json --allow-env --allow-read --allow-write=./ --allow-net --allow-run --output=./bin/cf-support_darwin_arm64 --target=aarch64-apple-darwin ./src/main.js",
14+
"compile": "deno task pre-compile && deno task compile:linux && deno task compile:windows && deno task compile:apple_x86_64 && deno task compile:apple_arm64"
15+
}
1616
}

src/codefresh.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,57 @@
22
import { parse } from 'https://deno.land/[email protected]/yaml/mod.ts';
33

44
class Codefresh {
5-
async init() {
6-
this.apiKey = await this.getEnvVarOrConfig('CF_API_KEY', 'token');
7-
this.apiURL = await this.getEnvVarOrConfig('CF_URL', 'url');
5+
async init() {
6+
this.apiKey = await this.getEnvVarOrConfig('CF_API_KEY', 'token');
7+
this.apiURL = await this.getEnvVarOrConfig('CF_URL', 'url');
88

9-
this.headers = {
10-
Authorization: this.apiKey,
11-
};
12-
this.baseURL = this.apiURL + `/api`;
13-
}
9+
this.headers = {
10+
Authorization: this.apiKey,
11+
};
12+
this.baseURL = this.apiURL + `/api`;
13+
}
1414

15-
async getEnvVarOrConfig(envVar, configKey) {
16-
if (Deno.env.has(envVar)) {
17-
return Deno.env.get(envVar);
15+
async getEnvVarOrConfig(envVar, configKey) {
16+
if (Deno.env.has(envVar)) {
17+
return Deno.env.get(envVar);
18+
} else {
19+
try {
20+
let cfConfig;
21+
if (Deno.build.os === 'windows') {
22+
cfConfig = parse(await Deno.readTextFile(`${Deno.env.get('USERPROFILE')}/.cfconfig`));
1823
} else {
19-
try {
20-
let cfConfig;
21-
if (Deno.build.os === 'windows') {
22-
cfConfig = parse(await Deno.readTextFile(`${Deno.env.get('USERPROFILE')}/.cfconfig`));
23-
} else {
24-
cfConfig = parse(await Deno.readTextFile(`${Deno.env.get('HOME')}/.cfconfig`));
25-
}
26-
27-
return cfConfig.contexts[cfConfig['current-context']][configKey];
28-
} catch (error) {
29-
console.error(error);
30-
}
24+
cfConfig = parse(await Deno.readTextFile(`${Deno.env.get('HOME')}/.cfconfig`));
3125
}
26+
27+
return cfConfig.contexts[cfConfig['current-context']][configKey];
28+
} catch (error) {
29+
console.error(error);
30+
}
3231
}
32+
}
3333

34-
async getAllRuntimes() {
35-
try {
36-
const response = await fetch(`${this.baseURL}/runtime-environments`, {
37-
method: 'GET',
38-
headers: this.headers,
39-
});
40-
const runtimes = await response.json();
41-
this.runtimes = runtimes;
42-
return runtimes.map((re) => re.metadata.name);
43-
} catch (error) {
44-
console.error(error);
45-
}
34+
async getAllRuntimes() {
35+
try {
36+
const response = await fetch(`${this.baseURL}/runtime-environments`, {
37+
method: 'GET',
38+
headers: this.headers,
39+
});
40+
const runtimes = await response.json();
41+
this.runtimes = runtimes;
42+
return runtimes.map((re) => re.metadata.name);
43+
} catch (error) {
44+
console.error(error);
4645
}
46+
}
4747

48-
getRuntimeInfo(name) {
49-
try {
50-
const runtime = this.runtimes.find((re) => re.metadata.name === name);
51-
return runtime;
52-
} catch (error) {
53-
console.error(error);
54-
}
48+
getRuntimeInfo(name) {
49+
try {
50+
const runtime = this.runtimes.find((re) => re.metadata.name === name);
51+
return runtime;
52+
} catch (error) {
53+
console.error(error);
5554
}
55+
}
5656
}
5757

5858
export { Codefresh };

0 commit comments

Comments
 (0)