-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathlist.ts
More file actions
54 lines (47 loc) · 1.46 KB
/
list.ts
File metadata and controls
54 lines (47 loc) · 1.46 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import chalk from 'chalk';
import { fetchPackages } from './utils/fetch-package';
import { getHypermodPackageName } from './utils/package-names';
export default async function list(packages: string[]) {
const configs = [];
for (const packageName of packages) {
try {
const { community, remote } = await fetchPackages(packageName);
community &&
configs.push({
packageName: getHypermodPackageName(packageName),
config: community.config,
});
remote && configs.push({ packageName, config: remote.config });
} catch (error) {
console.warn(
chalk.red(
`Unable to find Hypermod package: ${chalk.bold(packageName)}.`,
),
);
continue;
}
}
configs.forEach(({ packageName, config }) => {
console.log(chalk.bold(packageName));
if (config.transforms) {
console.log(`├─ transforms`);
Object.keys(config.transforms).forEach((transform, index, array) => {
if (index + 1 === array.length) {
console.log(`| └─ ${transform}`);
return;
}
console.log(`| ├─ ${transform}`);
});
}
if (config.presets) {
console.log(`└─ presets`);
Object.keys(config.presets).forEach((transform, index, array) => {
if (index + 1 === array.length) {
console.log(` └─ ${transform}`);
return;
}
console.log(`| ├─ ${transform}`);
});
}
});
}