UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

43 lines 1.76 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const globby_1 = __importDefault(require("@sprucelabs/globby")); const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils"); const schemaGeneratorUtil = { async filterSchemaFilesBySchemaIds(lookupDir, schemas) { const matches = await (0, globby_1.default)([ path_1.default.join(lookupDir, '/**/*.schema.[t|j]s'), path_1.default.join(lookupDir, '/*/v*/*.go'), ]); const filtered = matches.filter((match) => { let found = false; for (const schema of schemas) { const { id, namespace, version } = schema; const expectedPath = match.endsWith('.go') ? this.buildPath(spruce_skill_utils_1.namesUtil.toSnake(id), '.go', namespace, version) : this.buildPath(id, '.schema.', namespace, version); if (match.includes(expectedPath)) { found = true; break; } } return !found; }); return filtered; }, buildPath(schemaId, suffix, namespace, version) { let path = path_1.default.sep + schemaId + suffix; if (version) { path = path_1.default.sep + version + path; } if (namespace) { path = spruce_skill_utils_1.namesUtil.toCamel(namespace) + path; } return path; }, }; exports.default = schemaGeneratorUtil; //# sourceMappingURL=schemaGenerator.utility.js.map