@bafsllc/serverless-import-config-plugin
Advanced tools
Comparing version 0.0.5 to 0.0.6
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,9 +30,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -27,2 +39,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const lodash_difference_1 = __importDefault(require("lodash.difference")); | ||
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep")); | ||
const merge_1 = __importDefault(require("./merge")); | ||
@@ -36,6 +49,7 @@ const utils_1 = require("./utils"); | ||
class ImportConfigPlugin { | ||
constructor(serverless) { | ||
constructor(serverless, options) { | ||
var _a, _b; | ||
this.serverless = serverless; | ||
this.originalPlugins = (_b = (_a = this.serverless.service.plugins) === null || _a === void 0 ? void 0 : _a.slice(), (_b !== null && _b !== void 0 ? _b : [])); | ||
this.options = options; | ||
this.originalPlugins = (_b = (_a = this.serverless.service.plugins) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : []; | ||
this.importConfigs(this.serverless.service, { basedir: REALPATH }).catch((error) => { | ||
@@ -62,7 +76,7 @@ console.error(error); | ||
resolvePathToImport(rawPath, { basedir }) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { variables } = this.serverless; | ||
variables.loadVariableSyntax(); | ||
variables.options = this.serverless.service; | ||
variables.options = lodash_clonedeep_1.default(this.serverless.service); | ||
variables.options.provider.stage = this.options.stage || variables.options.provider.stage; | ||
const pathToImport = yield variables.populateProperty(rawPath); | ||
@@ -83,3 +97,3 @@ variables.options = undefined; | ||
const stats = utils_1.tryOrUndefined(() => fs_1.statSync(pathToImport)); | ||
if ((_a = stats) === null || _a === void 0 ? void 0 : _a.isDirectory()) { | ||
if (stats === null || stats === void 0 ? void 0 : stats.isDirectory()) { | ||
const tries = []; | ||
@@ -142,3 +156,2 @@ for (const configExtname of CONFIG_EXTNAMES) { | ||
importConfig(options, { basedir }) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -156,3 +169,3 @@ const isFullOptions = typeof options === "object" && options != null; | ||
const importExports = require(path.resolve(importPath)); | ||
const importFunction = typeof importExports === "function" ? importExports : (_a = importExports) === null || _a === void 0 ? void 0 : _a.default; | ||
const importFunction = typeof importExports === "function" ? importExports : importExports === null || importExports === void 0 ? void 0 : importExports.default; | ||
config = importFunction(inputs); | ||
@@ -167,3 +180,3 @@ } | ||
catch (error) { | ||
throw new this.serverless.classes.Error(`Error: Cannot import ${pathToImport}\nCause: ${error.message}`); | ||
throw new this.serverless.classes.Error(`Error: Cannot import ${importPath}\nCause: ${error.message}`); | ||
} | ||
@@ -170,0 +183,0 @@ merge_1.default(this.serverless.service, config); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveModule = exports.tryOrUndefined = exports.isObject = void 0; | ||
const resolve_1 = __importDefault(require("resolve")); | ||
@@ -8,0 +9,0 @@ exports.isObject = (value) => typeof value === 'object' && value != null; |
{ | ||
"name": "@bafsllc/serverless-import-config-plugin", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Adds possibility to import YAML files in serverless.yaml config file", | ||
@@ -8,3 +8,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "echo 'Build' && tsc", | ||
"build": "echo 'Build' && npx tsc", | ||
"watch": "npm-watch", | ||
@@ -42,5 +42,6 @@ "prepublishOnly": "npm run build" | ||
"npm-watch": "^0.6.0", | ||
"typescript": "^3.7.4" | ||
"typescript": "^3.9.9" | ||
}, | ||
"dependencies": { | ||
"@types/lodash.clonedeep": "^4.5.6", | ||
"@types/lodash.difference": "^4.5.6", | ||
@@ -52,2 +53,3 @@ "@types/lodash.differencewith": "^4.5.6", | ||
"@types/resolve": "^1.14.0", | ||
"lodash.clonedeep": "^4.5.0", | ||
"lodash.difference": "^4.5.0", | ||
@@ -54,0 +56,0 @@ "lodash.differencewith": "^4.5.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24897
248
13
+ Addedlodash.clonedeep@^4.5.0
+ Added@types/lodash.clonedeep@4.5.9(transitive)
+ Addedlodash.clonedeep@4.5.0(transitive)