@nodeswork/applet
Version:
Nodeswork Applet Framework
63 lines (61 loc) • 2.72 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const logger = require("@nodeswork/logger");
const kiws = require("@nodeswork/kiws");
const constants_1 = require("../constants");
const LOG = logger.getLogger();
const ENV = process.env.NODE_ENV === 'production' ? 'production' : 'dev';
const APPLET_ID = process.env[constants_1.constants.environmentKeys.APPLET_ID] || null;
const APPLET_TOKEN = process.env[constants_1.constants.environmentKeys.APPLET_TOKEN] || null;
const NA_TYPE = process.env[constants_1.constants.environmentKeys.NA_TYPE] || 'npm';
const NA_VERSION = process.env[constants_1.constants.environmentKeys.NA_VERSION] || '8.3.0';
let PACKAGE_NAME = process.env[constants_1.constants.environmentKeys.PACKAGE_NAME] || null;
let PACKAGE_VERSION = process.env[constants_1.constants.environmentKeys.PACKAGE_VERSION] || null;
if (PACKAGE_NAME == null || PACKAGE_VERSION == null) {
try {
const p = require(path.join(process.cwd(), 'package.json'));
if (PACKAGE_NAME == null) {
PACKAGE_NAME = p.name;
}
if (PACKAGE_VERSION == null) {
PACKAGE_VERSION = p.version;
}
}
catch (e) {
// Ignore
}
}
const PRODUCER = `na-npm-${PACKAGE_NAME}_${PACKAGE_VERSION}`;
let AppletInfoService = class AppletInfoService {
constructor() {
this.appletInfo = {
env: ENV,
appletId: APPLET_ID,
appletToken: APPLET_TOKEN,
naType: NA_TYPE,
naVersion: NA_VERSION,
packageName: PACKAGE_NAME,
packageVersion: PACKAGE_VERSION,
producer: PRODUCER,
};
}
getAppletInfo() {
return this.appletInfo;
}
};
AppletInfoService = __decorate([
kiws.Service(),
__metadata("design:paramtypes", [])
], AppletInfoService);
exports.AppletInfoService = AppletInfoService;
//# sourceMappingURL=applet.info.service.js.map