@docupace/pipeline 1.0.43 → 1.0.45

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.
package/next/sonar.sh CHANGED
@@ -1,23 +1,23 @@
1
- #!/bin/bash
2
-
3
- # Initialize sonar-scanner command with common parameters
4
- SONAR_CMD="npx sonarqube-scanner"
5
-
6
- echo "PR_ID=$PR_ID"
7
- echo "BRANCH=$BRANCH"
8
- echo "PR_DESTINATION_BRANCH=$PR_DESTINATION_BRANCH"
9
-
10
- # Determine the type of scan based on environment variables
11
- if [[ ! -z "$PR_ID" ]]; then
12
- SONAR_CMD+=" \
13
- -Dsonar.pullrequest.key=$PR_ID \
14
- -Dsonar.pullrequest.branch=$BRANCH \
15
- -Dsonar.pullrequest.base=$PR_DESTINATION_BRANCH"
16
- else
17
- SONAR_CMD+=" \
18
- -Dsonar.branch.name=$BRANCH"
19
- fi
20
-
21
- # Execute the sonar-scanner command
22
- echo "Running: $SONAR_CMD"
23
- $SONAR_CMD
1
+ #!/bin/bash
2
+
3
+ # Initialize sonar-scanner command with common parameters
4
+ SONAR_CMD="npx sonarqube-scanner"
5
+
6
+ echo "PR_ID=$PR_ID"
7
+ echo "BRANCH=$BRANCH"
8
+ echo "PR_DESTINATION_BRANCH=$PR_DESTINATION_BRANCH"
9
+
10
+ # Determine the type of scan based on environment variables
11
+ if [[ ! -z "$PR_ID" ]]; then
12
+ SONAR_CMD+=" \
13
+ -Dsonar.pullrequest.key=$PR_ID \
14
+ -Dsonar.pullrequest.branch=$BRANCH \
15
+ -Dsonar.pullrequest.base=$PR_DESTINATION_BRANCH"
16
+ else
17
+ SONAR_CMD+=" \
18
+ -Dsonar.branch.name=$BRANCH"
19
+ fi
20
+
21
+ # Execute the sonar-scanner command
22
+ echo "Running: $SONAR_CMD"
23
+ $SONAR_CMD
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env bash
2
+
3
+ TARGET_BRANCH="INFP-10599-create-new-build-agent-runner-in-uat"
4
+
5
+ TEMPERATURE=${TEMPERATURE:-1}
6
+ MAX_TOKENS=${MAX_TOKENS:-512}
7
+ MODEL=${MODEL:-"gemma3:27b"}
8
+ INTRO=${INTRO:-"Summarize the changes introduced in this commit message, focusing on the files modified."}
9
+ OLLAMA_ENDPOINT=${OLLAMA_ENDPOINT:-"http://10.10.22.111:11434/v1/completions"}
10
+
11
+ # Get a list of staged files
12
+ changed_files=$(git diff --cached --name-only)
13
+ diff_messages=""
14
+
15
+ for file in $changed_files; do
16
+ diff_messages+="$(git diff --cached -- "$file")"
17
+ done
18
+
19
+ payload=$(jq -n \
20
+ --arg model "$MODEL" \
21
+ --arg prompt "$(
22
+ echo "$INTRO";
23
+ echo "$diff_messages"
24
+ )" \
25
+ --argjson temp "$TEMPERATURE" \
26
+ --argjson tokens "$MAX_TOKENS" \
27
+ '{
28
+ model: $model,
29
+ prompt: $prompt,
30
+ temperature: $temp,
31
+ max_tokens: $tokens
32
+ }'
33
+ )
34
+
35
+ response=$(curl -s -X POST "$OLLAMA_ENDPOINT" \
36
+ -H "Content-Type: application/json" \
37
+ -d "$payload")
38
+
39
+ echo "$payload" | jq . > /tmp/ollama-summary.json
40
+ echo "$response" | jq . >> /tmp/ollama-summary.json
41
+
42
+ echo "$response" | jq -r '.choices[0].text' | sed '/./,$!d'
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ TARGET_BRANCH=master
4
+
5
+ TEMPERATURE=${TEMPERATURE:-1}
6
+ MAX_TOKENS=${MAX_TOKENS:-512}
7
+ MODEL=${MODEL:-"gemma3:27b"}
8
+ INTRO=${INTRO:-"Write a summary of the commits in this pull request"}
9
+ OLLAMA_ENDPOINT=${OLLAMA_ENDPOINT:-"http://10.10.22.111:11434/v1/completions"}
10
+
11
+ payload=$(jq -n \
12
+ --arg model "$MODEL" \
13
+ --arg prompt "$(
14
+ echo "$INTRO";
15
+ git log origin/$TARGET_BRANCH --format='%B';
16
+ )" \
17
+ --argjson temp "$TEMPERATURE" \
18
+ --argjson tokens "$MAX_TOKENS" \
19
+ '{
20
+ model: $model,
21
+ prompt: $prompt,
22
+ temperature: $temp,
23
+ max_tokens: $tokens
24
+ }'
25
+ )
26
+
27
+ response=$(curl -s -X POST "$OLLAMA_ENDPOINT" \
28
+ -H "Content-Type: application/json" \
29
+ -d "$payload")
30
+
31
+ echo "$payload" | jq . > /tmp/ollama-summary.json
32
+ echo "$response" | jq . >> /tmp/ollama-summary.json
33
+
34
+ echo "$response" | jq -r '.choices[0].text' | sed '/./,$!d'
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ TARGET_BRANCH=master
5
+ TEMPERATURE=${TEMPERATURE:-1}
6
+ MAX_TOKENS=${MAX_TOKENS:-512}
7
+ MODEL=${MODEL:-"gemma3:27b"}
8
+ INTRO=${INTRO:-"Below are some commit messages. Write a one sentence summary of them."}
9
+
10
+ LLM_ENDPOINT=${LLM_ENDPOINT:-"http://10.10.22.111:11434/v1/completions"} # Ollama or LocalAI
11
+
12
+ function num_commits {
13
+ git log origin/$TARGET_BRANCH --oneline | wc -l
14
+ }
15
+
16
+ function single_commit_title {
17
+ git log origin/$TARGET_BRANCH --format='%s' | head -1
18
+ }
19
+
20
+ function multi_commit_title {
21
+ prompt="$(
22
+ echo "$INTRO"
23
+ git log origin/$TARGET_BRANCH --format='%B'
24
+ )"
25
+
26
+ payload=$(jq -n \
27
+ --arg model "$MODEL" \
28
+ --arg prompt "$prompt" \
29
+ --argjson temp "$TEMPERATURE" \
30
+ --argjson tokens "$MAX_TOKENS" \
31
+ '{
32
+ model: $model,
33
+ prompt: $prompt,
34
+ temperature: $temp,
35
+ max_tokens: $tokens
36
+ }')
37
+
38
+ response=$(curl -s -X POST "$LLM_ENDPOINT" \
39
+ -H "Content-Type: application/json" \
40
+ -d "$payload")
41
+
42
+ echo "$payload" | jq . > /tmp/llama-title.json
43
+ echo "$response" | jq . >> /tmp/llama-title.json
44
+
45
+ error_message=$(echo "$response" | jq -r '.error.message // empty')
46
+ if [[ -n "$error_message" ]]; then
47
+ echo "LLM API error: $error_message"
48
+ exit 1
49
+ fi
50
+
51
+ echo "$response" | jq -r '.choices[0].text' | sed '/./,$!d' | head -1
52
+ }
53
+
54
+ function main {
55
+ if [ "$(num_commits)" -eq 0 ]; then
56
+ echo "Error: No commits found on branch origin/$TARGET_BRANCH."
57
+ exit 1
58
+ fi
59
+ if [ "$(num_commits)" -eq 1 ]; then
60
+ single_commit_title
61
+ else
62
+ multi_commit_title
63
+ fi
64
+ }
65
+
66
+ main
@@ -1,72 +1,72 @@
1
- import axios from 'axios';
2
-
3
- import { createAlias } from '../next/alias.js';
4
-
5
- import { getAuth0AuthToken } from './configure.js';
6
-
7
- import { getVaultSecrets } from './vault.js';
8
-
9
- import { getVaultSecretsConfigs } from '../next/config.js';
10
-
11
- import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
12
-
13
- export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
14
- console.log(`Forming alias name for application ${application}...`);
15
-
16
- try {
17
- const auth0Response = await axios.get(
18
- `https://${auth0Domain}/api/v2/clients`,
19
- {
20
- headers: { authorization: `Bearer ${auth0AuthToken}` },
21
- },
22
- );
23
-
24
- const appAuth0ClientIdData = auth0Response.data.find(
25
- (client) => client.name === `${application}`,
26
- );
27
- const appAuth0ClientId = appAuth0ClientIdData.client_id;
28
-
29
- console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
30
- return `${appAuth0ClientId}@clients`;
31
- } catch (err) {
32
- console.error(
33
- `Failed to form alias name for application: ${application}: ${err.message}`,
34
- );
35
- }
36
- }
37
-
38
- export async function configureAlias(site, env, username, password, realm) {
39
- console.log(`Creating alias for site: ${site} in env: ${env}`);
40
- // Site Common Secrets
41
- const siteCommonSecretsPath =
42
- getVaultSecretsConfigs(site).siteCommonSecretsPath;
43
- console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
44
- const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
45
-
46
- const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
47
- const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
48
- const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
49
- const auth0Token = await getAuth0AuthToken(
50
- auth0Domain,
51
- auth0ClientId,
52
- auth0ClientSecret,
53
- );
54
-
55
- await cloneEnvRepository(env);
56
-
57
- const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
58
- 'graphql-server',
59
- env,
60
- site,
61
- 'values',
62
- );
63
- const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
64
-
65
- const clientCredentialsAlias = await getCCAlias({
66
- application: 'docupace-graphql-client-credentials',
67
- auth0Domain: auth0Domain,
68
- auth0AuthToken: auth0Token,
69
- });
70
-
71
- await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
72
- }
1
+ import axios from 'axios';
2
+
3
+ import { createAlias } from '../next/alias.js';
4
+
5
+ import { getAuth0AuthToken } from './configure.js';
6
+
7
+ import { getVaultSecrets } from './vault.js';
8
+
9
+ import { getVaultSecretsConfigs } from '../next/config.js';
10
+
11
+ import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
12
+
13
+ export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
14
+ console.log(`Forming alias name for application ${application}...`);
15
+
16
+ try {
17
+ const auth0Response = await axios.get(
18
+ `https://${auth0Domain}/api/v2/clients`,
19
+ {
20
+ headers: { authorization: `Bearer ${auth0AuthToken}` },
21
+ },
22
+ );
23
+
24
+ const appAuth0ClientIdData = auth0Response.data.find(
25
+ (client) => client.name === `${application}`,
26
+ );
27
+ const appAuth0ClientId = appAuth0ClientIdData.client_id;
28
+
29
+ console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
30
+ return `${appAuth0ClientId}@clients`;
31
+ } catch (err) {
32
+ console.error(
33
+ `Failed to form alias name for application: ${application}: ${err.message}`,
34
+ );
35
+ }
36
+ }
37
+
38
+ export async function configureAlias(site, env, username, password, realm) {
39
+ console.log(`Creating alias for site: ${site} in env: ${env}`);
40
+ // Site Common Secrets
41
+ const siteCommonSecretsPath =
42
+ getVaultSecretsConfigs(site).siteCommonSecretsPath;
43
+ console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
44
+ const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
45
+
46
+ const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
47
+ const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
48
+ const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
49
+ const auth0Token = await getAuth0AuthToken(
50
+ auth0Domain,
51
+ auth0ClientId,
52
+ auth0ClientSecret,
53
+ );
54
+
55
+ await cloneEnvRepository(env);
56
+
57
+ const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
58
+ 'graphql-server',
59
+ env,
60
+ site,
61
+ 'values',
62
+ );
63
+ const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
64
+
65
+ const clientCredentialsAlias = await getCCAlias({
66
+ application: 'docupace-graphql-client-credentials',
67
+ auth0Domain: auth0Domain,
68
+ auth0AuthToken: auth0Token,
69
+ });
70
+
71
+ await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
72
+ }
package/src/auth0/cli.js CHANGED
@@ -1,76 +1,76 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import { configureFromSite } from './configure.js';
5
- import { getVaultSecrets } from './vault.js';
6
-
7
- import dotenv from 'dotenv';
8
- import { configureAlias } from './alias.js';
9
- import { exportConf } from './export.js';
10
- import { getAuth0Metadata } from './metadata.js';
11
-
12
- dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
13
-
14
- const program = new Command();
15
-
16
- program
17
- .command(
18
- 'configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain> <useS3> <deployCCUI>',
19
- )
20
- .description('Configure the Auth0 tenants in env for the given site')
21
- .action(
22
- async (
23
- fromSite,
24
- toSite,
25
- fromEnv,
26
- toEnv,
27
- deployUI,
28
- deployGraphQLServer,
29
- useNewDomain,
30
- useS3,
31
- deployCCUI,
32
- ) => {
33
- await configureFromSite(
34
- fromSite,
35
- toSite,
36
- fromEnv,
37
- toEnv,
38
- deployUI,
39
- deployGraphQLServer,
40
- useNewDomain,
41
- useS3 === 'true' || useS3 === true,
42
- deployCCUI,
43
- );
44
- },
45
- );
46
-
47
- program
48
- .command('getVaultSecrets <vaultPath>')
49
- .description('Get Secrets for Vault PATH')
50
- .action(async (vaultPath) => {
51
- const data = await getVaultSecrets(vaultPath);
52
- console.log(JSON.stringify(data, 'null', 2));
53
- });
54
-
55
- program
56
- .command('configureAlias <site> <env> <username> <password> <realm>')
57
- .description('Configure Core Alias for the given site')
58
- .action(async (site, env, username, password, realm) => {
59
- await configureAlias(site, env, username, password, realm);
60
- });
61
-
62
- program
63
- .command('exportConf <site> <env>')
64
- .description('Export Auth0 configuration for the given site')
65
- .action(async (site, env) => {
66
- await exportConf(site, env);
67
- });
68
-
69
- program
70
- .command('getAuth0Metadata <site> <env>')
71
- .description('Get Auth0 metadata for the given site')
72
- .action(async (site, env) => {
73
- await getAuth0Metadata(site, env);
74
- });
75
-
76
- program.parse(process.argv);
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import { configureFromSite } from './configure.js';
5
+ import { getVaultSecrets } from './vault.js';
6
+
7
+ import dotenv from 'dotenv';
8
+ import { configureAlias } from './alias.js';
9
+ import { exportConf } from './export.js';
10
+ import { getAuth0Metadata } from './metadata.js';
11
+
12
+ dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
13
+
14
+ const program = new Command();
15
+
16
+ program
17
+ .command(
18
+ 'configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain> <useS3> <deployCCUI>',
19
+ )
20
+ .description('Configure the Auth0 tenants in env for the given site')
21
+ .action(
22
+ async (
23
+ fromSite,
24
+ toSite,
25
+ fromEnv,
26
+ toEnv,
27
+ deployUI,
28
+ deployGraphQLServer,
29
+ useNewDomain,
30
+ useS3,
31
+ deployCCUI,
32
+ ) => {
33
+ await configureFromSite(
34
+ fromSite,
35
+ toSite,
36
+ fromEnv,
37
+ toEnv,
38
+ deployUI,
39
+ deployGraphQLServer,
40
+ useNewDomain,
41
+ useS3 === 'true' || useS3 === true,
42
+ deployCCUI,
43
+ );
44
+ },
45
+ );
46
+
47
+ program
48
+ .command('getVaultSecrets <vaultPath>')
49
+ .description('Get Secrets for Vault PATH')
50
+ .action(async (vaultPath) => {
51
+ const data = await getVaultSecrets(vaultPath);
52
+ console.log(JSON.stringify(data, 'null', 2));
53
+ });
54
+
55
+ program
56
+ .command('configureAlias <site> <env> <username> <password> <realm>')
57
+ .description('Configure Core Alias for the given site')
58
+ .action(async (site, env, username, password, realm) => {
59
+ await configureAlias(site, env, username, password, realm);
60
+ });
61
+
62
+ program
63
+ .command('exportConf <site> <env>')
64
+ .description('Export Auth0 configuration for the given site')
65
+ .action(async (site, env) => {
66
+ await exportConf(site, env);
67
+ });
68
+
69
+ program
70
+ .command('getAuth0Metadata <site> <env>')
71
+ .description('Get Auth0 metadata for the given site')
72
+ .action(async (site, env) => {
73
+ await getAuth0Metadata(site, env);
74
+ });
75
+
76
+ program.parse(process.argv);