@docupace/pipeline 1.0.39-newrelease.8 → 1.0.39

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,10 +1,22 @@
1
1
  import { $ } from 'zx';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+
5
+ export async function haproxySync(cluster) {
6
+ if (cluster !== 'preprod' && cluster !== 'stage') {
7
+ console.log('Error: Cluster must be preprod or stage');
8
+ process.exit(1);
9
+ }
2
10
 
3
- export async function haproxySync() {
4
11
  const repoPath = '/root/repo/docupace-ansible';
5
- const inventory = path.join(repoPath, 'inventories/preprod/inventory');
12
+ const inventory = path.join(repoPath, `inventories/${cluster}/inventory`);
6
13
 
7
14
  // Create haproxy.sh
15
+ const cluserHostMap = {
16
+ preprod: '10.10.28.198',
17
+ stage: '10.12.28.10',
18
+ };
19
+
8
20
  const scriptContent = `
9
21
  #!/bin/bash
10
22
 
@@ -18,11 +30,11 @@ export async function haproxySync() {
18
30
  git submodule foreach --recursive git checkout master
19
31
  git submodule foreach --recursive git pull origin master
20
32
 
21
- ansible-playbook -i inventories/preprod/inventory haproxy.yml -e "cluster=preprod"
33
+ ansible-playbook -i inventories/${cluster}/inventory haproxy.yml -e "cluster=${cluster}"
22
34
 
23
35
  echo "proceeding"
24
36
  echo "committing changes"
25
- git add preprod-haproxy.cfg
37
+ git add ${cluster}-haproxy.cfg
26
38
  git commit -m "Sync haproxy"
27
39
  git push origin master
28
40
  `;
@@ -32,18 +44,16 @@ export async function haproxySync() {
32
44
  // Private key
33
45
  const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
34
46
  if (!haproxyPrivateKey) {
35
- log('Error: HAPROXY_PRIVATE_KEY not set.');
47
+ console.log('Error: HAPROXY_PRIVATE_KEY not set.');
36
48
  process.exit(1);
37
49
  }
38
50
 
39
51
  await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
40
52
  await fs.chmod('private.key', 0o600);
41
53
 
42
- await $`cat private.key`; // Just to mimic the script's behavior
43
-
44
54
  // Copy script to remote
45
- await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@10.10.28.198:/tmp/haproxy.sh`;
55
+ await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@${cluserHostMap[cluster]}:/tmp/haproxy.sh`;
46
56
 
47
57
  // Execute script on remote
48
- await $`ssh -i private.key -o StrictHostKeyChecking=no root@10.10.28.198 "bash /tmp/haproxy.sh"`;
58
+ await $`ssh -i private.key -o StrictHostKeyChecking=no root@${cluserHostMap[cluster]} "bash /tmp/haproxy.sh"`;
49
59
  }
package/src/next/jira.js CHANGED
@@ -12,67 +12,19 @@ const jiraClient = axios.create({
12
12
  },
13
13
  });
14
14
 
15
- export async function getJiraReleaseNotes(issueKey) {
16
- try {
17
- const response = await jiraClient.get(
18
- `/rest/api/2/issue/${issueKey}?fields=customfield_10108,customfield_11625`,
19
- );
20
-
21
- const releaseNotesField = response.data.fields.customfield_10108;
22
- const url = response.data.fields.customfield_11625;
23
-
24
- // Extract text from the document structure
25
-
26
- return { summary: releaseNotesField, url };
27
- } catch (error) {
28
- console.error(
29
- `Error getting Jira release notes for ${issueKey}: ${error.message}`,
30
- );
31
- throw error;
32
- }
33
- }
34
-
35
- /**
36
- * Updates the release notes in the Jira issue's custom field
37
- * @param {string} issueKey - The Jira issue key
38
- * @param {string} text - The release notes text to set
39
- */
40
- export async function updateJiraReleaseNotes(
41
- issueKey,
42
- text,
43
- url,
44
- jiraVersions,
45
- ) {
46
- try {
47
- const payload = {
48
- fields: {
49
- customfield_10108: text,
50
- customfield_11625: url,
51
- fixVersions: jiraVersions.map((version) => ({ name: version })),
52
- },
53
- };
54
-
55
- await jiraClient.put(`/rest/api/2/issue/${issueKey}`, payload);
56
-
57
- console.log(`Updated release notes for ${issueKey}`);
58
- } catch (error) {
59
- console.error(
60
- `Error updating Jira release notes for ${issueKey}: ${error.message}`,
61
- );
62
- throw error;
63
- }
64
- }
65
-
15
+ const packageComponents = {
16
+ 'docupace-ui': 'next-ui',
17
+ 'docupace-graphql-server': 'graphql-server',
18
+ '@docupace/template': 'template',
19
+ };
66
20
  /**
67
21
  * Updates the component version custom field in Jira
68
22
  * @param {string} issueKey - The Jira issue key
69
- * @param {string} packageName - The package name
23
+ * @param {string} component - The component name
70
24
  * @param {string} version - The version to set
71
25
  */
72
26
  export async function updateComponentVersion(issueKey, packageName, version) {
73
- const component = packageName.includes('/')
74
- ? packageName.split('/')[1]
75
- : packageName;
27
+ const component = packageComponents[packageName] ?? packageName;
76
28
  console.log(
77
29
  `Updating ${issueKey} for package ${packageName} translated to component ${component} with version ${version}`,
78
30
  );
@@ -1,71 +1,48 @@
1
- import { $ } from './logger.js';
1
+ import { $ } from 'zx';
2
2
 
3
- const {
4
- JF_REGISTRY_URL,
5
- JF_REGISTRY_REPO_NAME,
6
- JF_REGISTRY_PASSWORD_DEV,
7
- JF_REGISTRY_USER_DEV,
8
- BITBUCKET_REPO_SLUG,
9
- BITBUCKET_BUILD_NUMBER,
10
- APP_NAME,
11
- } = process.env;
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}`;
12
8
 
13
- const JF_REGISTRY_FULL_URL = `${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}`;
9
+ console.log(`Publishing Docker image: ${IMAGE_NAME}`);
14
10
 
15
- async function loginRegistry() {
16
- await $`echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}`;
17
- }
18
-
19
- async function logoutRegistry() {
20
- await $`docker logout ${JF_REGISTRY_URL}`;
21
- }
22
-
23
- export async function publish(gitSha) {
24
- process.env.DOCKER_HOST = '';
25
-
26
- console.log(JSON.stringify(process.env));
27
-
28
- const IMAGE_PREFIX = APP_NAME ?? BITBUCKET_REPO_SLUG;
29
- const BUILD_IMAGE_NAME = `${IMAGE_PREFIX}:build-${BITBUCKET_BUILD_NUMBER}`;
30
- const IMAGE_NAME = `${IMAGE_PREFIX}:sha-${gitSha}`;
31
-
32
- console.log(`Publishing Docker image ${IMAGE_NAME}...`);
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}`;
33
13
 
