dce-dev-wizard
Version:
Wizard for managing development apps at Harvard DCE.
57 lines • 2.34 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
// Import shared helpers
const print_1 = __importDefault(require("./print"));
// Import constants
const TOP_LEVEL_DIRECTORY_1 = __importDefault(require("../constants/TOP_LEVEL_DIRECTORY"));
/* eslint-disable no-console */
// Check if the current directory is an NPM project
const configFilename = path_1.default.join(TOP_LEVEL_DIRECTORY_1.default, 'dceConfig.json');
if (!fs_1.default.existsSync(configFilename)) {
// Initialize npm project
print_1.default.title('DCE Configuration Not Found');
console.log('');
console.log('Create dceConfig.json and populate it with deployments:');
console.log('{');
console.log(' "deployments": [');
console.log(' {');
console.log(' "name": "Stage",');
console.log(' "app": "mytool-stage",');
console.log(' "profile": "stage"');
console.log(' },');
console.log(' {');
console.log(' "name": "Prod",');
console.log(' "app": "mytool",');
console.log(' "profile": "prod"');
console.log(' }');
console.log(' ]');
console.log('}');
console.log('');
console.log('Where "name" is a human-readable name, "app" is the name of the deployment service, and "profile" is the name of the aws profile you use to access it.');
console.log('');
process.exit(0);
}
// Get the name of the current project
const config = JSON.parse(fs_1.default.readFileSync(configFilename, 'utf-8'));
const { deployments } = config;
if (!deployments || deployments.length === 0) {
console.log('Oops! Your /config/dceConfig.json is not fully configured. Add a "deployments" array.');
process.exit(0);
}
for (let i = 0; i < deployments.length; i++) {
if (!deployments[i].name || !deployments[i].app || !deployments[i].profile) {
console.log('Oops! Each deployment must have a "name", "app", and "profile"');
process.exit(0);
}
}
/**
* Configuration file, parsed as a JSON object
* @author Gabe Abrams
*/
exports.default = config;
//# sourceMappingURL=config.js.map