@docupace/pipeline 1.0.77-alpha.2 → 1.0.77
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/cli.js +71 -0
- package/src/micro/ms-deploy.js +271 -0
- package/src/micro/{publish-ms.js → ms-publish.js} +6 -8
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +81 -81
- package/src/next/cli.js +1 -10
- 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 +93 -95
- 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/deploy-microservice.js +0 -153
|
@@ -1,328 +1,328 @@
|
|
|
1
|
-
// npm i axios
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
4
|
-
import { getPackageNames } from './package-util.js';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { toShortVersion } from './version.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Required env:
|
|
10
|
-
* CONFLUENCE_BASE_URL e.g. "https://docupacellc.atlassian.net/wiki"
|
|
11
|
-
* CONFLUENCE_EMAIL e.g. "you@docupace.com"
|
|
12
|
-
* CONFLUENCE_API_TOKEN Atlassian API token
|
|
13
|
-
*/
|
|
14
|
-
const BASE_URL = process.env.CONFLUENCE_BASE_URL;
|
|
15
|
-
const EMAIL = process.env.CONFLUENCE_EMAIL;
|
|
16
|
-
const API_TOKEN = process.env.CONFLUENCE_API_TOKEN;
|
|
17
|
-
|
|
18
|
-
const getHttpService = () =>
|
|
19
|
-
axios.create({
|
|
20
|
-
baseURL: BASE_URL.replace(/\/+$/, ''),
|
|
21
|
-
auth: { username: EMAIL, password: API_TOKEN },
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
/** ---------- ADF builder: Markdown macro ---------- */
|
|
25
|
-
function adfMarkdown(markdown) {
|
|
26
|
-
return {
|
|
27
|
-
type: 'doc',
|
|
28
|
-
version: 1,
|
|
29
|
-
content: [
|
|
30
|
-
{
|
|
31
|
-
type: 'extension',
|
|
32
|
-
attrs: {
|
|
33
|
-
layout: 'default',
|
|
34
|
-
extensionType: 'com.atlassian.confluence.macro.core',
|
|
35
|
-
extensionKey: 'markdown',
|
|
36
|
-
parameters: {
|
|
37
|
-
macroParams: {
|
|
38
|
-
sourceType: { value: 'MacroBody' },
|
|
39
|
-
darkmode: { value: 'auto' },
|
|
40
|
-
syntax: { value: 'Markdown' },
|
|
41
|
-
attachmentPageId: { value: '' },
|
|
42
|
-
attachmentId: { value: '' },
|
|
43
|
-
url: { value: '' },
|
|
44
|
-
__bodyContent: { value: markdown },
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** ---------- API helpers (v2) ---------- */
|
|
54
|
-
|
|
55
|
-
// get a page (v2) by id
|
|
56
|
-
async function getPage(pageId) {
|
|
57
|
-
const { data } = await getHttpService().get(`/api/v2/pages/${pageId}`);
|
|
58
|
-
return data;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// list child pages (paginated) and return *all* children
|
|
62
|
-
async function listChildPages(parentId) {
|
|
63
|
-
const all = [];
|
|
64
|
-
let next = `/api/v2/pages/${parentId}/children?limit=200`;
|
|
65
|
-
|
|
66
|
-
while (next) {
|
|
67
|
-
const { data } = await getHttpService().get(next);
|
|
68
|
-
if (Array.isArray(data.results)) all.push(...data.results);
|
|
69
|
-
next = data?._links?.next || null;
|
|
70
|
-
}
|
|
71
|
-
return all;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// find a direct child page by exact title
|
|
75
|
-
async function findChildByTitle(parentId, title) {
|
|
76
|
-
const kids = await listChildPages(parentId);
|
|
77
|
-
return kids.find((p) => (p.title || '').trim() === title.trim()) || null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// create a child page under a parent
|
|
81
|
-
async function createChildPage({
|
|
82
|
-
parentId,
|
|
83
|
-
spaceId,
|
|
84
|
-
title,
|
|
85
|
-
adf,
|
|
86
|
-
message = 'Create via API',
|
|
87
|
-
}) {
|
|
88
|
-
const payload = {
|
|
89
|
-
status: 'current',
|
|
90
|
-
title,
|
|
91
|
-
spaceId,
|
|
92
|
-
parentId,
|
|
93
|
-
body: {
|
|
94
|
-
atlas_doc_format: {
|
|
95
|
-
value: adf,
|
|
96
|
-
representation: 'atlas_doc_format',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
version: { number: 1, message, minorEdit: false },
|
|
100
|
-
};
|
|
101
|
-
const { data } = await getHttpService().post(`/api/v2/pages`, payload);
|
|
102
|
-
return data;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// update an existing page (replace body + optionally title)
|
|
106
|
-
async function updatePage({
|
|
107
|
-
page,
|
|
108
|
-
title = page.title,
|
|
109
|
-
adf,
|
|
110
|
-
message = 'Update via API',
|
|
111
|
-
}) {
|
|
112
|
-
if (!page.version) {
|
|
113
|
-
page = await getPage(page.id);
|
|
114
|
-
}
|
|
115
|
-
const payload = {
|
|
116
|
-
id: page.id,
|
|
117
|
-
status: 'current',
|
|
118
|
-
title,
|
|
119
|
-
spaceId: page.spaceId,
|
|
120
|
-
body: {
|
|
121
|
-
atlas_doc_format: {
|
|
122
|
-
value: adf,
|
|
123
|
-
representation: 'atlas_doc_format',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
version: {
|
|
127
|
-
number: page.version.number + 1,
|
|
128
|
-
message,
|
|
129
|
-
minorEdit: false,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
const { data } = await getHttpService().put(
|
|
133
|
-
`/api/v2/pages/${page.id}`,
|
|
134
|
-
payload,
|
|
135
|
-
);
|
|
136
|
-
return data;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const childPagesAdf = {
|
|
140
|
-
type: 'doc',
|
|
141
|
-
version: 1,
|
|
142
|
-
content: [
|
|
143
|
-
{
|
|
144
|
-
type: 'extension',
|
|
145
|
-
attrs: {
|
|
146
|
-
extensionType: 'com.atlassian.confluence.macro.core',
|
|
147
|
-
extensionKey: 'children',
|
|
148
|
-
layout: 'default',
|
|
149
|
-
parameters: {
|
|
150
|
-
macroParams: {
|
|
151
|
-
allChildren: { value: 'true' },
|
|
152
|
-
},
|
|
153
|
-
macroMetadata: {
|
|
154
|
-
macroId: { value: '9ea4beb6-ac0a-42d7-baf1-e8e6eca01bfd' },
|
|
155
|
-
schemaVersion: { value: '2' },
|
|
156
|
-
title: { value: 'Child pages' },
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
localId: '4890f00c-c519-4947-a60c-0c3b7e1c7b72',
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
/** ---------- Main upsert workflow ---------- */
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Upsert release notes at: Versions(parent) -> Version(title) -> Component(title)
|
|
169
|
-
*
|
|
170
|
-
* @param {object} args
|
|
171
|
-
* @param {string} args.versionsParentId - Page ID of the "Versions" page
|
|
172
|
-
* @param {string} args.versionTitle - e.g. "Version 1"
|
|
173
|
-
* @param {string} args.componentTitle - e.g. "Component A"
|
|
174
|
-
* @param {string} args.markdown - Release notes markdown for the component page
|
|
175
|
-
*
|
|
176
|
-
* @returns {Promise<{versionPage:any, componentPage:any}>}
|
|
177
|
-
*/
|
|
178
|
-
export async function upsertReleaseNotes({
|
|
179
|
-
versionsParentId,
|
|
180
|
-
version,
|
|
181
|
-
component,
|
|
182
|
-
markdown,
|
|
183
|
-
group,
|
|
184
|
-
}) {
|
|
185
|
-
if (!BASE_URL || !EMAIL || !API_TOKEN) {
|
|
186
|
-
throw new Error(
|
|
187
|
-
'Missing required env: CONFLUENCE_BASE_URL, CONFLUENCE_EMAIL, CONFLUENCE_API_TOKEN',
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!versionsParentId || !version || !component) {
|
|
192
|
-
throw new Error(
|
|
193
|
-
'versionsParentId, versionTitle, and componentTitle are required',
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!markdown || markdown.trim() === '') {
|
|
198
|
-
throw new Error('markdown content is required and cannot be empty');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// 1) fetch the parent to get spaceId
|
|
202
|
-
const parent = await getPage(versionsParentId);
|
|
203
|
-
const spaceId = parent.spaceId;
|
|
204
|
-
|
|
205
|
-
const versionTitle = `Docupace ${group} - Version ${version}`;
|
|
206
|
-
// 2) ensure Version page under parent
|
|
207
|
-
let versionPage = await findChildByTitle(parent.id, versionTitle);
|
|
208
|
-
if (!versionPage) {
|
|
209
|
-
versionPage = await createChildPage({
|
|
210
|
-
parentId: parent.id,
|
|
211
|
-
spaceId,
|
|
212
|
-
title: versionTitle,
|
|
213
|
-
adf: JSON.stringify(childPagesAdf),
|
|
214
|
-
message: `Create version page ${versionTitle}`,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const componentTitle = `${versionTitle} - ${component} Changelog`;
|
|
219
|
-
|
|
220
|
-
// 3) ensure Component page under Version
|
|
221
|
-
let componentPage = await findChildByTitle(versionPage.id, componentTitle);
|
|
222
|
-
const adf = adfMarkdown(markdown);
|
|
223
|
-
|
|
224
|
-
if (!componentPage) {
|
|
225
|
-
componentPage = await createChildPage({
|
|
226
|
-
parentId: versionPage.id,
|
|
227
|
-
spaceId,
|
|
228
|
-
title: componentTitle,
|
|
229
|
-
adf: JSON.stringify(adf),
|
|
230
|
-
message: `Create component page ${componentTitle}`,
|
|
231
|
-
});
|
|
232
|
-
} else {
|
|
233
|
-
// update existing component page with new markdown
|
|
234
|
-
componentPage = await updatePage({
|
|
235
|
-
page: componentPage,
|
|
236
|
-
title: componentTitle,
|
|
237
|
-
adf: JSON.stringify(adf),
|
|
238
|
-
message: `Update component page ${componentTitle}`,
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return { versionPage, componentPage };
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Upsert release notes from a markdown file
|
|
247
|
-
*
|
|
248
|
-
* @param {object} args
|
|
249
|
-
* @param {string} args.versionTitle - e.g. "Version 1"
|
|
250
|
-
* @param {string} args.componentTitle - e.g. "Component A"
|
|
251
|
-
* @param {string} args.markdownFile - Path to markdown file
|
|
252
|
-
*
|
|
253
|
-
* @returns {Promise<{versionPage:any, componentPage:any}>}
|
|
254
|
-
*/
|
|
255
|
-
export async function upsertReleaseNotesFromFile({
|
|
256
|
-
version,
|
|
257
|
-
component,
|
|
258
|
-
markdownFile,
|
|
259
|
-
group,
|
|
260
|
-
}) {
|
|
261
|
-
if (!group) {
|
|
262
|
-
throw new Error('changelog.group must be specified in package.json');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const versionsParentId =
|
|
266
|
-
process.env[`CONFLUENCE_${group.toUpperCase()}_PARENT_ID`];
|
|
267
|
-
|
|
268
|
-
if (!versionsParentId) {
|
|
269
|
-
throw new Error(
|
|
270
|
-
`CONFLUENCE_${group.toUpperCase()}_PARENT_ID environment variable is required`,
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (!markdownFile) {
|
|
275
|
-
throw new Error('markdownFile is required');
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Read markdown content from file
|
|
279
|
-
const markdown = readFileSync(markdownFile, 'utf8');
|
|
280
|
-
|
|
281
|
-
return upsertReleaseNotes({
|
|
282
|
-
versionsParentId,
|
|
283
|
-
version,
|
|
284
|
-
component,
|
|
285
|
-
markdown,
|
|
286
|
-
group,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export async function updateWikiWithVersion(releases) {
|
|
291
|
-
const packageNames = getPackageNames();
|
|
292
|
-
console.log(releases);
|
|
293
|
-
|
|
294
|
-
const promises = packageNames
|
|
295
|
-
.filter(
|
|
296
|
-
(packageName) =>
|
|
297
|
-
releases.find((release) => release.name == packageName.name) &&
|
|
298
|
-
packageName.content?.changelog?.component,
|
|
299
|
-
)
|
|
300
|
-
.map(async (packageName) => {
|
|
301
|
-
try {
|
|
302
|
-
const release = releases.find(
|
|
303
|
-
(release) => release.name == packageName.name,
|
|
304
|
-
);
|
|
305
|
-
await upsertReleaseNotesFromFile({
|
|
306
|
-
version: toShortVersion(release.newVersion),
|
|
307
|
-
component: packageName.content.changelog?.component,
|
|
308
|
-
markdownFile: path.join(packageName.path, 'CHANGELOG.md'),
|
|
309
|
-
group: packageName.content.changelog?.group,
|
|
310
|
-
});
|
|
311
|
-
console.log(`✅ Successfully updated wiki for ${packageName.name}`);
|
|
312
|
-
} catch (error) {
|
|
313
|
-
console.error(
|
|
314
|
-
`❌ Failed to update wiki for ${packageName.name}:`,
|
|
315
|
-
error.message,
|
|
316
|
-
);
|
|
317
|
-
// Continue with other packages instead of stopping the build
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
try {
|
|
322
|
-
await Promise.all(promises);
|
|
323
|
-
console.log('✅ Wiki update process completed');
|
|
324
|
-
} catch (error) {
|
|
325
|
-
console.error('❌ Error during wiki update process:', error.message);
|
|
326
|
-
// Don't throw the error to prevent build failure
|
|
327
|
-
}
|
|
328
|
-
}
|
|
1
|
+
// npm i axios
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { getPackageNames } from './package-util.js';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { toShortVersion } from './version.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Required env:
|
|
10
|
+
* CONFLUENCE_BASE_URL e.g. "https://docupacellc.atlassian.net/wiki"
|
|
11
|
+
* CONFLUENCE_EMAIL e.g. "you@docupace.com"
|
|
12
|
+
* CONFLUENCE_API_TOKEN Atlassian API token
|
|
13
|
+
*/
|
|
14
|
+
const BASE_URL = process.env.CONFLUENCE_BASE_URL;
|
|
15
|
+
const EMAIL = process.env.CONFLUENCE_EMAIL;
|
|
16
|
+
const API_TOKEN = process.env.CONFLUENCE_API_TOKEN;
|
|
17
|
+
|
|
18
|
+
const getHttpService = () =>
|
|
19
|
+
axios.create({
|
|
20
|
+
baseURL: BASE_URL.replace(/\/+$/, ''),
|
|
21
|
+
auth: { username: EMAIL, password: API_TOKEN },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/** ---------- ADF builder: Markdown macro ---------- */
|
|
25
|
+
function adfMarkdown(markdown) {
|
|
26
|
+
return {
|
|
27
|
+
type: 'doc',
|
|
28
|
+
version: 1,
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'extension',
|
|
32
|
+
attrs: {
|
|
33
|
+
layout: 'default',
|
|
34
|
+
extensionType: 'com.atlassian.confluence.macro.core',
|
|
35
|
+
extensionKey: 'markdown',
|
|
36
|
+
parameters: {
|
|
37
|
+
macroParams: {
|
|
38
|
+
sourceType: { value: 'MacroBody' },
|
|
39
|
+
darkmode: { value: 'auto' },
|
|
40
|
+
syntax: { value: 'Markdown' },
|
|
41
|
+
attachmentPageId: { value: '' },
|
|
42
|
+
attachmentId: { value: '' },
|
|
43
|
+
url: { value: '' },
|
|
44
|
+
__bodyContent: { value: markdown },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** ---------- API helpers (v2) ---------- */
|
|
54
|
+
|
|
55
|
+
// get a page (v2) by id
|
|
56
|
+
async function getPage(pageId) {
|
|
57
|
+
const { data } = await getHttpService().get(`/api/v2/pages/${pageId}`);
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// list child pages (paginated) and return *all* children
|
|
62
|
+
async function listChildPages(parentId) {
|
|
63
|
+
const all = [];
|
|
64
|
+
let next = `/api/v2/pages/${parentId}/children?limit=200`;
|
|
65
|
+
|
|
66
|
+
while (next) {
|
|
67
|
+
const { data } = await getHttpService().get(next);
|
|
68
|
+
if (Array.isArray(data.results)) all.push(...data.results);
|
|
69
|
+
next = data?._links?.next || null;
|
|
70
|
+
}
|
|
71
|
+
return all;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// find a direct child page by exact title
|
|
75
|
+
async function findChildByTitle(parentId, title) {
|
|
76
|
+
const kids = await listChildPages(parentId);
|
|
77
|
+
return kids.find((p) => (p.title || '').trim() === title.trim()) || null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// create a child page under a parent
|
|
81
|
+
async function createChildPage({
|
|
82
|
+
parentId,
|
|
83
|
+
spaceId,
|
|
84
|
+
title,
|
|
85
|
+
adf,
|
|
86
|
+
message = 'Create via API',
|
|
87
|
+
}) {
|
|
88
|
+
const payload = {
|
|
89
|
+
status: 'current',
|
|
90
|
+
title,
|
|
91
|
+
spaceId,
|
|
92
|
+
parentId,
|
|
93
|
+
body: {
|
|
94
|
+
atlas_doc_format: {
|
|
95
|
+
value: adf,
|
|
96
|
+
representation: 'atlas_doc_format',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
version: { number: 1, message, minorEdit: false },
|
|
100
|
+
};
|
|
101
|
+
const { data } = await getHttpService().post(`/api/v2/pages`, payload);
|
|
102
|
+
return data;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// update an existing page (replace body + optionally title)
|
|
106
|
+
async function updatePage({
|
|
107
|
+
page,
|
|
108
|
+
title = page.title,
|
|
109
|
+
adf,
|
|
110
|
+
message = 'Update via API',
|
|
111
|
+
}) {
|
|
112
|
+
if (!page.version) {
|
|
113
|
+
page = await getPage(page.id);
|
|
114
|
+
}
|
|
115
|
+
const payload = {
|
|
116
|
+
id: page.id,
|
|
117
|
+
status: 'current',
|
|
118
|
+
title,
|
|
119
|
+
spaceId: page.spaceId,
|
|
120
|
+
body: {
|
|
121
|
+
atlas_doc_format: {
|
|
122
|
+
value: adf,
|
|
123
|
+
representation: 'atlas_doc_format',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
version: {
|
|
127
|
+
number: page.version.number + 1,
|
|
128
|
+
message,
|
|
129
|
+
minorEdit: false,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
const { data } = await getHttpService().put(
|
|
133
|
+
`/api/v2/pages/${page.id}`,
|
|
134
|
+
payload,
|
|
135
|
+
);
|
|
136
|
+
return data;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const childPagesAdf = {
|
|
140
|
+
type: 'doc',
|
|
141
|
+
version: 1,
|
|
142
|
+
content: [
|
|
143
|
+
{
|
|
144
|
+
type: 'extension',
|
|
145
|
+
attrs: {
|
|
146
|
+
extensionType: 'com.atlassian.confluence.macro.core',
|
|
147
|
+
extensionKey: 'children',
|
|
148
|
+
layout: 'default',
|
|
149
|
+
parameters: {
|
|
150
|
+
macroParams: {
|
|
151
|
+
allChildren: { value: 'true' },
|
|
152
|
+
},
|
|
153
|
+
macroMetadata: {
|
|
154
|
+
macroId: { value: '9ea4beb6-ac0a-42d7-baf1-e8e6eca01bfd' },
|
|
155
|
+
schemaVersion: { value: '2' },
|
|
156
|
+
title: { value: 'Child pages' },
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
localId: '4890f00c-c519-4947-a60c-0c3b7e1c7b72',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** ---------- Main upsert workflow ---------- */
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Upsert release notes at: Versions(parent) -> Version(title) -> Component(title)
|
|
169
|
+
*
|
|
170
|
+
* @param {object} args
|
|
171
|
+
* @param {string} args.versionsParentId - Page ID of the "Versions" page
|
|
172
|
+
* @param {string} args.versionTitle - e.g. "Version 1"
|
|
173
|
+
* @param {string} args.componentTitle - e.g. "Component A"
|
|
174
|
+
* @param {string} args.markdown - Release notes markdown for the component page
|
|
175
|
+
*
|
|
176
|
+
* @returns {Promise<{versionPage:any, componentPage:any}>}
|
|
177
|
+
*/
|
|
178
|
+
export async function upsertReleaseNotes({
|
|
179
|
+
versionsParentId,
|
|
180
|
+
version,
|
|
181
|
+
component,
|
|
182
|
+
markdown,
|
|
183
|
+
group,
|
|
184
|
+
}) {
|
|
185
|
+
if (!BASE_URL || !EMAIL || !API_TOKEN) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
'Missing required env: CONFLUENCE_BASE_URL, CONFLUENCE_EMAIL, CONFLUENCE_API_TOKEN',
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!versionsParentId || !version || !component) {
|
|
192
|
+
throw new Error(
|
|
193
|
+
'versionsParentId, versionTitle, and componentTitle are required',
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!markdown || markdown.trim() === '') {
|
|
198
|
+
throw new Error('markdown content is required and cannot be empty');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// 1) fetch the parent to get spaceId
|
|
202
|
+
const parent = await getPage(versionsParentId);
|
|
203
|
+
const spaceId = parent.spaceId;
|
|
204
|
+
|
|
205
|
+
const versionTitle = `Docupace ${group} - Version ${version}`;
|
|
206
|
+
// 2) ensure Version page under parent
|
|
207
|
+
let versionPage = await findChildByTitle(parent.id, versionTitle);
|
|
208
|
+
if (!versionPage) {
|
|
209
|
+
versionPage = await createChildPage({
|
|
210
|
+
parentId: parent.id,
|
|
211
|
+
spaceId,
|
|
212
|
+
title: versionTitle,
|
|
213
|
+
adf: JSON.stringify(childPagesAdf),
|
|
214
|
+
message: `Create version page ${versionTitle}`,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const componentTitle = `${versionTitle} - ${component} Changelog`;
|
|
219
|
+
|
|
220
|
+
// 3) ensure Component page under Version
|
|
221
|
+
let componentPage = await findChildByTitle(versionPage.id, componentTitle);
|
|
222
|
+
const adf = adfMarkdown(markdown);
|
|
223
|
+
|
|
224
|
+
if (!componentPage) {
|
|
225
|
+
componentPage = await createChildPage({
|
|
226
|
+
parentId: versionPage.id,
|
|
227
|
+
spaceId,
|
|
228
|
+
title: componentTitle,
|
|
229
|
+
adf: JSON.stringify(adf),
|
|
230
|
+
message: `Create component page ${componentTitle}`,
|
|
231
|
+
});
|
|
232
|
+
} else {
|
|
233
|
+
// update existing component page with new markdown
|
|
234
|
+
componentPage = await updatePage({
|
|
235
|
+
page: componentPage,
|
|
236
|
+
title: componentTitle,
|
|
237
|
+
adf: JSON.stringify(adf),
|
|
238
|
+
message: `Update component page ${componentTitle}`,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return { versionPage, componentPage };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Upsert release notes from a markdown file
|
|
247
|
+
*
|
|
248
|
+
* @param {object} args
|
|
249
|
+
* @param {string} args.versionTitle - e.g. "Version 1"
|
|
250
|
+
* @param {string} args.componentTitle - e.g. "Component A"
|
|
251
|
+
* @param {string} args.markdownFile - Path to markdown file
|
|
252
|
+
*
|
|
253
|
+
* @returns {Promise<{versionPage:any, componentPage:any}>}
|
|
254
|
+
*/
|
|
255
|
+
export async function upsertReleaseNotesFromFile({
|
|
256
|
+
version,
|
|
257
|
+
component,
|
|
258
|
+
markdownFile,
|
|
259
|
+
group,
|
|
260
|
+
}) {
|
|
261
|
+
if (!group) {
|
|
262
|
+
throw new Error('changelog.group must be specified in package.json');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const versionsParentId =
|
|
266
|
+
process.env[`CONFLUENCE_${group.toUpperCase()}_PARENT_ID`];
|
|
267
|
+
|
|
268
|
+
if (!versionsParentId) {
|
|
269
|
+
throw new Error(
|
|
270
|
+
`CONFLUENCE_${group.toUpperCase()}_PARENT_ID environment variable is required`,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!markdownFile) {
|
|
275
|
+
throw new Error('markdownFile is required');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Read markdown content from file
|
|
279
|
+
const markdown = readFileSync(markdownFile, 'utf8');
|
|
280
|
+
|
|
281
|
+
return upsertReleaseNotes({
|
|
282
|
+
versionsParentId,
|
|
283
|
+
version,
|
|
284
|
+
component,
|
|
285
|
+
markdown,
|
|
286
|
+
group,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export async function updateWikiWithVersion(releases) {
|
|
291
|
+
const packageNames = getPackageNames();
|
|
292
|
+
console.log(releases);
|
|
293
|
+
|
|
294
|
+
const promises = packageNames
|
|
295
|
+
.filter(
|
|
296
|
+
(packageName) =>
|
|
297
|
+
releases.find((release) => release.name == packageName.name) &&
|
|
298
|
+
packageName.content?.changelog?.component,
|
|
299
|
+
)
|
|
300
|
+
.map(async (packageName) => {
|
|
301
|
+
try {
|
|
302
|
+
const release = releases.find(
|
|
303
|
+
(release) => release.name == packageName.name,
|
|
304
|
+
);
|
|
305
|
+
await upsertReleaseNotesFromFile({
|
|
306
|
+
version: toShortVersion(release.newVersion),
|
|
307
|
+
component: packageName.content.changelog?.component,
|
|
308
|
+
markdownFile: path.join(packageName.path, 'CHANGELOG.md'),
|
|
309
|
+
group: packageName.content.changelog?.group,
|
|
310
|
+
});
|
|
311
|
+
console.log(`✅ Successfully updated wiki for ${packageName.name}`);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error(
|
|
314
|
+
`❌ Failed to update wiki for ${packageName.name}:`,
|
|
315
|
+
error.message,
|
|
316
|
+
);
|
|
317
|
+
// Continue with other packages instead of stopping the build
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
await Promise.all(promises);
|
|
323
|
+
console.log('✅ Wiki update process completed');
|
|
324
|
+
} catch (error) {
|
|
325
|
+
console.error('❌ Error during wiki update process:', error.message);
|
|
326
|
+
// Don't throw the error to prevent build failure
|
|
327
|
+
}
|
|
328
|
+
}
|