jarvis-ci 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,29 @@
3
3
  "port": 5050,
4
4
  "local": false,
5
5
  "proxy": "",
6
- "secret": ""
6
+ "secret": "6e23a467d3acbf3adb29979f1757876d"
7
7
  },
8
- "repos": []
8
+ "repos": [
9
+ {
10
+ "name": "backend",
11
+ "repo": "asdf/sdf",
12
+ "branch": "main",
13
+ "yamlPath": "/home/muqeet-ahmad/Desktop/jarvis-ci/pipelines/backend/backend.jarvis.yaml",
14
+ "tempDir": "/home/muqeet-ahmad/Desktop/jarvis-ci/tmp/asdf-sdf"
15
+ },
16
+ {
17
+ "name": "n",
18
+ "repo": "sdf/sdf",
19
+ "branch": "main",
20
+ "yamlPath": "/home/muqeet-ahmad/Desktop/jarvis-ci/pipelines/n/n.jarvis.yaml",
21
+ "tempDir": "/home/muqeet-ahmad/Desktop/jarvis-ci/tmp/sdf-sdf"
22
+ },
23
+ {
24
+ "name": "asdf",
25
+ "repo": "sd/d",
26
+ "branch": "main",
27
+ "yamlPath": "/home/muqeet-ahmad/Desktop/jarvis-ci/pipelines/asdf/asdf.jarvis.yaml",
28
+ "tempDir": "/home/muqeet-ahmad/Desktop/jarvis-ci/tmp/sd-d"
29
+ }
30
+ ]
9
31
  }
package/dist/bin/cli.js CHANGED
@@ -1,14 +1,30 @@
1
1
  #!/usr/bin/env node
2
+ import path from "path";
2
3
  import { ConfigCommand } from "../commands/config/config.command.js";
3
4
  import { PipelineCommand } from "../commands/pipeline/pipeline.command.js";
4
5
  import { ServerCommand } from "../commands/server/server.command.js";
5
6
  import { Server } from "../server.js";
7
+ import fs from 'fs';
6
8
  export class JarvisCLI {
7
9
  static instance;
8
10
  configCommand;
9
11
  serverCommand;
10
12
  PipelineCommand;
13
+ CONFIG_PATH = path.join(process.cwd(), 'configs');
14
+ baseConfiguration = {
15
+ "server": {
16
+ "port": 5050,
17
+ "local": false,
18
+ "proxy": "",
19
+ "secret": ""
20
+ },
21
+ "repos": []
22
+ };
11
23
  constructor() {
24
+ if (!fs.existsSync(this.CONFIG_PATH)) {
25
+ fs.mkdirSync(this.CONFIG_PATH, { recursive: true });
26
+ fs.writeFileSync(path.join(this.CONFIG_PATH, '.jarvis-ci.json'), JSON.stringify(this.baseConfiguration));
27
+ }
12
28
  this.configCommand = new ConfigCommand();
13
29
  this.serverCommand = new ServerCommand();
14
30
  this.PipelineCommand = new PipelineCommand();
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { ConfigService } from './config.service.js';
4
+ import crypto from 'crypto';
4
5
  export class ConfigCommand {
5
6
  CONFIG_PATH = path.join(process.cwd(), 'configs', '.jarvis-ci.json');
6
7
  configService;
@@ -12,7 +13,7 @@ export class ConfigCommand {
12
13
  const proxyURL = local ? (await this.configService.getProxyURL()).proxy : '';
13
14
  const { githubRepoURL } = await this.configService.getGithubRepo();
14
15
  const { branchName } = await this.configService.getBranchName();
15
- const { webhookSecret } = await this.configService.getWebhookSecret();
16
+ // const { webhookSecret } = await this.configService.getWebhookSecret()
16
17
  const { pipelineName } = await this.configService.getPipelineName();
17
18
  const tempDirPath = this.configService.createTempPipelineDirectory(githubRepoURL);
18
19
  if (!tempDirPath) {
@@ -33,13 +34,19 @@ export class ConfigCommand {
33
34
  };
34
35
  const configFile = fs.readFileSync(this.CONFIG_PATH);
35
36
  let configArray = JSON.parse(configFile.toString());
36
- configArray.server.secret = webhookSecret;
37
+ const webhookSecret = configArray.server.secret !== "" ? configArray.server.secret : crypto.randomBytes(16).toString('hex');
38
+ if (configArray.server.secret !== "") {
39
+ configArray.server.secret = webhookSecret;
40
+ }
37
41
  configArray.server.local = local;
38
42
  if (local) {
39
43
  configArray.server.proxy = proxyURL;
40
44
  }
41
45
  configArray.repos.push(config);
42
46
  fs.writeFileSync(this.CONFIG_PATH, JSON.stringify(configArray, null, 2));
47
+ console.info(`
48
+ The webhook secret is this: ${webhookSecret}
49
+ `);
43
50
  console.log('✅ configuration has been added successfully to .jarvis-ci.json');
44
51
  }
45
52
  loadConfig() {
@@ -13,6 +13,7 @@ export class PipelineCommand {
13
13
  "docker-compose",
14
14
  "ssh",
15
15
  "git",
16
+ "cd",
16
17
  ];
17
18
  configService;
18
19
  CONFIG_PATH = path.join(process.cwd(), 'configs', '.jarvis-ci.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jarvis-ci",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "This npm package is light weight CI/CD tool. the goal is to achieve simplicity and local machine CI/CD execution. it is configured through YAML for commands.",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1 @@
1
+ sdfg
@@ -0,0 +1 @@
1
+ asdfsdf
@@ -0,0 +1 @@
1
+ ljk