1
1
import { setFailed } from "@actions/core" ;
2
- import { cosmicSync , config } from "@anandchowdhary/cosmic" ;
2
+ import { config , cosmicSync } from "@anandchowdhary/cosmic" ;
3
3
import {
4
- Spotify ,
5
- Rescuetime ,
6
- LastFm ,
7
- PocketCasts ,
8
- Wakatime ,
9
4
Clockify ,
5
+ Goodreads ,
10
6
GoogleFit ,
7
+ LastFm ,
11
8
OuraRing ,
12
- Goodreads ,
9
+ PocketCasts ,
10
+ Rescuetime ,
11
+ Spotify ,
13
12
Twitter ,
13
+ Wakatime ,
14
14
} from "@stethoscope-js/integrations" ;
15
- import simpleGit from "simple-git " ;
16
- import { readdir , pathExists , lstat , ensureFile , writeFile } from "fs-extra" ;
15
+ import Dot from "dot-object " ;
16
+ import { ensureFile , lstat , pathExists , readdir , writeFile } from "fs-extra" ;
17
17
import { join } from "path" ;
18
18
import recursiveReaddir from "recursive-readdir" ;
19
- import Dot from "dot-object" ;
20
19
21
20
const dot = new Dot ( "/" ) ;
22
- const git = simpleGit ( ) ;
23
21
cosmicSync ( "stethoscope" ) ;
24
22
25
23
const items = Object . keys ( config ( "integrations" ) || { } ) ;
@@ -41,7 +39,10 @@ export const run = async () => {
41
39
Twitter ,
42
40
] ) {
43
41
const integration = new ClassName ( ) ;
44
- if ( items . includes ( integration . name ) && config ( "integrations" ) [ integration . name ] . frequency === "daily" ) {
42
+ if (
43
+ items . includes ( integration . name ) &&
44
+ config ( "integrations" ) [ integration . name ] . frequency === "daily"
45
+ ) {
45
46
console . log ( "Updating" , integration . name ) ;
46
47
await integration . update ( ) ;
47
48
} else {
@@ -65,7 +66,7 @@ export const run = async () => {
65
66
const files = ( await recursiveReaddir ( join ( "." , "data" , category , "summary" ) ) )
66
67
. map ( ( path ) => path . split ( `${ join ( "." , "data" , category , "summary" ) } /` ) [ 1 ] )
67
68
. sort ( ( a , b ) =>
68
- a . localeCompare ( b , undefined , {
69
+ a . localeCompare ( b , "en" , {
69
70
numeric : true ,
70
71
sensitivity : "base" ,
71
72
} )
@@ -76,8 +77,10 @@ export const run = async () => {
76
77
const prefix = path . join ( "/" ) === "" ? "root" : path . join ( "/" ) ;
77
78
data [ prefix ] = true ;
78
79
} ) ;
79
- const items = recursivelyClean2 (
80
- recursivelyClean1 ( JSON . parse ( JSON . stringify ( dot . object ( data ) ) . replace ( / _ c h e c k _ / g, "" ) ) )
80
+ const items = recursivelyArrange (
81
+ recursivelyClean2 (
82
+ recursivelyClean1 ( JSON . parse ( JSON . stringify ( dot . object ( data ) ) . replace ( / _ c h e c k _ / g, "" ) ) )
83
+ )
81
84
) ;
82
85
await ensureFile ( join ( "." , "data" , category , "api.json" ) ) ;
83
86
await writeFile ( join ( "." , "data" , category , "api.json" ) , JSON . stringify ( items , null , 2 ) ) ;
@@ -119,6 +122,22 @@ function recursivelyClean2(items: any) {
119
122
return items ;
120
123
}
121
124
125
+ function recursivelyArrange ( items : any ) {
126
+ if ( Array . isArray ( items ) ) {
127
+ items = items . sort ( ( a , b ) =>
128
+ a . localeCompare ( b , "en" , {
129
+ numeric : true ,
130
+ sensitivity : "base" ,
131
+ } )
132
+ ) ;
133
+ } else if ( typeof items === "object" ) {
134
+ Object . keys ( items ) . forEach ( ( key ) => {
135
+ items [ key ] = recursivelyArrange ( items [ key ] ) ;
136
+ } ) ;
137
+ }
138
+ return items ;
139
+ }
140
+
122
141
run ( )
123
142
. then ( ( ) => { } )
124
143
. catch ( ( error ) => {
0 commit comments