cricinfo-cli-go 0.1.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.
- package/AGENTS.md +63 -0
- package/CONTRIBUTORS.md +75 -0
- package/LICENSE +21 -0
- package/Makefile +131 -0
- package/README.md +130 -0
- package/bin/cricinfo.js +44 -0
- package/cmd/cricinfo/main.go +15 -0
- package/go.mod +10 -0
- package/go.sum +10 -0
- package/internal/app/app.go +11 -0
- package/internal/app/app_test.go +122 -0
- package/internal/buildinfo/buildinfo.go +16 -0
- package/internal/cli/analysis.go +262 -0
- package/internal/cli/analysis_test.go +175 -0
- package/internal/cli/competitions.go +154 -0
- package/internal/cli/competitions_test.go +165 -0
- package/internal/cli/leagues.go +297 -0
- package/internal/cli/leagues_test.go +194 -0
- package/internal/cli/matches.go +403 -0
- package/internal/cli/matches_test.go +413 -0
- package/internal/cli/players.go +263 -0
- package/internal/cli/players_test.go +384 -0
- package/internal/cli/root.go +141 -0
- package/internal/cli/search.go +119 -0
- package/internal/cli/teams.go +214 -0
- package/internal/cli/teams_test.go +192 -0
- package/internal/cricinfo/analysis.go +1401 -0
- package/internal/cricinfo/analysis_phase15_test.go +267 -0
- package/internal/cricinfo/client.go +471 -0
- package/internal/cricinfo/client_test.go +280 -0
- package/internal/cricinfo/cmd/fixture-refresh/main.go +145 -0
- package/internal/cricinfo/competitions.go +405 -0
- package/internal/cricinfo/competitions_phase13_test.go +234 -0
- package/internal/cricinfo/coverage_ledger.go +122 -0
- package/internal/cricinfo/coverage_ledger_test.go +253 -0
- package/internal/cricinfo/decode.go +115 -0
- package/internal/cricinfo/decode_test.go +100 -0
- package/internal/cricinfo/entity_index.go +618 -0
- package/internal/cricinfo/entity_index_test.go +175 -0
- package/internal/cricinfo/fixture_matrix.go +243 -0
- package/internal/cricinfo/fixture_matrix_test.go +49 -0
- package/internal/cricinfo/fixtures_test.go +264 -0
- package/internal/cricinfo/historical_hydration.go +1641 -0
- package/internal/cricinfo/historical_phase14_test.go +542 -0
- package/internal/cricinfo/leagues.go +1210 -0
- package/internal/cricinfo/leagues_phase12_test.go +324 -0
- package/internal/cricinfo/live_leagues_test.go +169 -0
- package/internal/cricinfo/live_matches_test.go +203 -0
- package/internal/cricinfo/live_matrix_test.go +118 -0
- package/internal/cricinfo/live_players_test.go +122 -0
- package/internal/cricinfo/live_search_test.go +86 -0
- package/internal/cricinfo/live_smoke_test.go +213 -0
- package/internal/cricinfo/live_teams_test.go +104 -0
- package/internal/cricinfo/matches.go +1508 -0
- package/internal/cricinfo/matches_phase7_test.go +207 -0
- package/internal/cricinfo/matches_phase9_test.go +253 -0
- package/internal/cricinfo/normalize_entities.go +1727 -0
- package/internal/cricinfo/normalize_leagues.go +346 -0
- package/internal/cricinfo/players.go +1332 -0
- package/internal/cricinfo/players_phase10_test.go +174 -0
- package/internal/cricinfo/players_phase11_test.go +373 -0
- package/internal/cricinfo/render_contract.go +1088 -0
- package/internal/cricinfo/render_phase4_test.go +633 -0
- package/internal/cricinfo/renderer.go +1689 -0
- package/internal/cricinfo/resolver.go +813 -0
- package/internal/cricinfo/resolver_test.go +244 -0
- package/internal/cricinfo/teams.go +603 -0
- package/internal/cricinfo/teams_phase8_test.go +231 -0
- package/internal/cricinfo/testdata/fixtures/README.md +43 -0
- package/internal/cricinfo/testdata/fixtures/aux-competition-metadata/broadcasts.json +11 -0
- package/internal/cricinfo/testdata/fixtures/aux-competition-metadata/officials.json +150 -0
- package/internal/cricinfo/testdata/fixtures/details-plays/detail-110.json +157 -0
- package/internal/cricinfo/testdata/fixtures/details-plays/detail-52545007.json +145 -0
- package/internal/cricinfo/testdata/fixtures/details-plays/detail-52559021.json +143 -0
- package/internal/cricinfo/testdata/fixtures/details-plays/plays.json +15 -0
- package/internal/cricinfo/testdata/fixtures/endpoint-matrix.tsv +19 -0
- package/internal/cricinfo/testdata/fixtures/innings-fow-partnerships/fow-1.json +12 -0
- package/internal/cricinfo/testdata/fixtures/innings-fow-partnerships/fow.json +42 -0
- package/internal/cricinfo/testdata/fixtures/innings-fow-partnerships/innings-1-2.json +38 -0
- package/internal/cricinfo/testdata/fixtures/innings-fow-partnerships/partnership-1.json +31 -0
- package/internal/cricinfo/testdata/fixtures/innings-fow-partnerships/partnerships.json +42 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/calendar-offdays.json +20 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/calendar-ondays.json +21 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/calendar.json +14 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/season-2025.json +13 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/season-group-1.json +13 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/season-groups.json +11 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/season-type-1.json +13 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/season-types.json +11 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/seasons.json +30 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/standings-item-1.json +72 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/standings-root.json +3 -0
- package/internal/cricinfo/testdata/fixtures/leagues-seasons-standings/standings.json +15 -0
- package/internal/cricinfo/testdata/fixtures/matches-competitions/competition.json +460 -0
- package/internal/cricinfo/testdata/fixtures/matches-competitions/event-1529474.json +86 -0
- package/internal/cricinfo/testdata/fixtures/matches-competitions/matchcards-1527966.json +368 -0
- package/internal/cricinfo/testdata/fixtures/matches-competitions/situation-1529474.json +10 -0
- package/internal/cricinfo/testdata/fixtures/players/athlete-1361257-statistics.json +126 -0
- package/internal/cricinfo/testdata/fixtures/players/athlete-1361257.json +113 -0
- package/internal/cricinfo/testdata/fixtures/players/roster-1361257-linescores-1-1-statistics-0.json +208 -0
- package/internal/cricinfo/testdata/fixtures/players/roster-1361257-linescores-1-2-statistics-0.json +252 -0
- package/internal/cricinfo/testdata/fixtures/players/roster-1361257-linescores.json +74 -0
- package/internal/cricinfo/testdata/fixtures/players/roster-1361257-statistics-0.json +1008 -0
- package/internal/cricinfo/testdata/fixtures/root-discovery/events.json +72 -0
- package/internal/cricinfo/testdata/fixtures/root-discovery/root.json +28 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/competitor-789643.json +40 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/leaders-789643.json +353 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/records-789643.json +91 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/roster-1147772-object.json +231 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/roster-1147772.json +235 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/roster-789643.json +322 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/scores-789643.json +19 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/statistics-789643.json +629 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/team-789643-athletes.json +7 -0
- package/internal/cricinfo/testdata/fixtures/team-competitor/team-789643.json +67 -0
- package/internal/cricinfo/testdata/golden/match-empty.golden +1 -0
- package/internal/cricinfo/testdata/golden/match-list.golden +2 -0
- package/internal/cricinfo/testdata/golden/match-partial.golden +3 -0
- package/internal/cricinfo/types.go +54 -0
- package/package.json +51 -0
- package/scripts/postinstall.js +153 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "http://core.espnuk.org/v2/sports/cricket/teams/789643",
|
|
3
|
+
"id": "789643",
|
|
4
|
+
"uid": "s:200~t:789643",
|
|
5
|
+
"location": "Afghanistan",
|
|
6
|
+
"name": "Boost Region",
|
|
7
|
+
"nickname": "Boost Region",
|
|
8
|
+
"abbreviation": "BOOST",
|
|
9
|
+
"displayName": "Boost Region",
|
|
10
|
+
"shortDisplayName": "BOOST",
|
|
11
|
+
"isNational": false,
|
|
12
|
+
"isActive": true,
|
|
13
|
+
"countryCode": "AF",
|
|
14
|
+
"slug": "boost-region",
|
|
15
|
+
"classes": [
|
|
16
|
+
4,
|
|
17
|
+
5,
|
|
18
|
+
6,
|
|
19
|
+
14
|
|
20
|
+
],
|
|
21
|
+
"event": {
|
|
22
|
+
"date": "2026-04-09T05:30Z",
|
|
23
|
+
"$ref": "http://core.espnuk.org/v2/sports/cricket/leagues/19138/events/1529474"
|
|
24
|
+
},
|
|
25
|
+
"defaultLeague": {
|
|
26
|
+
"$ref": "http://core.espnuk.org/v2/sports/cricket/leagues/19138"
|
|
27
|
+
},
|
|
28
|
+
"color": "",
|
|
29
|
+
"logos": [
|
|
30
|
+
{
|
|
31
|
+
"href": "https://a.espncdn.com/i/teamlogos/cricket/500/789643.png",
|
|
32
|
+
"rel": [
|
|
33
|
+
"full",
|
|
34
|
+
"default"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"athletes": {
|
|
39
|
+
"$ref": "http://core.espnuk.org/v2/sports/cricket/teams/789643/athletes"
|
|
40
|
+
},
|
|
41
|
+
"links": [
|
|
42
|
+
{
|
|
43
|
+
"language": "en",
|
|
44
|
+
"rel": [
|
|
45
|
+
"clubhouse",
|
|
46
|
+
"desktop"
|
|
47
|
+
],
|
|
48
|
+
"href": "https://www.espn.in/cricket/team/_/id/789643/boost-region",
|
|
49
|
+
"text": "Clubhouse",
|
|
50
|
+
"shortText": "Clubhouse",
|
|
51
|
+
"isExternal": false,
|
|
52
|
+
"isPremium": false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"language": "en",
|
|
56
|
+
"rel": [
|
|
57
|
+
"fixtures",
|
|
58
|
+
"desktop"
|
|
59
|
+
],
|
|
60
|
+
"href": "https://www.espn.in/cricket/scores/team/789643/boost-region",
|
|
61
|
+
"text": "Fixtures",
|
|
62
|
+
"shortText": "Fixtures",
|
|
63
|
+
"isExternal": false,
|
|
64
|
+
"isPremium": false
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
No matches found.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package cricinfo
|
|
2
|
+
|
|
3
|
+
import "encoding/json"
|
|
4
|
+
|
|
5
|
+
// Ref is the common Cricinfo hypermedia reference object.
|
|
6
|
+
type Ref struct {
|
|
7
|
+
URL string `json:"$ref"`
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Page is the common paginated response envelope used by many routes.
|
|
11
|
+
type Page[T any] struct {
|
|
12
|
+
Count int `json:"count"`
|
|
13
|
+
Items []T `json:"items"`
|
|
14
|
+
PageCount int `json:"pageCount"`
|
|
15
|
+
PageIndex int `json:"pageIndex"`
|
|
16
|
+
PageSize int `json:"pageSize"`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// RootDiscovery is a minimal shape for the API root resource.
|
|
20
|
+
type RootDiscovery struct {
|
|
21
|
+
Ref string `json:"$ref,omitempty"`
|
|
22
|
+
ID string `json:"id,omitempty"`
|
|
23
|
+
Name string `json:"name,omitempty"`
|
|
24
|
+
Slug string `json:"slug,omitempty"`
|
|
25
|
+
UID string `json:"uid,omitempty"`
|
|
26
|
+
Events *Ref `json:"events,omitempty"`
|
|
27
|
+
Leagues *Ref `json:"leagues,omitempty"`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// StatsObject is a minimal single-object stats payload shape.
|
|
31
|
+
type StatsObject struct {
|
|
32
|
+
Ref string `json:"$ref,omitempty"`
|
|
33
|
+
Athlete *Ref `json:"athlete,omitempty"`
|
|
34
|
+
Competition *Ref `json:"competition,omitempty"`
|
|
35
|
+
Team *Ref `json:"team,omitempty"`
|
|
36
|
+
Splits json.RawMessage `json:"splits"`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Document is a fetched JSON payload plus request/canonical metadata.
|
|
40
|
+
type Document struct {
|
|
41
|
+
RequestedRef string
|
|
42
|
+
CanonicalRef string
|
|
43
|
+
StatusCode int
|
|
44
|
+
Body []byte
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ResolvedDocument is the result of following a pointer chain.
|
|
48
|
+
type ResolvedDocument struct {
|
|
49
|
+
RequestedRef string
|
|
50
|
+
CanonicalRef string
|
|
51
|
+
TraversedRef []string
|
|
52
|
+
StatusCode int
|
|
53
|
+
Body []byte
|
|
54
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cricinfo-cli-go",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cricinfo command line interface",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "amxv",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/amxv/cricinfo-cli.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/amxv/cricinfo-cli#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/amxv/cricinfo-cli/issues"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"cricinfo": "bin/cricinfo.js"
|
|
17
|
+
},
|
|
18
|
+
"config": {
|
|
19
|
+
"cliBinaryName": "cricinfo"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin/cricinfo.js",
|
|
23
|
+
"scripts/postinstall.js",
|
|
24
|
+
"cmd",
|
|
25
|
+
"internal",
|
|
26
|
+
"go.mod",
|
|
27
|
+
"go.sum",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"AGENTS.md",
|
|
31
|
+
"CONTRIBUTORS.md",
|
|
32
|
+
"Makefile"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"postinstall": "node scripts/postinstall.js",
|
|
36
|
+
"test": "node --check bin/cricinfo.js && node --check scripts/postinstall.js",
|
|
37
|
+
"lint": "npm run test",
|
|
38
|
+
"fixtures:refresh": "go run ./internal/cricinfo/cmd/fixture-refresh --write",
|
|
39
|
+
"test:live": "CRICINFO_LIVE_MATRIX=1 go test ./internal/cricinfo -run TestLive -count=1"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"go",
|
|
46
|
+
"cli",
|
|
47
|
+
"template",
|
|
48
|
+
"npm",
|
|
49
|
+
"release"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const https = require("node:https");
|
|
6
|
+
const { spawnSync } = require("node:child_process");
|
|
7
|
+
|
|
8
|
+
const pkg = require("../package.json");
|
|
9
|
+
const cliName = resolveCLIName(pkg);
|
|
10
|
+
|
|
11
|
+
const repoURL = pkg.repository?.url || "";
|
|
12
|
+
const repoMatch = repoURL.match(/github\.com[:/](.+?)\/(.+?)(?:\.git)?$/);
|
|
13
|
+
if (!repoMatch) {
|
|
14
|
+
console.error("package.json repository.url must point to a GitHub repo.");
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const repoOwner = repoMatch[1];
|
|
19
|
+
const repoName = repoMatch[2];
|
|
20
|
+
|
|
21
|
+
const goosMap = {
|
|
22
|
+
darwin: "darwin",
|
|
23
|
+
linux: "linux",
|
|
24
|
+
win32: "windows"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const goarchMap = {
|
|
28
|
+
x64: "amd64",
|
|
29
|
+
arm64: "arm64"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const goos = goosMap[process.platform];
|
|
33
|
+
const goarch = goarchMap[process.arch];
|
|
34
|
+
|
|
35
|
+
const rootDir = path.resolve(__dirname, "..");
|
|
36
|
+
const binDir = path.join(rootDir, "bin");
|
|
37
|
+
const binaryName = process.platform === "win32" ? `${cliName}.exe` : `${cliName}-bin`;
|
|
38
|
+
const destination = path.join(binDir, binaryName);
|
|
39
|
+
|
|
40
|
+
function buildLdflags(version) {
|
|
41
|
+
const resolvedVersion = `${version || ""}`.trim() || "dev";
|
|
42
|
+
return `-s -w -X github.com/amxv/cricinfo-cli/internal/buildinfo.Version=${resolvedVersion}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function main() {
|
|
46
|
+
if (!goos || !goarch) {
|
|
47
|
+
console.warn(`Unsupported platform/arch: ${process.platform}/${process.arch}`);
|
|
48
|
+
fallbackBuildOrExit();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
53
|
+
|
|
54
|
+
const version = pkg.version;
|
|
55
|
+
const assetName = `${cliName}_${goos}_${goarch}${goos === "windows" ? ".exe" : ""}`;
|
|
56
|
+
const assetURL = `https://github.com/${repoOwner}/${repoName}/releases/download/v${version}/${assetName}`;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
await downloadToFile(assetURL, destination);
|
|
60
|
+
if (goos !== "windows") {
|
|
61
|
+
fs.chmodSync(destination, 0o755);
|
|
62
|
+
}
|
|
63
|
+
console.log(`Installed ${cliName} binary from ${assetURL}`);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.warn(`Failed to download prebuilt binary: ${err.message}`);
|
|
66
|
+
fallbackBuildOrExit();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function fallbackBuildOrExit() {
|
|
71
|
+
const hasGo = spawnSync("go", ["version"], { stdio: "ignore" }).status === 0;
|
|
72
|
+
const hasSource = fs.existsSync(path.join(rootDir, "cmd", cliName, "main.go"));
|
|
73
|
+
|
|
74
|
+
if (!hasGo || !hasSource) {
|
|
75
|
+
console.error("Unable to install CLI binary. Missing release asset and local Go build fallback.");
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const result = spawnSync(
|
|
80
|
+
"go",
|
|
81
|
+
["build", "-trimpath", `-ldflags=${buildLdflags(pkg.version)}`, "-o", destination, `./cmd/${cliName}`],
|
|
82
|
+
{ cwd: rootDir, stdio: "inherit" }
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (result.status !== 0) {
|
|
86
|
+
process.exit(result.status || 1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (goos !== "windows") {
|
|
90
|
+
fs.chmodSync(destination, 0o755);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log("Installed CLI binary by building from source.");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function downloadToFile(url, destinationPath) {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const request = https.get(url, (response) => {
|
|
99
|
+
if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
100
|
+
response.resume();
|
|
101
|
+
downloadToFile(response.headers.location, destinationPath).then(resolve).catch(reject);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (response.statusCode !== 200) {
|
|
106
|
+
response.resume();
|
|
107
|
+
reject(new Error(`HTTP ${response.statusCode}`));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const file = fs.createWriteStream(destinationPath);
|
|
112
|
+
response.pipe(file);
|
|
113
|
+
|
|
114
|
+
file.on("finish", () => {
|
|
115
|
+
file.close((err) => {
|
|
116
|
+
if (err) {
|
|
117
|
+
reject(err);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
resolve();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
file.on("error", (err) => {
|
|
125
|
+
fs.rmSync(destinationPath, { force: true });
|
|
126
|
+
reject(err);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
request.on("error", reject);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
main().catch((err) => {
|
|
135
|
+
console.error(err.message);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
function resolveCLIName(packageJSON) {
|
|
140
|
+
const configured = `${packageJSON?.config?.cliBinaryName || ""}`.trim();
|
|
141
|
+
if (configured) {
|
|
142
|
+
return configured;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (packageJSON?.bin && typeof packageJSON.bin === "object") {
|
|
146
|
+
const names = Object.keys(packageJSON.bin);
|
|
147
|
+
if (names.length > 0 && `${names[0]}`.trim()) {
|
|
148
|
+
return `${names[0]}`.trim();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return "cricinfo";
|
|
153
|
+
}
|