-
Notifications
You must be signed in to change notification settings - Fork 0
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
77e2f8f
commit b40adfd
Showing
4 changed files
with
58 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { createExecutionContext, parseCommonOptions } from '../cli'; | ||
import { CliCommandMetadata } from './cli-option'; | ||
import { SoloRcConfig } from './solorc'; | ||
|
||
const commandName = `solo-init`; | ||
|
||
async function soloInitCommand(this: any, str: any, options: any) { | ||
const executionContext = createExecutionContext(parseCommonOptions(options)); | ||
const { logger } = executionContext; | ||
|
||
const homeDir = process.env.HOME || process.env.USERPROFILE; | ||
if (!homeDir) { | ||
const message = 'HOME or USERPROFILE environment variable not set.'; | ||
logger.error(message); | ||
return; | ||
} | ||
|
||
const cliConfigLocation = path.join(homeDir, '.solorc.json'); | ||
if (fs.existsSync(cliConfigLocation)) { | ||
const message = `Config file ${cliConfigLocation} already exists.`; | ||
logger.error(message); | ||
return; | ||
} | ||
|
||
const newConfig: SoloRcConfig = { | ||
ado: { | ||
login: '<your-email-login-here>', | ||
token: '<your-personal-access-token-here>', | ||
org: '<OPTIONAL-your-organization-here>', | ||
proj: '<OPTIONAL-your-project-here>', | ||
}, | ||
}; | ||
fs.writeFileSync(cliConfigLocation, JSON.stringify(newConfig, null, 2)); | ||
}; | ||
|
||
export const command: CliCommandMetadata = { | ||
name: commandName, | ||
description: `Initialize CLI tool.`, | ||
options: {}, | ||
impl: soloInitCommand, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface SoloRcConfig { | ||
ado: { | ||
login: string; | ||
token: string; | ||
org: string; | ||
proj: string; | ||
}; | ||
} |