-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli) : cli compatibility with operator (#1793)
* feat(cli) : changes in package.json & readme * feat(cli) : changes in deploy service * feat(cli) : env command added * fix(cli) : comments resolved * feat(cli) : common package updated for CLI * feat(cli) : comments added for spaship env
- Loading branch information
1 parent
ff7eca8
commit b1d7716
Showing
14 changed files
with
377 additions
and
69 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
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,7 +1,7 @@ | ||
{ | ||
"name": "@spaship/cli", | ||
"description": "A command line interface for SPAship!", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"author": "[email protected]", | ||
"bin": { | ||
"spaship": "./bin/run" | ||
|
@@ -15,38 +15,46 @@ | |
"main": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:spaship/spaship.git", | ||
"url": "https://github.com/spaship/spaship.git", | ||
"directory": "packages/cli" | ||
}, | ||
"scripts": { | ||
"postpack": "rm -f oclif.manifest.json", | ||
"prepack": "oclif-dev manifest && oclif-dev readme", | ||
"prepack": "oclif-dev manifest", | ||
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"", | ||
"preversion": "oclif-dev readme && git add README.md" | ||
}, | ||
"dependencies": { | ||
"@oclif/command": "^1.5.19", | ||
"@oclif/command": "^1.8.16", | ||
"@oclif/config": "^1.13.3", | ||
"@oclif/plugin-help": "^5.0.0", | ||
"@spaship/common": "^1.3.0", | ||
"@oclif/plugin-help": "^3.3.1", | ||
"@spaship/common": "^0.14.0", | ||
"ajv": "^8.6.3", | ||
"archiver": "^5.0.0", | ||
"axios": "^0.23.0", | ||
"chalk": "^4.1.1", | ||
"cosmiconfig": "^7.0.0", | ||
"form-data": "^4.0.0", | ||
"inquirer": "^8.0.0", | ||
"inquirer-loop": "^0.3.0", | ||
"js-yaml": "^4.1.0", | ||
"jwt-check-expiration": "^1.0.5", | ||
"lodash": "^4.17.15", | ||
"nconf": "^0.11.0", | ||
"ora": "^6.0.0", | ||
"ora": "^5.0.0", | ||
"pretty-bytes": "^5.3.0", | ||
"read-pkg-up": "^7.0.1" | ||
"read-package-json": "^4.1.1", | ||
"read-pkg-up": "^7.0.0", | ||
"uuid": "^8.3.2" | ||
}, | ||
"devDependencies": { | ||
"@oclif/dev-cli": "1.26.10", | ||
"@oclif/test": "2.1.0", | ||
"chai": "4.3.6", | ||
"@oclif/dev-cli": "1.26.0", | ||
"@oclif/test": "1.2.8", | ||
"chai": "4.3.4", | ||
"eslint-config-oclif": "4.0.0", | ||
"globby": "12.2.0", | ||
"mocha": "9.2.2", | ||
"nock": "13.2.2", | ||
"globby": "^11.0.4", | ||
"mocha": "9.1.2", | ||
"nock": "13.1.3", | ||
"nyc": "15.1.0", | ||
"shortid": "2.2.16", | ||
"temp-dir": "2.0.0" | ||
|
@@ -70,4 +78,4 @@ | |
"publishConfig": { | ||
"access": "public" | ||
} | ||
} | ||
} |
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,61 @@ | ||
const { Command, flags } = require("@oclif/command"); | ||
const fs = require("fs"); | ||
const { loadRcFile } = require("../common/spashiprc-loader"); | ||
const { assign, get, isEmpty, omit } = require("lodash"); | ||
const { config } = require("../common/config/index"); | ||
const commonFlags = require("../common/flags"); | ||
const os = require("os"); | ||
|
||
class EnvCommand extends Command { | ||
async run() { | ||
let existingConfig; | ||
const userHomeDir = os.homedir(); | ||
try { | ||
await config.read(`${userHomeDir}/.spashiprc.yml`); | ||
existingConfig = true; | ||
} catch (e) { | ||
existingConfig = false; | ||
} | ||
const { flags } = this.parse(EnvCommand); | ||
const dataObj = {}; | ||
dataObj[flags.name] = { apikey: flags.apikey, url: flags.url }; | ||
const finalObj = { envs: dataObj }; | ||
try { | ||
if (!existingConfig) { | ||
await config.write(`${userHomeDir}/.spashiprc.yml`, JSON.parse(JSON.stringify(finalObj))); | ||
} else { | ||
let yamlData = await config.read(`${userHomeDir}/.spashiprc.yml`); | ||
yamlData.envs = { ...yamlData.envs, ...dataObj }; | ||
await config.append(`${userHomeDir}/.spashiprc.yml`, JSON.parse(JSON.stringify(yamlData))); | ||
} | ||
this.log("Generated .spashiprc.yaml at " + userHomeDir); | ||
} catch (error) { | ||
this.log(error); | ||
} | ||
} | ||
} | ||
|
||
EnvCommand.flags = assign( | ||
{ | ||
name: flags.string({ | ||
char: "n", | ||
description: "name of the environment", | ||
required: false, // not required for interactive mode | ||
default: "undefined", | ||
}), | ||
}, | ||
{ | ||
url: flags.string({ | ||
char: "u", | ||
description: "url of the environment", | ||
required: false, // not required for interactive mode | ||
default: "undefined", | ||
}), | ||
}, | ||
commonFlags.apikey | ||
); | ||
|
||
EnvCommand.description = `set env for .spashiprc.yml file (for setting environment & authentication). | ||
`; | ||
|
||
module.exports = EnvCommand; |
Oops, something went wrong.