@docupace/pipeline 1.0.39-matttest.35 → 1.0.39-matttest.38
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/package.json +2 -1
- package/src/changeset/create.js +40 -24
- package/src/changeset/package-util.js +86 -0
- package/src/next/config.js +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.39-matttest.
|
|
3
|
+
"version": "1.0.39-matttest.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"js-yaml": "^4.1.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"openai": "^4.76.3",
|
|
30
|
+
"semver": "^7.7.2",
|
|
30
31
|
"zod": "^3.24.1",
|
|
31
32
|
"zx": "^8.3.0"
|
|
32
33
|
},
|
package/src/changeset/create.js
CHANGED
|
@@ -4,9 +4,9 @@ import z from 'zod';
|
|
|
4
4
|
import { zodResponseFormat } from 'openai/helpers/zod';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { getAllAppPackages, getAllPackages, isMonoRepo } from '../next/util.js';
|
|
8
7
|
import inquirer from 'inquirer';
|
|
9
8
|
import { getMainPackage, getPackage } from './util.js';
|
|
9
|
+
import { getPackageNames } from './package-util.js';
|
|
10
10
|
|
|
11
11
|
async function createChangesetDirectory() {
|
|
12
12
|
try {
|
|
@@ -103,14 +103,14 @@ async function generateReleaseNotes(jiraTicketData) {
|
|
|
103
103
|
/**
|
|
104
104
|
* Writes the changeset file
|
|
105
105
|
*/
|
|
106
|
-
async function writeChangesetFile(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
async function writeChangesetFile(packages, jiraTicketId, changeType, summary) {
|
|
107
|
+
// Generate the YAML frontmatter for multiple packages
|
|
108
|
+
const packageEntries = packages
|
|
109
|
+
.map((pkg) => `'${pkg.name}': ${changeType}`)
|
|
110
|
+
.join('\n');
|
|
111
|
+
|
|
112
112
|
const changesetContent = `---
|
|
113
|
-
|
|
113
|
+
${packageEntries}
|
|
114
114
|
---
|
|
115
115
|
|
|
116
116
|
${summary} [${jiraTicketId}]
|
|
@@ -127,31 +127,47 @@ ${summary} [${jiraTicketId}]
|
|
|
127
127
|
*/
|
|
128
128
|
|
|
129
129
|
export async function createChangeset() {
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
const packages = getPackageNames();
|
|
131
|
+
|
|
132
|
+
if (packages.length > 1) {
|
|
133
|
+
const allPackages = packages;
|
|
132
134
|
const response = await inquirer.prompt([
|
|
133
135
|
{
|
|
134
|
-
type: '
|
|
135
|
-
name: '
|
|
136
|
-
message: 'Which
|
|
137
|
-
choices: allPackages.map((appPackage) =>
|
|
136
|
+
type: 'checkbox',
|
|
137
|
+
name: 'packages',
|
|
138
|
+
message: 'Which packages do you want to generate changesets for?',
|
|
139
|
+
choices: allPackages.map((appPackage) => ({
|
|
140
|
+
name: appPackage.name,
|
|
141
|
+
value: appPackage.name,
|
|
142
|
+
})),
|
|
143
|
+
validate: (input) => {
|
|
144
|
+
if (input.length === 0) {
|
|
145
|
+
return 'Please select at least one package.';
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
},
|
|
138
149
|
},
|
|
139
150
|
]);
|
|
140
151
|
|
|
141
|
-
const
|
|
142
|
-
(appPackage
|
|
152
|
+
const selectedPackages = allPackages.filter((appPackage) =>
|
|
153
|
+
response.packages.includes(appPackage.name),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// Get package contents for all selected packages
|
|
157
|
+
const selectedPackageContents = await Promise.all(
|
|
158
|
+
selectedPackages.map(async (selectedPackage) => {
|
|
159
|
+
return await getPackage(selectedPackage.path);
|
|
160
|
+
}),
|
|
143
161
|
);
|
|
144
162
|
|
|
145
|
-
|
|
146
|
-
await createChangesetForPackage(selectedPackageContent);
|
|
163
|
+
await createChangesetForPackage(selectedPackageContents);
|
|
147
164
|
} else {
|
|
148
165
|
const mainPackage = await getMainPackage();
|
|
149
|
-
await createChangesetForPackage(mainPackage);
|
|
166
|
+
await createChangesetForPackage([mainPackage]);
|
|
150
167
|
}
|
|
151
168
|
}
|
|
152
169
|
|
|
153
|
-
export async function createChangesetForPackage(
|
|
154
|
-
const componentName = mainPackage.name;
|
|
170
|
+
export async function createChangesetForPackage(packages) {
|
|
155
171
|
try {
|
|
156
172
|
// Step 1: Get the current branch name
|
|
157
173
|
const branchName = await getCurrentBranch();
|
|
@@ -171,10 +187,10 @@ export async function createChangesetForPackage(mainPackage) {
|
|
|
171
187
|
console.log(`Change type: ${change_type}`);
|
|
172
188
|
console.log(`Release note: ${summary}`);
|
|
173
189
|
|
|
174
|
-
// Step 5: Create a changeset .md file
|
|
175
|
-
await writeChangesetFile(
|
|
190
|
+
// Step 5: Create a changeset .md file for all packages
|
|
191
|
+
await writeChangesetFile(packages, jiraTicketId, change_type, summary);
|
|
176
192
|
|
|
177
|
-
console.log('
|
|
193
|
+
console.log('Changeset created successfully!');
|
|
178
194
|
} catch (err) {
|
|
179
195
|
console.error(`Error: ${err.message}`);
|
|
180
196
|
process.exit(1);
|
|
@@ -0,0 +1,86 @@
|
|
|
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 }]
|
|
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
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error(`Error reading package.json in ${itemPath}:`, error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error(`Error reading directory ${dirPath}:`, error);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return packages;
|
|
86
|
+
}
|
package/src/next/config.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
|
|
1
3
|
export const environments = ['dev', 'qa', 'uat', 'stage', 'prod'];
|
|
2
4
|
|
|
5
|
+
const UI_MONO_VERSION = '1.4.0-alpha.0';
|
|
6
|
+
|
|
3
7
|
export const environmentConfig = {
|
|
4
8
|
dev: {
|
|
5
9
|
newUrl: (site) => `https://${site}.dev.dpai.tech`,
|
|
@@ -42,9 +46,13 @@ export const appInfo = {
|
|
|
42
46
|
deployAttributes: ['image.tag'],
|
|
43
47
|
updateConfigFunction: (config) => {
|
|
44
48
|
if (config.image.repository.endsWith('/docupace-ui-main')) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const tag = config.image.tag;
|
|
50
|
+
const version = tag.startsWith('v') ? tag.slice(1) : tag;
|
|
51
|
+
if (semver.gt(version, UI_MONO_VERSION)) {
|
|
52
|
+
const parts = config.image.repository.split('/');
|
|
53
|
+
parts[2] = 'enterprise-ui-app';
|
|
54
|
+
config.image.repository = parts.join('/');
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
return config;
|
|
50
58
|
},
|