-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: improve fluence env switching [fixes DXJ-473] * improve logs * fix * Apply automatic changes * fix description * Apply automatic changes * add env.yaml to gitignore * review fixes * fix * Apply automatic changes * fix * check registry cli-up branch * up * use main --------- Co-authored-by: shamsartem <[email protected]>
- Loading branch information
1 parent
efb88fb
commit a09f39b
Showing
77 changed files
with
1,384 additions
and
1,007 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 @@ | ||
# env.yaml | ||
|
||
Defines user project preferences | ||
|
||
## Properties | ||
|
||
| Property | Type | Required | Description | | ||
|--------------|--------|----------|-------------------------------------------------------------------------------------------------------| | ||
| `version` | number | **Yes** | | | ||
| `fluenceEnv` | string | No | Fluence environment to connect to Possible values are: `kras`, `stage`, `testnet`, `local`, `custom`. | | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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,73 @@ | ||
/** | ||
* Copyright 2023 Fluence Labs Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import assert from "assert"; | ||
|
||
import { color } from "@oclif/color"; | ||
|
||
import { BaseCommand, baseFlags } from "../../baseCommand.js"; | ||
import { commandObj } from "../../lib/commandObj.js"; | ||
import { envConfig } from "../../lib/configs/globalConfigs.js"; | ||
import { ENV_ARG } from "../../lib/const.js"; | ||
import { initCli } from "../../lib/lifeCycle.js"; | ||
import { | ||
ensureValidEnvFlag, | ||
fluenceEnvPrompt, | ||
ensureCustomRelays, | ||
} from "../../lib/multiaddres.js"; | ||
|
||
export default class Peers extends BaseCommand<typeof Peers> { | ||
static override description = | ||
"Switch default Fluence Environment used in the current Fluence project"; | ||
static override examples = ["<%= config.bin %> <%= command.id %>"]; | ||
static override flags = { | ||
...baseFlags, | ||
}; | ||
static override args = { | ||
...ENV_ARG, | ||
}; | ||
async run(): Promise<void> { | ||
const { args, fluenceConfig } = await initCli( | ||
this, | ||
await this.parse(Peers), | ||
true, | ||
); | ||
|
||
assert(envConfig !== undefined, "this command requires fluence project"); | ||
const fluenceEnvFromArgs = await ensureValidEnvFlag(args.ENV); | ||
|
||
const newFluenceEnv = | ||
fluenceEnvFromArgs === undefined | ||
? await fluenceEnvPrompt() | ||
: fluenceEnvFromArgs; | ||
|
||
if ( | ||
newFluenceEnv === "custom" && | ||
fluenceConfig.customFluenceEnv === undefined | ||
) { | ||
await ensureCustomRelays(fluenceConfig); | ||
} | ||
|
||
envConfig.fluenceEnv = newFluenceEnv; | ||
await envConfig.$commit(); | ||
|
||
commandObj.log( | ||
`Successfully set default fluence environment to ${color.yellow( | ||
newFluenceEnv, | ||
)}`, | ||
); | ||
} | ||
} |
Oops, something went wrong.