include node_modules so release .zip is deployable

This commit is contained in:
2023-11-24 17:44:25 -05:00
parent 6c86cfe5d2
commit 8b11c41267
8963 changed files with 874175 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigData = void 0;
const types_1 = require("@smithy/types");
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
const getConfigData = (data) => Object.entries(data)
.filter(([key]) => {
const sections = key.split(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
if (sections.length === 2 && Object.values(types_1.IniSectionType).includes(sections[0])) {
return true;
}
return false;
})
.reduce((acc, [key, value]) => {
const updatedKey = key.startsWith(types_1.IniSectionType.PROFILE) ? key.split(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR)[1] : key;
acc[updatedKey] = value;
return acc;
}, {
...(data.default && { default: data.default }),
});
exports.getConfigData = getConfigData;
@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigFilepath = exports.ENV_CONFIG_PATH = void 0;
const path_1 = require("path");
const getHomeDir_1 = require("./getHomeDir");
exports.ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
const getConfigFilepath = () => process.env[exports.ENV_CONFIG_PATH] || (0, path_1.join)((0, getHomeDir_1.getHomeDir)(), ".aws", "config");
exports.getConfigFilepath = getConfigFilepath;
@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCredentialsFilepath = exports.ENV_CREDENTIALS_PATH = void 0;
const path_1 = require("path");
const getHomeDir_1 = require("./getHomeDir");
exports.ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
const getCredentialsFilepath = () => process.env[exports.ENV_CREDENTIALS_PATH] || (0, path_1.join)((0, getHomeDir_1.getHomeDir)(), ".aws", "credentials");
exports.getCredentialsFilepath = getCredentialsFilepath;
+26
View File
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHomeDir = void 0;
const os_1 = require("os");
const path_1 = require("path");
const homeDirCache = {};
const getHomeDirCacheKey = () => {
if (process && process.geteuid) {
return `${process.geteuid()}`;
}
return "DEFAULT";
};
const getHomeDir = () => {
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${path_1.sep}` } = process.env;
if (HOME)
return HOME;
if (USERPROFILE)
return USERPROFILE;
if (HOMEPATH)
return `${HOMEDRIVE}${HOMEPATH}`;
const homeDirCacheKey = getHomeDirCacheKey();
if (!homeDirCache[homeDirCacheKey])
homeDirCache[homeDirCacheKey] = (0, os_1.homedir)();
return homeDirCache[homeDirCacheKey];
};
exports.getHomeDir = getHomeDir;
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProfileName = exports.DEFAULT_PROFILE = exports.ENV_PROFILE = void 0;
exports.ENV_PROFILE = "AWS_PROFILE";
exports.DEFAULT_PROFILE = "default";
const getProfileName = (init) => init.profile || process.env[exports.ENV_PROFILE] || exports.DEFAULT_PROFILE;
exports.getProfileName = getProfileName;
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSSOTokenFilepath = void 0;
const crypto_1 = require("crypto");
const path_1 = require("path");
const getHomeDir_1 = require("./getHomeDir");
const getSSOTokenFilepath = (id) => {
const hasher = (0, crypto_1.createHash)("sha1");
const cacheName = hasher.update(id).digest("hex");
return (0, path_1.join)((0, getHomeDir_1.getHomeDir)(), ".aws", "sso", "cache", `${cacheName}.json`);
};
exports.getSSOTokenFilepath = getSSOTokenFilepath;
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSSOTokenFromFile = void 0;
const fs_1 = require("fs");
const getSSOTokenFilepath_1 = require("./getSSOTokenFilepath");
const { readFile } = fs_1.promises;
const getSSOTokenFromFile = async (id) => {
const ssoTokenFilepath = (0, getSSOTokenFilepath_1.getSSOTokenFilepath)(id);
const ssoTokenText = await readFile(ssoTokenFilepath, "utf8");
return JSON.parse(ssoTokenText);
};
exports.getSSOTokenFromFile = getSSOTokenFromFile;
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSsoSessionData = void 0;
const types_1 = require("@smithy/types");
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
const getSsoSessionData = (data) => Object.entries(data)
.filter(([key]) => key.startsWith(types_1.IniSectionType.SSO_SESSION + loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR))
.reduce((acc, [key, value]) => ({ ...acc, [key.split(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR)[1]]: value }), {});
exports.getSsoSessionData = getSsoSessionData;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./getHomeDir"), exports);
tslib_1.__exportStar(require("./getProfileName"), exports);
tslib_1.__exportStar(require("./getSSOTokenFilepath"), exports);
tslib_1.__exportStar(require("./getSSOTokenFromFile"), exports);
tslib_1.__exportStar(require("./loadSharedConfigFiles"), exports);
tslib_1.__exportStar(require("./loadSsoSessionData"), exports);
tslib_1.__exportStar(require("./parseKnownFiles"), exports);
tslib_1.__exportStar(require("./types"), exports);
@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadSharedConfigFiles = exports.CONFIG_PREFIX_SEPARATOR = void 0;
const getConfigData_1 = require("./getConfigData");
const getConfigFilepath_1 = require("./getConfigFilepath");
const getCredentialsFilepath_1 = require("./getCredentialsFilepath");
const parseIni_1 = require("./parseIni");
const slurpFile_1 = require("./slurpFile");
const swallowError = () => ({});
exports.CONFIG_PREFIX_SEPARATOR = ".";
const loadSharedConfigFiles = async (init = {}) => {
const { filepath = (0, getCredentialsFilepath_1.getCredentialsFilepath)(), configFilepath = (0, getConfigFilepath_1.getConfigFilepath)() } = init;
const parsedFiles = await Promise.all([
(0, slurpFile_1.slurpFile)(configFilepath, {
ignoreCache: init.ignoreCache,
})
.then(parseIni_1.parseIni)
.then(getConfigData_1.getConfigData)
.catch(swallowError),
(0, slurpFile_1.slurpFile)(filepath, {
ignoreCache: init.ignoreCache,
})
.then(parseIni_1.parseIni)
.catch(swallowError),
]);
return {
configFile: parsedFiles[0],
credentialsFile: parsedFiles[1],
};
};
exports.loadSharedConfigFiles = loadSharedConfigFiles;
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadSsoSessionData = void 0;
const getConfigFilepath_1 = require("./getConfigFilepath");
const getSsoSessionData_1 = require("./getSsoSessionData");
const parseIni_1 = require("./parseIni");
const slurpFile_1 = require("./slurpFile");
const swallowError = () => ({});
const loadSsoSessionData = async (init = {}) => {
var _a;
return (0, slurpFile_1.slurpFile)((_a = init.configFilepath) !== null && _a !== void 0 ? _a : (0, getConfigFilepath_1.getConfigFilepath)())
.then(parseIni_1.parseIni)
.then(getSsoSessionData_1.getSsoSessionData)
.catch(swallowError);
};
exports.loadSsoSessionData = loadSsoSessionData;
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeConfigFiles = void 0;
const mergeConfigFiles = (...files) => {
const merged = {};
for (const file of files) {
for (const [key, values] of Object.entries(file)) {
if (merged[key] !== undefined) {
Object.assign(merged[key], values);
}
else {
merged[key] = values;
}
}
}
return merged;
};
exports.mergeConfigFiles = mergeConfigFiles;
+56
View File
@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseIni = void 0;
const types_1 = require("@smithy/types");
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
const profileNameBlockList = ["__proto__", "profile __proto__"];
const parseIni = (iniData) => {
const map = {};
let currentSection;
let currentSubSection;
for (const iniLine of iniData.split(/\r?\n/)) {
const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
if (isSection) {
currentSection = undefined;
currentSubSection = undefined;
const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
const matches = prefixKeyRegex.exec(sectionName);
if (matches) {
const [, prefix, , name] = matches;
if (Object.values(types_1.IniSectionType).includes(prefix)) {
currentSection = [prefix, name].join(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
}
}
else {
currentSection = sectionName;
}
if (profileNameBlockList.includes(sectionName)) {
throw new Error(`Found invalid profile name "${sectionName}"`);
}
}
else if (currentSection) {
const indexOfEqualsSign = trimmedLine.indexOf("=");
if (![0, -1].includes(indexOfEqualsSign)) {
const [name, value] = [
trimmedLine.substring(0, indexOfEqualsSign).trim(),
trimmedLine.substring(indexOfEqualsSign + 1).trim(),
];
if (value === "") {
currentSubSection = name;
}
else {
if (currentSubSection && iniLine.trimStart() === iniLine) {
currentSubSection = undefined;
}
map[currentSection] = map[currentSection] || {};
const key = currentSubSection ? [currentSubSection, name].join(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR) : name;
map[currentSection][key] = value;
}
}
}
}
return map;
};
exports.parseIni = parseIni;
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseKnownFiles = void 0;
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
const mergeConfigFiles_1 = require("./mergeConfigFiles");
const parseKnownFiles = async (init) => {
const parsedFiles = await (0, loadSharedConfigFiles_1.loadSharedConfigFiles)(init);
return (0, mergeConfigFiles_1.mergeConfigFiles)(parsedFiles.configFile, parsedFiles.credentialsFile);
};
exports.parseKnownFiles = parseKnownFiles;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.slurpFile = void 0;
const fs_1 = require("fs");
const { readFile } = fs_1.promises;
const filePromisesHash = {};
const slurpFile = (path, options) => {
if (!filePromisesHash[path] || (options === null || options === void 0 ? void 0 : options.ignoreCache)) {
filePromisesHash[path] = readFile(path, "utf8");
}
return filePromisesHash[path];
};
exports.slurpFile = slurpFile;
+2
View File
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });