@sapphire-sh/utils 3.1.0 → 3.2.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.
@@ -133,6 +133,41 @@ const writeWorkflow = (outputName, template) => {
133
133
  console.log(`wrote ${outputName}`);
134
134
  };
135
135
 
136
+ const writeDependabotConfig = (outputName, template) => {
137
+ const filepath = join(cwd, outputName);
138
+ const manifestDirectories = [];
139
+ const pendingDirectories = [''];
140
+
141
+ while (pendingDirectories.length > 0) {
142
+ const relativeDirectory = pendingDirectories.pop();
143
+
144
+ for (const entry of readdirSync(join(cwd, relativeDirectory), { withFileTypes: true })) {
145
+ if (entry.isDirectory() && entry.name !== 'node_modules' && entry.name !== '.git') {
146
+ pendingDirectories.push(relativeDirectory === '' ? entry.name : `${relativeDirectory}/${entry.name}`);
147
+ } else if (entry.isFile() && entry.name === 'package.json' && relativeDirectory !== '') {
148
+ manifestDirectories.push(`/${relativeDirectory}`);
149
+ }
150
+ }
151
+ }
152
+
153
+ let content = template;
154
+
155
+ if (manifestDirectories.length > 0) {
156
+ const directoryLines = ['/', ...manifestDirectories]
157
+ .toSorted()
158
+ .map((directory) => ` - ${formatYamlValue(directory)}\n`)
159
+ .join('');
160
+ content = template.replace(
161
+ ' - package-ecosystem: npm\n directory: /\n',
162
+ ` - package-ecosystem: npm\n directories:\n${directoryLines}`,
163
+ );
164
+ }
165
+
166
+ mkdirSync(dirname(filepath), { recursive: true });
167
+ writeFileSync(filepath, content);
168
+ console.log(`wrote ${outputName}`);
169
+ };
170
+
136
171
  const collectTemplates = (directory, prefix) => {
137
172
  const relativePaths = [];
138
173
 
@@ -221,6 +256,8 @@ for (const relativePath of collectTemplates(templatesDir, '')) {
221
256
 
222
257
  if (dirname(outputName) === workflowsDir) {
223
258
  writeWorkflow(outputName, readFileSync(join(templatesDir, relativePath), 'utf-8'));
259
+ } else if (outputName === join('.github', 'dependabot.yml')) {
260
+ writeDependabotConfig(outputName, readFileSync(join(templatesDir, relativePath), 'utf-8'));
224
261
  } else if (sectioned.has(outputName)) {
225
262
  const content = readFileSync(join(templatesDir, relativePath), 'utf-8');
226
263
  writeSectioned(outputName, content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire-sh/utils",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "@sapphire-sh/utils",
5
5
  "type": "module",
6
6
  "sideEffects": false,