@docupace/pipeline 1.0.77 → 1.0.78
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/.prettierrc.cjs +12 -12
- package/README.md +135 -135
- package/bin/azuread_update_callbacks_for_app.sh +58 -58
- package/bin/next-changeset-validate.sh +8 -8
- package/bitbucket-pipelines.yml +59 -59
- package/eslint.config.js +49 -49
- package/jest.config.js +15 -15
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -123
- package/next/sonar.sh +23 -23
- package/package.json +1 -1
- package/src/auth0/alias.js +79 -79
- package/src/auth0/alias.test.js +172 -172
- package/src/auth0/cli.js +82 -82
- package/src/auth0/configure.js +902 -902
- package/src/auth0/configure.test.js +167 -167
- package/src/auth0/export.js +48 -48
- package/src/auth0/export.test.js +103 -103
- package/src/auth0/metadata.js +141 -141
- package/src/auth0/metadata.test.js +186 -186
- package/src/auth0/vault.js +60 -60
- package/src/auth0/vault.test.js +134 -134
- package/src/changeset/changelog-wiki.js +328 -328
- package/src/changeset/changeset-config.js +34 -34
- package/src/changeset/cli.js +237 -237
- package/src/changeset/create.js +215 -215
- package/src/changeset/package-util.js +87 -87
- package/src/changeset/util.js +43 -43
- package/src/changeset/validate.js +91 -91
- package/src/changeset/version.js +102 -102
- package/src/jenkins/setParams.groovy +58 -58
- package/src/lib/merge-driver.js +204 -204
- package/src/merge/cli-merge-all.js +507 -507
- package/src/merge/cli-merge.js +492 -492
- package/src/merge/cli-resolve.js +399 -399
- package/src/merge/cli.js +38 -38
- package/src/merge/merge-changelog.js +87 -87
- package/src/merge/merge-package.js +106 -106
- package/src/merge/merge-types.js +82 -82
- package/src/merge/pr.js +231 -231
- package/src/micro/deploy-microservice.js +153 -0
- package/src/micro/{ms-publish.js → publish-ms.js} +8 -6
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +81 -81
- package/src/next/cli.js +10 -1
- package/src/next/config.js +137 -137
- package/src/next/connect.js +226 -226
- package/src/next/copy.js +61 -61
- package/src/next/deploy.js +633 -633
- package/src/next/git-to-semver.js +79 -79
- package/src/next/haproxy.js +76 -76
- package/src/next/jenkins.js +123 -123
- package/src/next/jira.js +84 -84
- package/src/next/logger.js +17 -17
- package/src/next/pipline.js +114 -114
- package/src/next/publish.js +71 -71
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/test.js +5 -5
- package/src/next/util.js +95 -93
- package/src/next/vault.js +45 -45
- package/terraform/apply.sh +37 -37
- package/terraform/init.sh +72 -72
- package/terraform/plan.sh +76 -76
- package/terraform/validate.sh +17 -17
- package/src/micro/cli.js +0 -71
- package/src/micro/ms-deploy.js +0 -271
package/src/changeset/create.js
CHANGED
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
import OpenAI from 'openai';
|
|
2
|
-
import z from 'zod';
|
|
3
|
-
import { zodResponseFormat } from 'openai/helpers/zod';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import inquirer from 'inquirer';
|
|
7
|
-
import { getMainPackage, getPackage, findJiraTicketId } from './util.js';
|
|
8
|
-
import { getPackageNames } from './package-util.js';
|
|
9
|
-
import { execSync } from 'child_process';
|
|
10
|
-
|
|
11
|
-
async function createChangesetDirectory() {
|
|
12
|
-
try {
|
|
13
|
-
// Use path.join to build a safe path to `.changeset`
|
|
14
|
-
const targetDir = path.join(process.cwd(), '.changeset');
|
|
15
|
-
|
|
16
|
-
// Create the directory recursively if it doesn't exist
|
|
17
|
-
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error('Error creating .changeset directory:', error);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Gets the current git branch name
|
|
25
|
-
*/
|
|
26
|
-
async function getCurrentBranch() {
|
|
27
|
-
try {
|
|
28
|
-
const branchName = execSync('git branch --show-current', {
|
|
29
|
-
encoding: 'utf8',
|
|
30
|
-
shell: true,
|
|
31
|
-
}).trim();
|
|
32
|
-
console.log(`Current branch: ${branchName}`);
|
|
33
|
-
return branchName;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error('Error getting current branch:', error.message);
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Extracts a Jira ticket ID from a branch name
|
|
41
|
-
*/
|
|
42
|
-
function extractJiraTicketId(branchName) {
|
|
43
|
-
const jiraTicketId = findJiraTicketId(branchName);
|
|
44
|
-
if (!jiraTicketId) {
|
|
45
|
-
throw new Error('No Jira ticket found in the branch name.');
|
|
46
|
-
}
|
|
47
|
-
return jiraTicketId;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Fetches Jira ticket data from Jira API
|
|
52
|
-
*/
|
|
53
|
-
async function fetchJiraTicketData(jiraTicketId) {
|
|
54
|
-
const jiraBaseUrl = 'https://docupacellc.atlassian.net';
|
|
55
|
-
const jiraEmail = process.env.JIRA_API_EMAIL;
|
|
56
|
-
const jiraApiKey = process.env.JIRA_API_KEY;
|
|
57
|
-
const jiraFullApiKey = `${jiraEmail}:${jiraApiKey}`;
|
|
58
|
-
const jiraUrl = `${jiraBaseUrl}/rest/api/2/issue/${jiraTicketId}`;
|
|
59
|
-
|
|
60
|
-
const jiraResponse = await fetch(jiraUrl, {
|
|
61
|
-
headers: {
|
|
62
|
-
Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString('base64')}`,
|
|
63
|
-
'Content-Type': 'application/json',
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (!jiraResponse.ok) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`Failed to fetch Jira ticket ${jiraTicketId}. Status: ${jiraResponse.status}, Ticket URL: ${jiraUrl}`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return await jiraResponse.json();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Generates release notes using OpenAI
|
|
78
|
-
*/
|
|
79
|
-
async function generateReleaseNotes(jiraTicketData) {
|
|
80
|
-
const openaiClient = new OpenAI({
|
|
81
|
-
apiKey: process.env['OPENAI_API_KEY'],
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const ChangeRequestSchema = z.object({
|
|
85
|
-
change_type: z.enum(['patch', 'minor']),
|
|
86
|
-
summary: z.string(),
|
|
87
|
-
jira_ticket_id: z.string(),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const openAiResponse = await openaiClient.chat.completions.create({
|
|
91
|
-
model: 'gpt-4o-mini',
|
|
92
|
-
messages: [
|
|
93
|
-
{
|
|
94
|
-
role: 'system',
|
|
95
|
-
content: `Process JSON from a Jira ticket to generate simple maximum 2 sentence release note for the ticket and determine the change type for bug it should be a patch for new feature it should be a minor change`,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
role: 'user',
|
|
99
|
-
content: JSON.stringify(jiraTicketData),
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
response_format: zodResponseFormat(ChangeRequestSchema, 'changeset_schema'),
|
|
103
|
-
temperature: 0,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const assistantResponse = openAiResponse.choices[0].message.content;
|
|
107
|
-
return JSON.parse(assistantResponse);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Writes the changeset file
|
|
112
|
-
*/
|
|
113
|
-
async function writeJiraChangesetFile(
|
|
114
|
-
packages,
|
|
115
|
-
jiraTicketId,
|
|
116
|
-
changeType,
|
|
117
|
-
summary,
|
|
118
|
-
) {
|
|
119
|
-
const text = `${summary} [${jiraTicketId}]`;
|
|
120
|
-
await writeChangesetFile(packages, jiraTicketId, changeType, text);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export async function writeChangesetFile(packages, filename, changeType, text) {
|
|
124
|
-
const packageEntries = packages
|
|
125
|
-
.map((pkg) => `'${pkg.name}': ${changeType}`)
|
|
126
|
-
.join('\n');
|
|
127
|
-
|
|
128
|
-
const changesetContent = `---
|
|
129
|
-
${packageEntries}
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
${text}
|
|
133
|
-
`;
|
|
134
|
-
|
|
135
|
-
const changesetFile = `./.changeset/${filename}.md`;
|
|
136
|
-
|
|
137
|
-
await createChangesetDirectory();
|
|
138
|
-
await fs.promises.writeFile(changesetFile, changesetContent);
|
|
139
|
-
console.log(`Created changeset file at ${changesetFile}`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Main function to create a changeset
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
export async function createChangeset() {
|
|
147
|
-
const packages = getPackageNames();
|
|
148
|
-
|
|
149
|
-
if (packages.length > 1) {
|
|
150
|
-
const allPackages = packages;
|
|
151
|
-
const response = await inquirer.prompt([
|
|
152
|
-
{
|
|
153
|
-
type: 'checkbox',
|
|
154
|
-
name: 'packages',
|
|
155
|
-
message: 'Which packages do you want to generate changesets for?',
|
|
156
|
-
choices: allPackages.map((appPackage) => ({
|
|
157
|
-
name: appPackage.name,
|
|
158
|
-
value: appPackage.name,
|
|
159
|
-
})),
|
|
160
|
-
validate: (input) => {
|
|
161
|
-
if (input.length === 0) {
|
|
162
|
-
return 'Please select at least one package.';
|
|
163
|
-
}
|
|
164
|
-
return true;
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
]);
|
|
168
|
-
|
|
169
|
-
const selectedPackages = allPackages.filter((appPackage) =>
|
|
170
|
-
response.packages.includes(appPackage.name),
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
// Get package contents for all selected packages
|
|
174
|
-
const selectedPackageContents = await Promise.all(
|
|
175
|
-
selectedPackages.map(async (selectedPackage) => {
|
|
176
|
-
return await getPackage(selectedPackage.path);
|
|
177
|
-
}),
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
await createChangesetForPackage(selectedPackageContents);
|
|
181
|
-
} else {
|
|
182
|
-
const mainPackage = await getMainPackage();
|
|
183
|
-
await createChangesetForPackage([mainPackage]);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export async function createChangesetForPackage(packages) {
|
|
188
|
-
try {
|
|
189
|
-
// Step 1: Get the current branch name
|
|
190
|
-
const branchName = await getCurrentBranch();
|
|
191
|
-
|
|
192
|
-
// Step 2: Extract Jira ticket number
|
|
193
|
-
const jiraTicketId = extractJiraTicketId(branchName);
|
|
194
|
-
|
|
195
|
-
// Step 3: Fetch Jira ticket data
|
|
196
|
-
const jiraTicketData = await fetchJiraTicketData(jiraTicketId);
|
|
197
|
-
const jiraSummary = jiraTicketData.fields.summary;
|
|
198
|
-
console.log(
|
|
199
|
-
`Generating release notes for ${jiraTicketId} - ${jiraSummary}`,
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
// Step 4: Generate release notes using OpenAI
|
|
203
|
-
const { change_type, summary } = await generateReleaseNotes(jiraTicketData);
|
|
204
|
-
console.log(`Change type: ${change_type}`);
|
|
205
|
-
console.log(`Release note: ${summary}`);
|
|
206
|
-
|
|
207
|
-
// Step 5: Create a changeset .md file for all packages
|
|
208
|
-
await writeJiraChangesetFile(packages, jiraTicketId, change_type, summary);
|
|
209
|
-
|
|
210
|
-
console.log('Changeset created successfully!');
|
|
211
|
-
} catch (err) {
|
|
212
|
-
console.error(`Error: ${err.message}`);
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
import { zodResponseFormat } from 'openai/helpers/zod';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import { getMainPackage, getPackage, findJiraTicketId } from './util.js';
|
|
8
|
+
import { getPackageNames } from './package-util.js';
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
|
|
11
|
+
async function createChangesetDirectory() {
|
|
12
|
+
try {
|
|
13
|
+
// Use path.join to build a safe path to `.changeset`
|
|
14
|
+
const targetDir = path.join(process.cwd(), '.changeset');
|
|
15
|
+
|
|
16
|
+
// Create the directory recursively if it doesn't exist
|
|
17
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Error creating .changeset directory:', error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Gets the current git branch name
|
|
25
|
+
*/
|
|
26
|
+
async function getCurrentBranch() {
|
|
27
|
+
try {
|
|
28
|
+
const branchName = execSync('git branch --show-current', {
|
|
29
|
+
encoding: 'utf8',
|
|
30
|
+
shell: true,
|
|
31
|
+
}).trim();
|
|
32
|
+
console.log(`Current branch: ${branchName}`);
|
|
33
|
+
return branchName;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error getting current branch:', error.message);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extracts a Jira ticket ID from a branch name
|
|
41
|
+
*/
|
|
42
|
+
function extractJiraTicketId(branchName) {
|
|
43
|
+
const jiraTicketId = findJiraTicketId(branchName);
|
|
44
|
+
if (!jiraTicketId) {
|
|
45
|
+
throw new Error('No Jira ticket found in the branch name.');
|
|
46
|
+
}
|
|
47
|
+
return jiraTicketId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Fetches Jira ticket data from Jira API
|
|
52
|
+
*/
|
|
53
|
+
async function fetchJiraTicketData(jiraTicketId) {
|
|
54
|
+
const jiraBaseUrl = 'https://docupacellc.atlassian.net';
|
|
55
|
+
const jiraEmail = process.env.JIRA_API_EMAIL;
|
|
56
|
+
const jiraApiKey = process.env.JIRA_API_KEY;
|
|
57
|
+
const jiraFullApiKey = `${jiraEmail}:${jiraApiKey}`;
|
|
58
|
+
const jiraUrl = `${jiraBaseUrl}/rest/api/2/issue/${jiraTicketId}`;
|
|
59
|
+
|
|
60
|
+
const jiraResponse = await fetch(jiraUrl, {
|
|
61
|
+
headers: {
|
|
62
|
+
Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString('base64')}`,
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (!jiraResponse.ok) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`Failed to fetch Jira ticket ${jiraTicketId}. Status: ${jiraResponse.status}, Ticket URL: ${jiraUrl}`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return await jiraResponse.json();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Generates release notes using OpenAI
|
|
78
|
+
*/
|
|
79
|
+
async function generateReleaseNotes(jiraTicketData) {
|
|
80
|
+
const openaiClient = new OpenAI({
|
|
81
|
+
apiKey: process.env['OPENAI_API_KEY'],
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const ChangeRequestSchema = z.object({
|
|
85
|
+
change_type: z.enum(['patch', 'minor']),
|
|
86
|
+
summary: z.string(),
|
|
87
|
+
jira_ticket_id: z.string(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const openAiResponse = await openaiClient.chat.completions.create({
|
|
91
|
+
model: 'gpt-4o-mini',
|
|
92
|
+
messages: [
|
|
93
|
+
{
|
|
94
|
+
role: 'system',
|
|
95
|
+
content: `Process JSON from a Jira ticket to generate simple maximum 2 sentence release note for the ticket and determine the change type for bug it should be a patch for new feature it should be a minor change`,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
role: 'user',
|
|
99
|
+
content: JSON.stringify(jiraTicketData),
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
response_format: zodResponseFormat(ChangeRequestSchema, 'changeset_schema'),
|
|
103
|
+
temperature: 0,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const assistantResponse = openAiResponse.choices[0].message.content;
|
|
107
|
+
return JSON.parse(assistantResponse);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Writes the changeset file
|
|
112
|
+
*/
|
|
113
|
+
async function writeJiraChangesetFile(
|
|
114
|
+
packages,
|
|
115
|
+
jiraTicketId,
|
|
116
|
+
changeType,
|
|
117
|
+
summary,
|
|
118
|
+
) {
|
|
119
|
+
const text = `${summary} [${jiraTicketId}]`;
|
|
120
|
+
await writeChangesetFile(packages, jiraTicketId, changeType, text);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function writeChangesetFile(packages, filename, changeType, text) {
|
|
124
|
+
const packageEntries = packages
|
|
125
|
+
.map((pkg) => `'${pkg.name}': ${changeType}`)
|
|
126
|
+
.join('\n');
|
|
127
|
+
|
|
128
|
+
const changesetContent = `---
|
|
129
|
+
${packageEntries}
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
${text}
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
const changesetFile = `./.changeset/${filename}.md`;
|
|
136
|
+
|
|
137
|
+
await createChangesetDirectory();
|
|
138
|
+
await fs.promises.writeFile(changesetFile, changesetContent);
|
|
139
|
+
console.log(`Created changeset file at ${changesetFile}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Main function to create a changeset
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
export async function createChangeset() {
|
|
147
|
+
const packages = getPackageNames();
|
|
148
|
+
|
|
149
|
+
if (packages.length > 1) {
|
|
150
|
+
const allPackages = packages;
|
|
151
|
+
const response = await inquirer.prompt([
|
|
152
|
+
{
|
|
153
|
+
type: 'checkbox',
|
|
154
|
+
name: 'packages',
|
|
155
|
+
message: 'Which packages do you want to generate changesets for?',
|
|
156
|
+
choices: allPackages.map((appPackage) => ({
|
|
157
|
+
name: appPackage.name,
|
|
158
|
+
value: appPackage.name,
|
|
159
|
+
})),
|
|
160
|
+
validate: (input) => {
|
|
161
|
+
if (input.length === 0) {
|
|
162
|
+
return 'Please select at least one package.';
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
168
|
+
|
|
169
|
+
const selectedPackages = allPackages.filter((appPackage) =>
|
|
170
|
+
response.packages.includes(appPackage.name),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// Get package contents for all selected packages
|
|
174
|
+
const selectedPackageContents = await Promise.all(
|
|
175
|
+
selectedPackages.map(async (selectedPackage) => {
|
|
176
|
+
return await getPackage(selectedPackage.path);
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
await createChangesetForPackage(selectedPackageContents);
|
|
181
|
+
} else {
|
|
182
|
+
const mainPackage = await getMainPackage();
|
|
183
|
+
await createChangesetForPackage([mainPackage]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function createChangesetForPackage(packages) {
|
|
188
|
+
try {
|
|
189
|
+
// Step 1: Get the current branch name
|
|
190
|
+
const branchName = await getCurrentBranch();
|
|
191
|
+
|
|
192
|
+
// Step 2: Extract Jira ticket number
|
|
193
|
+
const jiraTicketId = extractJiraTicketId(branchName);
|
|
194
|
+
|
|
195
|
+
// Step 3: Fetch Jira ticket data
|
|
196
|
+
const jiraTicketData = await fetchJiraTicketData(jiraTicketId);
|
|
197
|
+
const jiraSummary = jiraTicketData.fields.summary;
|
|
198
|
+
console.log(
|
|
199
|
+
`Generating release notes for ${jiraTicketId} - ${jiraSummary}`,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
// Step 4: Generate release notes using OpenAI
|
|
203
|
+
const { change_type, summary } = await generateReleaseNotes(jiraTicketData);
|
|
204
|
+
console.log(`Change type: ${change_type}`);
|
|
205
|
+
console.log(`Release note: ${summary}`);
|
|
206
|
+
|
|
207
|
+
// Step 5: Create a changeset .md file for all packages
|
|
208
|
+
await writeJiraChangesetFile(packages, jiraTicketId, change_type, summary);
|
|
209
|
+
|
|
210
|
+
console.log('Changeset created successfully!');
|
|
211
|
+
} catch (err) {
|
|
212
|
+
console.error(`Error: ${err.message}`);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
export function getPackageNames(rootPath = '.') {
|
|
5
|
-
const appsDir = path.join(rootPath, 'apps');
|
|
6
|
-
const packagesDir = path.join(rootPath, 'packages');
|
|
7
|
-
const rootPackageJson = path.join(rootPath, 'package.json');
|
|
8
|
-
|
|
9
|
-
// Check if this is a monorepo (has apps and/or packages directories)
|
|
10
|
-
const hasAppsDir =
|
|
11
|
-
fs.existsSync(appsDir) && fs.statSync(appsDir).isDirectory();
|
|
12
|
-
const hasPackagesDir =
|
|
13
|
-
fs.existsSync(packagesDir) && fs.statSync(packagesDir).isDirectory();
|
|
14
|
-
|
|
15
|
-
if (hasAppsDir || hasPackagesDir) {
|
|
16
|
-
// This is a monorepo
|
|
17
|
-
const packages = [];
|
|
18
|
-
|
|
19
|
-
// Get packages from apps directory
|
|
20
|
-
if (hasAppsDir) {
|
|
21
|
-
const appsPackages = getPackagesFromDirectory(appsDir);
|
|
22
|
-
packages.push(...appsPackages);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Get packages from packages directory
|
|
26
|
-
if (hasPackagesDir) {
|
|
27
|
-
const packagesPackages = getPackagesFromDirectory(packagesDir);
|
|
28
|
-
packages.push(...packagesPackages);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return packages;
|
|
32
|
-
} else {
|
|
33
|
-
// This is not a monorepo, return single package
|
|
34
|
-
if (fs.existsSync(rootPackageJson)) {
|
|
35
|
-
try {
|
|
36
|
-
const packageJson = JSON.parse(
|
|
37
|
-
fs.readFileSync(rootPackageJson, 'utf8'),
|
|
38
|
-
);
|
|
39
|
-
return packageJson.name
|
|
40
|
-
? [{ name: packageJson.name, path: rootPath, content: packageJson }]
|
|
41
|
-
: [];
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error('Error reading root package.json:', error);
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getPackagesFromDirectory(dirPath) {
|
|
52
|
-
const packages = [];
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const items = fs.readdirSync(dirPath);
|
|
56
|
-
|
|
57
|
-
for (const item of items) {
|
|
58
|
-
const itemPath = path.join(dirPath, item);
|
|
59
|
-
const packageJsonPath = path.join(itemPath, 'package.json');
|
|
60
|
-
|
|
61
|
-
// Check if item is a directory and has package.json
|
|
62
|
-
if (
|
|
63
|
-
fs.statSync(itemPath).isDirectory() &&
|
|
64
|
-
fs.existsSync(packageJsonPath)
|
|
65
|
-
) {
|
|
66
|
-
try {
|
|
67
|
-
const packageJson = JSON.parse(
|
|
68
|
-
fs.readFileSync(packageJsonPath, 'utf8'),
|
|
69
|
-
);
|
|
70
|
-
if (packageJson.name) {
|
|
71
|
-
packages.push({
|
|
72
|
-
name: packageJson.name,
|
|
73
|
-
path: itemPath,
|
|
74
|
-
content: packageJson,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error(`Error reading package.json in ${itemPath}:`, error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error(`Error reading directory ${dirPath}:`, error);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return packages;
|
|
87
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export function getPackageNames(rootPath = '.') {
|
|
5
|
+
const appsDir = path.join(rootPath, 'apps');
|
|
6
|
+
const packagesDir = path.join(rootPath, 'packages');
|
|
7
|
+
const rootPackageJson = path.join(rootPath, 'package.json');
|
|
8
|
+
|
|
9
|
+
// Check if this is a monorepo (has apps and/or packages directories)
|
|
10
|
+
const hasAppsDir =
|
|
11
|
+
fs.existsSync(appsDir) && fs.statSync(appsDir).isDirectory();
|
|
12
|
+
const hasPackagesDir =
|
|
13
|
+
fs.existsSync(packagesDir) && fs.statSync(packagesDir).isDirectory();
|
|
14
|
+
|
|
15
|
+
if (hasAppsDir || hasPackagesDir) {
|
|
16
|
+
// This is a monorepo
|
|
17
|
+
const packages = [];
|
|
18
|
+
|
|
19
|
+
// Get packages from apps directory
|
|
20
|
+
if (hasAppsDir) {
|
|
21
|
+
const appsPackages = getPackagesFromDirectory(appsDir);
|
|
22
|
+
packages.push(...appsPackages);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Get packages from packages directory
|
|
26
|
+
if (hasPackagesDir) {
|
|
27
|
+
const packagesPackages = getPackagesFromDirectory(packagesDir);
|
|
28
|
+
packages.push(...packagesPackages);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return packages;
|
|
32
|
+
} else {
|
|
33
|
+
// This is not a monorepo, return single package
|
|
34
|
+
if (fs.existsSync(rootPackageJson)) {
|
|
35
|
+
try {
|
|
36
|
+
const packageJson = JSON.parse(
|
|
37
|
+
fs.readFileSync(rootPackageJson, 'utf8'),
|
|
38
|
+
);
|
|
39
|
+
return packageJson.name
|
|
40
|
+
? [{ name: packageJson.name, path: rootPath, content: packageJson }]
|
|
41
|
+
: [];
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error reading root package.json:', error);
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getPackagesFromDirectory(dirPath) {
|
|
52
|
+
const packages = [];
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const items = fs.readdirSync(dirPath);
|
|
56
|
+
|
|
57
|
+
for (const item of items) {
|
|
58
|
+
const itemPath = path.join(dirPath, item);
|
|
59
|
+
const packageJsonPath = path.join(itemPath, 'package.json');
|
|
60
|
+
|
|
61
|
+
// Check if item is a directory and has package.json
|
|
62
|
+
if (
|
|
63
|
+
fs.statSync(itemPath).isDirectory() &&
|
|
64
|
+
fs.existsSync(packageJsonPath)
|
|
65
|
+
) {
|
|
66
|
+
try {
|
|
67
|
+
const packageJson = JSON.parse(
|
|
68
|
+
fs.readFileSync(packageJsonPath, 'utf8'),
|
|
69
|
+
);
|
|
70
|
+
if (packageJson.name) {
|
|
71
|
+
packages.push({
|
|
72
|
+
name: packageJson.name,
|
|
73
|
+
path: itemPath,
|
|
74
|
+
content: packageJson,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(`Error reading package.json in ${itemPath}:`, error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error(`Error reading directory ${dirPath}:`, error);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return packages;
|
|
87
|
+
}
|