-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b2909d
commit a11e237
Showing
2 changed files
with
140 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,60 @@ | ||
#!/usr/bin/env node | ||
|
||
import "./cli"; | ||
import RegClient from "another-npm-registry-client"; | ||
import npmlog from "npmlog"; | ||
import updateNotifier from "update-notifier"; | ||
import pkg from "../package.json"; | ||
import { makeOpenupmCli } from "./cli"; | ||
import type { DebugLog } from "./domain/logging"; | ||
import { | ||
getAllRegistryPackumentsUsing, | ||
getAuthTokenUsing, | ||
getRegistryPackumentUsing, | ||
searchRegistryUsing, | ||
} from "./io/registry"; | ||
|
||
// Composition root | ||
|
||
const log = npmlog; | ||
|
||
const debugLogToConsole: DebugLog = async function (message, context) { | ||
const contextMessage = | ||
context !== undefined | ||
? `\n${ | ||
context instanceof Error | ||
? context.toString() | ||
: JSON.stringify(context, null, 2) | ||
}` | ||
: ""; | ||
return log.verbose("", `${message}${contextMessage}`); | ||
}; | ||
|
||
const registryClient = new RegClient({ log }); | ||
const fetchPackument = getRegistryPackumentUsing( | ||
registryClient, | ||
debugLogToConsole | ||
); | ||
const searchRegistry = searchRegistryUsing(debugLogToConsole); | ||
const fetchAllPackuments = getAllRegistryPackumentsUsing(debugLogToConsole); | ||
const getAuthToken = getAuthTokenUsing(registryClient, debugLogToConsole); | ||
|
||
const openupmCli = makeOpenupmCli( | ||
fetchPackument, | ||
searchRegistry, | ||
fetchAllPackuments, | ||
getAuthToken, | ||
log, | ||
debugLogToConsole | ||
); | ||
|
||
// Update in case of update | ||
|
||
const notifier = updateNotifier({ pkg }); | ||
notifier.notify(); | ||
|
||
// Run app | ||
|
||
openupmCli.parse(process.argv); | ||
|
||
// print help if no command is given | ||
if (openupmCli.args.length === 0) openupmCli.help(); |