oxc-configs 0.0.1 → 0.0.2
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/README.md +0 -1
- package/index.ts +8 -23
- package/package.json +1 -1
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { cancel, intro, isCancel, log, outro, select, spinner } from '@clack/prompts';
|
|
4
4
|
import { $ } from 'bun';
|
|
5
|
-
import { bold, green,
|
|
5
|
+
import { bold, green, yellow } from 'picocolors';
|
|
6
6
|
|
|
7
7
|
enum Template {
|
|
8
8
|
ReactTypeScript = 'react-typescript',
|
|
@@ -16,8 +16,6 @@ async function main() {
|
|
|
16
16
|
|
|
17
17
|
intro(yellow(`@simek/oxc-configs`));
|
|
18
18
|
|
|
19
|
-
await checkGHCLIAvailability();
|
|
20
|
-
|
|
21
19
|
if (!template) {
|
|
22
20
|
template = await select({
|
|
23
21
|
message: 'Select OXC toolset configs template to download:',
|
|
@@ -51,23 +49,9 @@ async function main() {
|
|
|
51
49
|
await fetchConfigsFromRepo(template, '.oxfmtrc.json');
|
|
52
50
|
await fetchConfigsFromRepo(template, '.oxlintrc.json');
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
}
|
|
52
|
+
await $`bunx --silent oxfmt@latest .oxfmtrc.json .oxlintrc.json`;
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
await $`gh auth status`.quiet();
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (error instanceof $.ShellError) {
|
|
62
|
-
const message = error.stderr.toString();
|
|
63
|
-
if (message.includes('You are not logged')) {
|
|
64
|
-
log.error(red(message));
|
|
65
|
-
} else {
|
|
66
|
-
log.error(red('GitHub CLI need to be installed on your system, see: https://cli.github.com/.'));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
54
|
+
outro(green('All done!'));
|
|
71
55
|
}
|
|
72
56
|
|
|
73
57
|
export async function fetchConfigsFromRepo(template: string, fileName: string) {
|
|
@@ -94,11 +78,12 @@ export async function fetchConfigsFromRepo(template: string, fileName: string) {
|
|
|
94
78
|
const progress = spinner();
|
|
95
79
|
progress.start(`Fetching ${bold(fileName)} config file...`);
|
|
96
80
|
|
|
97
|
-
const configContent = await
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
const configContent = await fetch(
|
|
82
|
+
`https://raw.githubusercontent.com/simek/oxc-configs/HEAD/${template}/${fileName}`
|
|
83
|
+
);
|
|
100
84
|
|
|
101
|
-
await
|
|
85
|
+
const config = await configContent.json();
|
|
86
|
+
await Bun.write(fileName, JSON.stringify(config));
|
|
102
87
|
|
|
103
88
|
progress.stop(`${bold(fileName)} fetched and written`);
|
|
104
89
|
}
|