@starship-ci/cli
Version:
126 lines (118 loc) • 5.07 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.displayUsage = exports.usageText = exports.loadConfig = exports.params = exports.displayVersion = void 0;
const client_1 = require("@starship-ci/client"); // Adjust the import path as necessary
const chalk_1 = __importDefault(require("chalk"));
const fs_1 = require("fs");
const yaml = __importStar(require("js-yaml"));
const path_1 = require("path");
const package_1 = require("./package");
// Function to display the version information
function displayVersion() {
const pkg = (0, package_1.readAndParsePackageJson)();
console.log(chalk_1.default.green(`Name: ${pkg.name}`));
console.log(chalk_1.default.blue(`Version: ${pkg.version}`));
}
exports.displayVersion = displayVersion;
const resolvePath = (filename) => filename.startsWith('/') ? filename : (0, path_1.resolve)((process.cwd(), filename));
const loadYaml = (filename) => {
const path = resolvePath(filename);
const fileContents = (0, fs_1.readFileSync)(path, 'utf8');
return yaml.load(fileContents);
};
exports.params = [
'config',
'name',
'version',
'repo',
'repoUrl',
'chart',
'namespace',
'timeout'
];
const loadConfig = (argv) => {
const context = {
...client_1.defaultStarshipContext
};
let starship = {};
// Override context with command-line arguments dynamically based on StarshipContext keys
exports.params.forEach((key) => {
if (argv[key] !== undefined) {
console.log('argv:', key, ':', argv[key]);
// @ts-expect-error - dynamic assignment
context[key] = argv[key];
}
});
if (context.config) {
context.config = resolvePath(context.config);
starship = loadYaml(context.config);
}
return { context, starship };
};
exports.loadConfig = loadConfig;
exports.usageText = `
Usage: starship <command> [options]
Commands:
start Start the Starship services.
stop Remove all components related to the deployment.
deploy Deploy starship using specified options or configuration file.
setup Setup initial configuration and dependencies.
start-ports Start port forwarding for the deployed services.
stop-ports Stop port forwarding.
delete Delete a specific Helm release.
get-pods Get the list of pods for the Helm release.
clean Perform a clean operation to tidy up resources.
version, -v Display the version of the Starship Client.
Configuration File:
--config <path> Specify the path to the configuration file containing the actual config file. Required.
Command-line options will override settings from this file if both are provided.
Command-line Options:
--name <name> Specify the Helm release name, default: starship.
Will overide config file settings for name.
--version <ver> Specify the version of the Helm chart, default: v0.2.6.
Will overide config file settings for version.
--timeout <time> Specify the timeout for the Helm operations, default: 10m.
Will overide config file settings for timeout.
Examples:
$ starship start --config ./config/two-chain.yaml
$ starship stop --config ./config/two-chain.yaml
If you want to setup starship for the first time
$ starship setup
If you want to run the deployment step by step
$ starship deploy --config ./config/two-chain.yaml
$ starship start-ports --config ./config/two-chain.yaml
$ starship stop-ports --config ./config/two-chain.yaml
$ starship delete --config ./config/two-chain.yaml
Additional Help:
$ starship help Display this help information.
`;
function displayUsage() {
console.log(exports.usageText);
}
exports.displayUsage = displayUsage;
;