"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const fs_extra_1 = require("fs-extra");
const glob = require("glob");
const path_1 = require("../path");
const removeLastSegment_1 = require("../util/removeLastSegment");
const cwd = path_1.PATH_SRC_SYSTEM;
let count = 0;
glob
    .sync(`**/**/spec.json`, {
    cwd,
})
    .map((path) => (0, removeLastSegment_1.removeLastSegment)(path))
    .forEach((_) => {
    const spec_file_path = `${cwd}/${_}/spec.json`;
    const spec = (0, fs_extra_1.readJSONSync)(spec_file_path);
    const segments = _.split('/');
    const l = segments.length;
    const tags = segments.slice(0, l - 1);
    spec.metadata = spec.metadata || {};
    spec.metadata.tags = tags;
    (0, fs_1.writeFileSync)(spec_file_path, JSON.stringify(spec, null, 2));
});
console.log(count);
//# sourceMappingURL=type.js.map