34
- await loginRegistry();
35
-
36
- let manifestExists = false;
14
+ // Check if the image already exists
37
15
  try {
38
- $.verbose = false; // Silence output temporarily
39
16
  await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
40
- manifestExists = true;
41
- } catch {
42
- manifestExists = false;
43
- } finally {
44
- $.verbose = true; // Restore normal output
45
- }
46
-
47
- if (manifestExists) {
48
17
  console.log(
49
- `Tag sha-${gitSha} already exists in the remote repository. Skipping push.`,
18
+ `Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`,
50
19
  );
51
- } else {
20
+ } catch {
52
21
  await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
53
22
  await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
54
23
  }
55
24
 
25
+ // Tag and push build image
56
26
  await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
57
27
  await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
58
28
 
59
- const gitTags = (await $`git tag --points-at HEAD`).stdout
60
- .trim()
61
- .split('\n')
62
- .filter(Boolean);
63
- for (const gitTag of gitTags) {
64
- const version = gitTag.includes('@') ? 'v' + gitTag.split('@')[1] : gitTag;
65
- const tagName = `${IMAGE_PREFIX}:${version}`;
66
- await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${tagName}`;
67
- await $`docker push ${JF_REGISTRY_FULL_URL}/${tagName}`;
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}`;
41
+ }
42
+ } else {
43
+ console.log('No Git tags found pointing to the current HEAD.');
68
44
  }
