@docupace/pipeline 1.0.1-2.ervinsUpdate2.5 → 1.0.1

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.
@@ -1,48 +1,46 @@
1
1
  import { $ } from 'zx';
2
2
 
3
3
  export async function publish(GIT_SHA) {
4
- const BITBUCKET_REPO_SLUG = process.env.BITBUCKET_REPO_SLUG;
5
- const BUILD_IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:build-${process.env.BITBUCKET_BUILD_NUMBER}`;
6
- const IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
7
- const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
8
-
9
- console.log(`Publishing Docker image: ${IMAGE_NAME}`);
10
-
11
- // Docker login
12
- await $`echo ${process.env.JF_REGISTRY_PASSWORD_DEV} | docker login --username ${process.env.JF_REGISTRY_USER_DEV} --password-stdin ${process.env.JF_REGISTRY_URL}`;
13
-
14
- // Check if the image already exists
15
- try {
16
- await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
17
- console.log(
18
- `Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`,
19
- );
20
- } catch {
21
- await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
22
- await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
23
- }
24
-
25
- // Tag and push build image
26
- await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
27
- await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
28
-
29
- // Fetch Git tags pointing to the current HEAD
30
- const gitTagsOutput = (await $`git tag --points-at HEAD`).stdout.trim();
31
- const gitTags = gitTagsOutput.split('\n').filter((tag) => tag);
32
-
33
- // Tag and push each Git tag as a Docker tag
34
- if (gitTags.length > 0) {
35
- console.log(`Found Git tags pointing to HEAD: ${gitTags.join(', ')}`);
36
- for (const gitTag of gitTags) {
37
- const dockerTag = `${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${gitTag}`;
38
- console.log(`Tagging and pushing Docker image for Git tag: ${gitTag}`);
39
- await $`docker tag ${IMAGE_NAME} ${dockerTag}`;
40
- await $`docker push ${dockerTag}`;
4
+ const BITBUCKET_REPO_SLUG = process.env.BITBUCKET_REPO_SLUG;
5
+ const BUILD_IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:build-${process.env.BITBUCKET_BUILD_NUMBER}`;
6
+ const IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
7
+ const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
8
+
9
+ console.log(`Publishing Docker image: ${IMAGE_NAME}`);
10
+
11
+ // Docker login
12
+ await $`echo ${process.env.JF_REGISTRY_PASSWORD_DEV} | docker login --username ${process.env.JF_REGISTRY_USER_DEV} --password-stdin ${process.env.JF_REGISTRY_URL}`;
13
+
14
+ // Check if the image already exists
15
+ try {
16
+ await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
17
+ console.log(`Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`);
18
+ } catch {
19
+ await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
20
+ await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
41
21
  }
42
- } else {
43
- console.log('No Git tags found pointing to the current HEAD.');
44
- }
45
22
 
46
- // Docker logout
47
- await $`docker logout ${process.env.JF_REGISTRY_URL}`;
23
+ // Tag and push build image
24
+ await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
25
+ await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
26
+
27
+ // Fetch Git tags pointing to the current HEAD
28
+ const gitTagsOutput = (await $`git tag --points-at HEAD`).stdout.trim();
29
+ const gitTags = gitTagsOutput.split('\n').filter((tag) => tag);
30
+
31
+ // Tag and push each Git tag as a Docker tag
32
+ if (gitTags.length > 0) {
33
+ console.log(`Found Git tags pointing to HEAD: ${gitTags.join(', ')}`);
34
+ for (const gitTag of gitTags) {
35
+ const dockerTag = `${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${gitTag}`;
36
+ console.log(`Tagging and pushing Docker image for Git tag: ${gitTag}`);
37
+ await $`docker tag ${IMAGE_NAME} ${dockerTag}`;
38
+ await $`docker push ${dockerTag}`;
39
+ }
40
+ } else {
41
+ console.log('No Git tags found pointing to the current HEAD.');
42
+ }
43
+
44
+ // Docker logout
45
+ await $`docker logout ${process.env.JF_REGISTRY_URL}`;
48
46
  }
package/src/next/pull.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { $ } from 'zx';
2
2
 
