45 lines
3.8 KiB
JavaScript
45 lines
3.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const serviceManager_1 = require("../serviceManager");
|
|
const Debug = require("debug");
|
|
const configuration_1 = require("../configuration");
|
|
const fs_1 = require("fs");
|
|
class DependenciesFeature {
|
|
constructor() {
|
|
this.logger = Debug('axm:features:dependencies');
|
|
}
|
|
init() {
|
|
this.transport = serviceManager_1.ServiceManager.get('transport');
|
|
this.logger('init');
|
|
const pkgPath = configuration_1.default.findPackageJson();
|
|
if (typeof pkgPath !== 'string')
|
|
return this.logger('failed to found pkg.json path');
|
|
this.logger(`found pkg.json in ${pkgPath}`);
|
|
fs_1.readFile(pkgPath, (err, data) => {
|
|
if (err)
|
|
return this.logger(`failed to read pkg.json`, err);
|
|
try {
|
|
const pkg = JSON.parse(data.toString());
|
|
if (typeof pkg.dependencies !== 'object') {
|
|
return this.logger(`failed to find deps in pkg.json`);
|
|
}
|
|
const dependencies = Object.keys(pkg.dependencies)
|
|
.reduce((list, name) => {
|
|
list[name] = { version: pkg.dependencies[name] };
|
|
return list;
|
|
}, {});
|
|
this.logger(`collected ${Object.keys(dependencies).length} dependencies`);
|
|
this.transport.send('application:dependencies', dependencies);
|
|
this.logger('sent dependencies list');
|
|
}
|
|
catch (err) {
|
|
return this.logger(`failed to parse pkg.json`, err);
|
|
}
|
|
});
|
|
}
|
|
destroy() {
|
|
this.logger('destroy');
|
|
}
|
|
}
|
|
exports.DependenciesFeature = DependenciesFeature;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwZW5kZW5jaWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2ZlYXR1cmVzL2RlcGVuZGVuY2llcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHNEQUFrRDtBQUNsRCwrQkFBOEI7QUFHOUIsb0RBQTRDO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