69
45
 
70
- await logoutRegistry();
46
+ // Docker logout
47
+ await $`docker logout ${process.env.JF_REGISTRY_URL}`;
71
48
  }
package/src/next/vault.js CHANGED
@@ -3,8 +3,8 @@ import axios from 'axios';
3
3
  export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
4
4
  const AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID;
5
5
  const AUTH0_CLIENT_SECRET = process.env.AUTH0_CLIENT_SECRET;
6
- const VAULT_ADDR = process.env.VAULT_ADDR; // Vault host URL from environment variables
7
- const VAULT_TOKEN = process.env.VAULT_TOKEN; // Vault token from environment variables
6
+ const VAULT_ADDR = process.env.VAULT_ADDR; // Vault host URL from environment variables
7
+ const VAULT_TOKEN = process.env.VAULT_TOKEN; // Vault token from environment variables
8
8
 
9
9
  if (!VAULT_ADDR || !VAULT_TOKEN) {
10
10
  throw new Error('Missing VAULT_ADDR or VAULT_TOKEN environment variable.');
@@ -13,6 +13,7 @@ export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
13
13
  const vaultApiUrl = `${VAULT_ADDR}/v1/secret/data/${SITE}/common/config`;
14
14
 
15
15
  try {
16
+
16
17
  if (process.env.VAULT_SKIP_VERIFY === 'true') {
17
18
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
18
19
  }
@@ -31,15 +32,12 @@ export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
31
32
  'X-Vault-Token': VAULT_TOKEN,
32
33
  'Content-Type': 'application/json',
33
34
  },
34
- },
35
+ }
35
36
  );
36
37
 
37
38
  console.log('Data added to Vault successfully:', response.data);
38
39
  } catch (error) {
39
- console.error(
40
- 'Error adding data to Vault:',
41
- error.response?.data || error.message,
42
- );
40
+ console.error('Error adding data to Vault:', error.response?.data || error.message);
43
41
  throw error;
44
42
  }
45
43
  }
@@ -2,6 +2,7 @@
2
2
  set -e
3
3
 
4
4
  PROJECT=$1
5
+ export ROLE_NAME="${2:-atlassian-bitbucket-pipelines-runner-eks-role}"
5
6
 
6
7
  if [[ -z "$PROJECT" ]]; then
7
8
  echo "Error: Project name is required."
@@ -9,7 +10,6 @@ if [[ -z "$PROJECT" ]]; then
9
10
  exit 1
10
11
  fi
11
12
 
12
- export ROLE_NAME="atlassian-bitbucket-pipelines-runner-eks-role"
13
13
  export SESSION_NAME="EKSAdminSession"
14
14
  export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
15
15
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
package/terraform/init.sh CHANGED
@@ -3,6 +3,7 @@ set -e
3
3
 
4
4
  PROJECT=$1
5
5
  CURRENT_ENVIRONMENT=$2
6
+ export ROLE_NAME="${3:-atlassian-bitbucket-pipelines-runner-eks-role}"
6
7
 
7
8
  if [[ -z "$PROJECT" ]]; then
8
9
  echo "Error: Project name is required."
@@ -16,7 +17,6 @@ if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
16
17
  exit 1
17
18
  fi
18
19
 
19
- export ROLE_NAME="atlassian-bitbucket-pipelines-runner-eks-role"
20
20
  export SESSION_NAME="EKSAdminSession"
