UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

50 lines 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProjectJsonFile = exports.projectConfigSchema = void 0; const path_1 = require("path"); const ajv_1 = require("ajv"); const alwayscli_1 = require("@alwaysai/alwayscli"); const config_nodejs_1 = require("@alwaysai/config-nodejs"); const constants_1 = require("../../constants"); const paths_1 = require("../../paths"); exports.projectConfigSchema = { type: 'object', properties: { project: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string', nullable: true } }, required: ['id'] } }, required: ['project'] }; const ajv = new ajv_1.default(); const validateFunction = ajv.compile(exports.projectConfigSchema); const ENOENT = { message: `${paths_1.PROJECT_JSON_FILE_NAME} not found. Did you run "${constants_1.ALWAYSAI_CLI_EXECUTABLE_NAME} app configure"?`, code: alwayscli_1.CLI_TERSE_ERROR }; function ProjectJsonFile(dir = process.cwd()) { const configFile = (0, config_nodejs_1.ConfigFileSchema)({ path: (0, path_1.join)(dir, paths_1.PROJECT_JSON_FILE_NAME), validateFunction, ENOENT, initialValue: { project: { id: '', name: '' } } }); return Object.assign(Object.assign({}, configFile), { name: paths_1.PROJECT_JSON_FILE_NAME }); } exports.ProjectJsonFile = ProjectJsonFile; //# sourceMappingURL=project-json-file.js.map