3
3
  export async function pull(imageName) {
4
- const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
5
- console.log(`Pulling Docker image: ${JF_REGISTRY_FULL_URL}/${imageName}`);
6
- await $`docker pull ${JF_REGISTRY_FULL_URL}/${imageName}`;
7
- }
4
+ const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
5
+ console.log(`Pulling Docker image: ${JF_REGISTRY_FULL_URL}/${imageName}`);
6
+ await $`docker pull ${JF_REGISTRY_FULL_URL}/${imageName}`;
7
+ }
package/src/next/sonar.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { $ } from 'zx';
2
2
 
3
3
  export async function sonar(GIT_SHA) {
4
- const IMAGE_NAME = `${process.env.BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
5
- const SONAR_CONTAINER_NAME = `${process.env.BITBUCKET_REPO_SLUG}-${GIT_SHA}`;
4
+ const IMAGE_NAME = `${process.env.BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
5
+ const SONAR_CONTAINER_NAME = `${process.env.BITBUCKET_REPO_SLUG}-${GIT_SHA}`;
6
6
 
7
- console.log(`Running Sonar analysis on Docker image: ${IMAGE_NAME}`);
7
+ console.log(`Running Sonar analysis on Docker image: ${IMAGE_NAME}`);
8
8
 
9
- // Remove existing container
10
- const existingContainer = (
11
- await $`docker ps -a --filter "name=${SONAR_CONTAINER_NAME}" --format "{{.Names}}"`
12
- ).stdout.trim();
13
- if (existingContainer) {
14
- await $`docker rm -f ${SONAR_CONTAINER_NAME}`;
15
- }
9
+ // Remove existing container
10
+ const existingContainer = (
11
+ await $`docker ps -a --filter "name=${SONAR_CONTAINER_NAME}" --format "{{.Names}}"`
12
+ ).stdout.trim();
13
+ if (existingContainer) {
14
+ await $`docker rm -f ${SONAR_CONTAINER_NAME}`;
15
+ }
16
16
 
17
- await $`docker run --rm \
17
+ await $`docker run --rm \
18
18
  -e BRANCH=${process.env.BITBUCKET_BRANCH} \
19
19
  -e PR_ID=${process.env.BITBUCKET_PR_ID} \
20
20
  -e PR_DESTINATION_BRANCH=${process.env.BITBUCKET_PR_DESTINATION_BRANCH} \
package/.prettierrc.cjs DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- parser: 'typescript',
3
- trailingComma: 'all',
4
- tabWidth: 2,
5
- semi: true,
6
- singleQuote: true,
7
- printWidth: 80,
8
- tabs: false,
9
- jsxSingleQuote: false,
10
- bracketSameLine: true,
11
- arrowParens: 'always',
12
- };
package/eslint.config.js DELETED
@@ -1,26 +0,0 @@
1
- import globals from 'globals';
2
- import pluginJs from '@eslint/js';
3
- import prettierConfig from 'eslint-config-prettier';
4
- import prettierPlugin from 'eslint-plugin-prettier';
5
-
6
- /** @type {import('eslint').Linter.Config[]} */
7
- export default [
8
- {
9
- languageOptions: {
10
- globals: {
11
- ...globals.browser,
12
- ...globals.node, // Add Node.js globals
13
- },
14
- },
15
- },
16
- pluginJs.configs.recommended,
17
- {
18
- plugins: {
19
- prettier: prettierPlugin,
20
- },
21
- rules: {
22
- ...prettierConfig.rules,
23
- 'prettier/prettier': 'error',
24
- },
25
- },
26
- ];
package/src/auth0/cli.js DELETED
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import {
5
- configureFromSite
6
- } from './configure.js';
7
- import {
8
- getVaultSecrets
9
- } from './vault.js'
10
-
11
- import dotenv from 'dotenv';
12
-
13
- dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
14
-
15
- const program = new Command();
16
-
17
- program
18
- .command('configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain>')
19
- .description('Configure the Auth0 tenants in env for the given site')
20
- .action(async (fromSite, toSite, fromEnv,toEnv, deployUI, deployGraphQLServer, useNewDomain) => {
21
- await configureFromSite(fromSite, toSite, fromEnv, toEnv, deployUI, deployGraphQLServer, useNewDomain);
22
- });
23
-
24
- program
25
- .command('getVaultSecrets <vaultPath>')
26
- .description('Get Secrets for Vault PATH')
27
- .action(async (vaultPath) => {
28
- await getVaultSecrets(vaultPath);
29
- });
30
-
31
- program.parse(process.argv);