21
21
  export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
22
22
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
@@ -37,6 +37,7 @@ info () {
37
37
  echo "PROJECT => $PROJECT"
38
38
  echo "CURRENT_ENVIRONMENT => $CURRENT_ENVIRONMENT"
39
39
  echo "SITE_NAME => $SITE_NAME"
40
+ echo "Using AWS Role: $ROLE_NAME"
40
41
  }
41
42
 
42
43
  if [[ "$PROJECT" == "s3" ]]; then
package/terraform/plan.sh CHANGED
@@ -3,6 +3,7 @@ set -e
3
3
 
4
4
  PROJECT=$1
5
5
  CURRENT_ENVIRONMENT=$2
6
+ export ROLE_NAME="${3:-atlassian-bitbucket-pipelines-runner-eks-role}"
6
7
 
7
8
  if [[ -z "$PROJECT" ]]; then
8
9
  echo "Error: Project name is required."
@@ -16,7 +17,6 @@ if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
16
17
  exit 1
17
18
  fi
18
19
 
19
- export ROLE_NAME="atlassian-bitbucket-pipelines-runner-eks-role"
20
20
  export SESSION_NAME="EKSAdminSession"
21
21
  export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
22
22
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
package/README.md DELETED
@@ -1,136 +0,0 @@
1
- # Pipeline Shared Scripts
2
-
3
- A collection of CLI tools for Docupace's CI/CD pipelines and deployment workflows.
4
-
5
- ## Overview
6
-
7
- This package provides a set of command-line interfaces (CLIs) to facilitate various DevOps operations in the Docupace ecosystem:
8
-
9
- - `dp-next-cli`: Deployment and pipeline management for Next applications
10
- - `dp-changeset-cli`: Versioning and changeset management
11
- - `dp-auth0-cli`: Auth0 tenant configuration and management
12
-
13
- ## Installation
14
-
15
- ```bash
16
- npm install @docupace/pipeline
17
- ```
18
-
19
- Or with pnpm:
20
-
21
- ```bash
22
- pnpm add @docupace/pipeline
23
- ```
24
-
25
- ## Command Line Interfaces
26
-
27
- ### dp-next-cli
28
-
29
- Manages deployment, Docker image handling, and infrastructure configuration.
30
-
31
- ```bash
32
- dp-next-cli [command] [options]
33
- ```
34
-
35
- **Commands:**
36
-
37
- - `pull <imageName>`: Pull a Docker image from the registry
38
- - `sonar`: Run Sonar analysis
39
- - `addApacheSite`: Add site to apache
40
- - `connectClone`: Clone connect site
41
- - `haproxySync`: Sync haproxy config
42
- - `vaultAddSiteData`: Add m2m auth0 data to vault
43
- - `-s, --site-name <siteName>`: Site name
44
- - `-p, --site-config-remote-path <path>`: Site config remote path
45
- - `publish`: Publish a Docker image
46
- - `deploy-from-site`: Deploy an application for a specific site
47
- - `-f, --from-env <fromEnv>`: Source environment
48
- - `-t, --to-env <toEnv>`: Target environment
49
- - `-F, --from-site <fromSite>`: Source site
50
- - `-T, --to-site <toSite>`: Target site
51
- - `-c, --deploy-core <deployCore>`: Deploy Core (default: "false")
52
- - `-C, --deploy-connect <deployConnect>`: Deploy Connect (default: "false")
53
- - `deploy-template`: Deploy an application for a specific site
54
- - `deploy-app <application>`: Deploy an application for a specific site
55
- - `deploy-core <env> <site>`: Deploy Core
56
- - `-l, --liquibase <liquibase>`: Application name (default: "true")
57
- - `-b, --branch <branch>`: Branch (default: "master")
58
- - `deploy-connect <env> <site>`: Deploy Connect
59
- - `-l, --liquibase <liquibase>`: Application name (default: "true")
60
- - `-b, --branch <branch>`: Branch (default: "master")
61
- - `deploy-core-pipeline <env> <site>`: Deploy Core via pipeline
62
- - `-l, --liquibase <liquibase>`: Application name (default: "true")
63
- - `-b, --branch <branch>`: Branch (default: "master")
64
- - `copy`: Copy a Docker image between registries
65
- - `-a, --application <application>`: Application name
66
- - `-f, --from-env <fromEnv>`: Source environment
67
- - `-t, --to-env <toEnv>`: Target environment
68
- - `-g, --tag <tag>`: Image tag
69
- - `run-pipeline`: Trigger a pipeline by name
70
- - `-r, --repository <repository>`: Repository name
71
- - `-p, --pipeline-name <pipelineName>`: Pipeline name
72
- - `-b, --branch <branch>`: Branch name
73
- - `-v, --variables <key=value>`: Pipeline variable as key=value pair
74
- - `-w, --wait`: Wait for the pipeline to complete (default: false)
75
-
76
- ### dp-changeset-cli
77
-
78
- Manages versioning and changesets for mono-repos and single-package repos.
79
-
80
- ```bash
81
- dp-changeset-cli [command] [options]
82
- ```
83
-
84
- **Commands:**
85
-
86
- - `validate`: Validate changesets for the provided PR
87
- - `version`: Run Changeset versioning
88
- - `commit-tag`: Commit and tag the new version
89
- - `version-commit-tag`: Run versioning and commit-and-tag in sequence
90
- - `close-version`: Close a version and create a release branch
91
- - `create-changeset`: Create a changeset based on the current branch and Jira ticket information
92
-
93
- ### dp-auth0-cli
94
-
95
- Manages Auth0 tenant configuration across environments.
96
-
97
- ```bash
98
- dp-auth0-cli [command] [options]
99
- ```
100
-
101
- **Commands:**
102
-
103
- - `configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain> <useS3>`: Configure Auth0 tenants
104
- - `getVaultSecrets <vaultPath>`: Get secrets from Vault
105
- - `configureAlias <site> <env> <username> <password> <realm>`: Configure Core Alias for the given site
106
- - `exportConf <site> <env>`: Export Auth0 configuration for the given site
107
- - `getAuth0Metadata <site> <env>`: Get Auth0 metadata for the given site
108
-
109
- ## Environment Configuration
110
-
111
- The CLI tools look for environment configuration in the following locations:
112
- - `.env.pipeline.local`
113
- - `config/.env.pipeline.local`
114
-
115
- ## Examples
116
-
117
- ```bash
118
- # Deploy from one site to another
119
- dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true
120
-
121
- # Run a pipeline
122
- dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa
123
-
124
- # Validate changesets
125
- dp-changeset-cli validate
126
-
127
- # Create a new changeset
128
- dp-changeset-cli create-changeset
129
-
130
- # Configure Auth0 for a site
131
- dp-auth0-cli configureFromSite sourceSite targetSite dev prod true true true false
132
- ```
133
-
134
- ## License
135
-
136
- ISC
@@ -1,116 +0,0 @@
1
- #!/usr/bin/env node
2
- import fetch from 'node-fetch';
3
-
4
- // Configuration
5
- const CANNY_API_KEY = process.env.CANNY_API_KEY;
6
-
7
- /**
8
- * Upload release notes to Canny
9
- * @param {Object} releaseNote - The release note data
10
- * @returns {Promise<Object>} - The full Canny entry object
11
- */
12
- export async function uploadToCanny(releaseNote, labelIDs) {
13
- if (!CANNY_API_KEY) {
14
- console.warn('Canny API key not provided. Skipping upload.');
15
- return null;
16
- }
17
-
18
- try {
19
- // Prepare the content for Canny based on the release notes
20
- const title = releaseNote.title;
21
- let content = '';
22
-
23
- // Include user-facing description if available
24
- if (
25
- releaseNote.userFacingDescription &&
26
- releaseNote.userFacingDescription.__line.trim()
27
- ) {
28
- content += `${releaseNote.userFacingDescription.__line}\n\n`;
29
- } else {
30
- content += `${releaseNote.summary}\n\n`;
31
- }
32
-
33
- // Include technical details if available
34
- if (
35
- releaseNote.technicalDescription &&
36
- releaseNote.technicalDescription.__line.trim()
37
- ) {
38
- content += `**Technical Details**\n\n${releaseNote.technicalDescription.__line}\n\n`;
39
- }
40
-
41
- // Add JIRA reference
42
- content += `**Reference**: JIRA ticket [${releaseNote.ticketId}]`;
43
-
44
- // Map our changeType to Canny's type parameter
45
- let entryType;
46
- if (releaseNote.changeType === 'New') {
47
- entryType = 'new';
48
- } else if (releaseNote.changeType === 'Improved') {
49
- entryType = 'improved';
50
- } else if (releaseNote.changeType === 'Fixed') {
51
- entryType = 'fixed';
52
- }
53
-
54
- // Create a new changelog entry in Canny
55
- const createResponse = await fetch(
56
- 'https://canny.io/api/v1/entries/create',
57
- {
58
- method: 'POST',
59
- headers: {
60
- 'Content-Type': 'application/json',
61
- },
62
- body: JSON.stringify({
63
- apiKey: CANNY_API_KEY,
64
- title: title,
65
- details: content,
66
- type: entryType,
67
- published: false, // Keep as draft initially
68
- labelIDs,
69
- }),
70
- },
71
- );
72
-
73
- if (!createResponse.ok) {
74
- console.error(`Error from Canny API: ${createResponse.statusText}`);
75
- return null;
76
- }
77
-
78
- const createData = await createResponse.json();
79
- const entryId = createData.id;
80
-
81
- // Fetch the complete entry details using the entries/list endpoint
82
- const listResponse = await fetch('https://canny.io/api/v1/entries/list', {
83
- method: 'POST',
84
- headers: {
85
- 'Content-Type': 'application/json',
86
- },
87
- body: JSON.stringify({
88
- apiKey: CANNY_API_KEY,
89
- }),
90
- });
91
-
92
- if (!listResponse.ok) {
93
- console.error(
94
- `Error fetching entries list from Canny API: ${listResponse.statusText}`,
95
- );
96
- return createData; // Return just the create response as fallback
97
- }
98
-
99
- const listData = await listResponse.json();
100
-
101
- // Find the entry we just created in the list
102
- const fullEntry = listData.entries.find((entry) => entry.id === entryId);
103
-
104
- if (!fullEntry) {
105
- console.warn(
106
- `Created entry with ID ${entryId} not found in entries list. Returning partial data.`,
107
- );
108
- return createData;
109
- }
110
-
111
- return fullEntry;
112
- } catch (error) {
113
- console.error(`Error uploading to Canny: ${error.message}`);
114
- return null;
115
- }
116
- }
@@ -1,26 +0,0 @@
1
- async function getReleaseLine(changeset, type, changelogOpts) {
2
- return (async () => {
3
- const { default: changelog } = await import('./changelog.js');
4
- return await changelog.getReleaseLine(changeset, type, changelogOpts); // Now you can use `changelog` here
5
- })();
6
- }
7
-
8
- async function getDependencyReleaseLine(
9
- changesets,
10
- dependenciesUpdated,
11
- changelogOpts,
12
- ) {
13
- return (async () => {
14
- const { default: changelog } = await import('./changelog.js');
15
- return await changelog.getDependenciesReleaseLine(
16
- changesets,
17
- dependenciesUpdated,
18
- changelogOpts,
19
- ); // Now you can use `changelog` here
20
- })();
21
- }
22
-
23
- module.exports = {
24
- getReleaseLine,
25
- getDependencyReleaseLine,
26
- };