-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-definition.js
37 lines (32 loc) · 1.06 KB
/
build-definition.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-disable @typescript-eslint/no-var-requires */
const { writeFileSync } = require('fs');
const { join } = require('path');
const { lstatSync, readdirSync, readFileSync } = require('fs');
const package = require('./package.json');
const buildVersion = package.version;
const isDirectory = source => lstatSync(source).isDirectory();
const getDirectories = source =>
readdirSync(source)
.map(name => join(source, name))
.filter(isDirectory);
const repos = [];
let count = 0;
getDirectories(__dirname).forEach(dir => {
if (dir.includes('.git')) {
return;
}
const packageJson = JSON.parse(readFileSync(dir + '/package.json', 'utf8'));
if (packageJson.repository) {
count++;
repos.push({
id: count,
repo: packageJson.name.split('/')[1],
label: packageJson.name,
owner: 'Stradivario',
folderName: dir.replace(/^.*[\\\/]/, ''),
url: packageJson.repository.url,
namespace: packageJson.name.split('/')[0].replace('@', '')
});
}
});
writeFileSync('definitions.json', JSON.stringify(repos, null, 2), 'utf8');