@sapphire-sh/utils 3.3.0 → 3.5.0
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/bin/sapphire-bootstrap.js +40 -2
- package/package.json +1 -1
|
@@ -62,6 +62,32 @@ const readWorkflowValues = () => {
|
|
|
62
62
|
return JSON.parse(readFileSync(filepath, 'utf-8'));
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
const codeOwnersPath = join('.github', 'CODEOWNERS');
|
|
66
|
+
|
|
67
|
+
const readCodeOwnerAssignees = () => {
|
|
68
|
+
const filepath = join(cwd, codeOwnersPath);
|
|
69
|
+
|
|
70
|
+
if (existsSync(filepath) === false) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let assignees = [];
|
|
75
|
+
|
|
76
|
+
for (const line of readFileSync(filepath, 'utf-8').split('\n')) {
|
|
77
|
+
const tokens = line.trim().split(/\s+/);
|
|
78
|
+
const commentIndex = tokens.findIndex((token) => token.startsWith('#'));
|
|
79
|
+
const [pattern, ...owners] = commentIndex === -1 ? tokens : tokens.slice(0, commentIndex);
|
|
80
|
+
|
|
81
|
+
if (pattern === '*') {
|
|
82
|
+
assignees = owners
|
|
83
|
+
.filter((owner) => owner.startsWith('@') && owner.includes('/') === false)
|
|
84
|
+
.map((owner) => owner.slice(1));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return assignees;
|
|
89
|
+
};
|
|
90
|
+
|
|
65
91
|
const isSelf = readPackageName() === selfPackageName;
|
|
66
92
|
const workflowValues = readWorkflowValues();
|
|
67
93
|
|
|
@@ -137,10 +163,10 @@ const writeWorkflow = (outputName, template) => {
|
|
|
137
163
|
const writeDependabotConfig = (outputName, template) => {
|
|
138
164
|
const filepath = join(cwd, outputName);
|
|
139
165
|
const manifestDirectories = [];
|
|
140
|
-
const trackedFiles = spawnSync('git', ['ls-files'], { cwd, encoding: 'utf-8' });
|
|
166
|
+
const trackedFiles = spawnSync('git', ['ls-files', '-z'], { cwd, encoding: 'utf-8' });
|
|
141
167
|
|
|
142
168
|
if (trackedFiles.status === 0) {
|
|
143
|
-
for (const path of trackedFiles.stdout.split('\
|
|
169
|
+
for (const path of trackedFiles.stdout.split('\0')) {
|
|
144
170
|
if (basename(path) === 'package.json' && dirname(path) !== '.') {
|
|
145
171
|
manifestDirectories.push(`/${dirname(path)}`);
|
|
146
172
|
}
|
|
@@ -174,6 +200,18 @@ const writeDependabotConfig = (outputName, template) => {
|
|
|
174
200
|
);
|
|
175
201
|
}
|
|
176
202
|
|
|
203
|
+
const assignees = readCodeOwnerAssignees();
|
|
204
|
+
|
|
205
|
+
if (assignees.length > 0) {
|
|
206
|
+
const assigneeLines = assignees.map((assignee) => ` - ${formatYamlValue(assignee)}\n`).join('');
|
|
207
|
+
content = content
|
|
208
|
+
.split(/(?=^ {2}- package-ecosystem: )/m)
|
|
209
|
+
.map((entry) =>
|
|
210
|
+
entry.startsWith(' - package-ecosystem: ') === true ? `${entry} assignees:\n${assigneeLines}` : entry,
|
|
211
|
+
)
|
|
212
|
+
.join('');
|
|
213
|
+
}
|
|
214
|
+
|
|
177
215
|
mkdirSync(dirname(filepath), { recursive: true });
|
|
178
216
|
writeFileSync(filepath, content);
|
|
179
217
|
console.log(`wrote ${outputName}`);
|