@smithy/shared-ini-file-loader 2.2.7 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/getConfigData.js +1 -22
- package/dist-cjs/getConfigFilepath.js +1 -8
- package/dist-cjs/getCredentialsFilepath.js +1 -8
- package/dist-cjs/getProfileName.js +1 -7
- package/dist-cjs/getSsoSessionData.js +1 -9
- package/dist-cjs/index.js +188 -11
- package/dist-cjs/loadSharedConfigFiles.js +1 -31
- package/dist-cjs/loadSsoSessionData.js +1 -16
- package/dist-cjs/mergeConfigFiles.js +1 -18
- package/dist-cjs/parseIni.js +1 -56
- package/dist-cjs/parseKnownFiles.js +1 -10
- package/dist-cjs/types.js +1 -2
- package/package.json +13 -3
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfigData = void 0;
|
|
4
|
-
const types_1 = require("@smithy/types");
|
|
5
|
-
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
|
|
6
|
-
const getConfigData = (data) => Object.entries(data)
|
|
7
|
-
.filter(([key]) => {
|
|
8
|
-
const indexOfSeparator = key.indexOf(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
|
|
9
|
-
if (indexOfSeparator === -1) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return Object.values(types_1.IniSectionType).includes(key.substring(0, indexOfSeparator));
|
|
13
|
-
})
|
|
14
|
-
.reduce((acc, [key, value]) => {
|
|
15
|
-
const indexOfSeparator = key.indexOf(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
|
|
16
|
-
const updatedKey = key.substring(0, indexOfSeparator) === types_1.IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
|
|
17
|
-
acc[updatedKey] = value;
|
|
18
|
-
return acc;
|
|
19
|
-
}, {
|
|
20
|
-
...(data.default && { default: data.default }),
|
|
21
|
-
});
|
|
22
|
-
exports.getConfigData = getConfigData;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfigFilepath = exports.ENV_CONFIG_PATH = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const getHomeDir_1 = require("./getHomeDir");
|
|
6
|
-
exports.ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
7
|
-
const getConfigFilepath = () => process.env[exports.ENV_CONFIG_PATH] || (0, path_1.join)((0, getHomeDir_1.getHomeDir)(), ".aws", "config");
|
|
8
|
-
exports.getConfigFilepath = getConfigFilepath;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCredentialsFilepath = exports.ENV_CREDENTIALS_PATH = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const getHomeDir_1 = require("./getHomeDir");
|
|
6
|
-
exports.ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
7
|
-
const getCredentialsFilepath = () => process.env[exports.ENV_CREDENTIALS_PATH] || (0, path_1.join)((0, getHomeDir_1.getHomeDir)(), ".aws", "credentials");
|
|
8
|
-
exports.getCredentialsFilepath = getCredentialsFilepath;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProfileName = exports.DEFAULT_PROFILE = exports.ENV_PROFILE = void 0;
|
|
4
|
-
exports.ENV_PROFILE = "AWS_PROFILE";
|
|
5
|
-
exports.DEFAULT_PROFILE = "default";
|
|
6
|
-
const getProfileName = (init) => init.profile || process.env[exports.ENV_PROFILE] || exports.DEFAULT_PROFILE;
|
|
7
|
-
exports.getProfileName = getProfileName;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSsoSessionData = void 0;
|
|
4
|
-
const types_1 = require("@smithy/types");
|
|
5
|
-
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
|
|
6
|
-
const getSsoSessionData = (data) => Object.entries(data)
|
|
7
|
-
.filter(([key]) => key.startsWith(types_1.IniSectionType.SSO_SESSION + loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR))
|
|
8
|
-
.reduce((acc, [key, value]) => ({ ...acc, [key.split(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR)[1]]: value }), {});
|
|
9
|
-
exports.getSsoSessionData = getSsoSessionData;
|
|
1
|
+
module.exports = require("./index.js");
|
package/dist-cjs/index.js
CHANGED
|
@@ -1,11 +1,188 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
CONFIG_PREFIX_SEPARATOR: () => CONFIG_PREFIX_SEPARATOR,
|
|
25
|
+
DEFAULT_PROFILE: () => DEFAULT_PROFILE,
|
|
26
|
+
ENV_PROFILE: () => ENV_PROFILE,
|
|
27
|
+
getProfileName: () => getProfileName,
|
|
28
|
+
loadSharedConfigFiles: () => loadSharedConfigFiles,
|
|
29
|
+
loadSsoSessionData: () => loadSsoSessionData,
|
|
30
|
+
parseKnownFiles: () => parseKnownFiles
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
__reExport(src_exports, require("././getHomeDir"), module.exports);
|
|
34
|
+
|
|
35
|
+
// src/getProfileName.ts
|
|
36
|
+
var ENV_PROFILE = "AWS_PROFILE";
|
|
37
|
+
var DEFAULT_PROFILE = "default";
|
|
38
|
+
var getProfileName = /* @__PURE__ */ __name((init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE, "getProfileName");
|
|
39
|
+
|
|
40
|
+
// src/index.ts
|
|
41
|
+
__reExport(src_exports, require("././getSSOTokenFilepath"), module.exports);
|
|
42
|
+
__reExport(src_exports, require("././getSSOTokenFromFile"), module.exports);
|
|
43
|
+
|
|
44
|
+
// src/getConfigData.ts
|
|
45
|
+
var import_types = require("@smithy/types");
|
|
46
|
+
var getConfigData = /* @__PURE__ */ __name((data) => Object.entries(data).filter(([key]) => {
|
|
47
|
+
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
48
|
+
if (indexOfSeparator === -1) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return Object.values(import_types.IniSectionType).includes(key.substring(0, indexOfSeparator));
|
|
52
|
+
}).reduce(
|
|
53
|
+
(acc, [key, value]) => {
|
|
54
|
+
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
55
|
+
const updatedKey = key.substring(0, indexOfSeparator) === import_types.IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
|
|
56
|
+
acc[updatedKey] = value;
|
|
57
|
+
return acc;
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
// Populate default profile, if present.
|
|
61
|
+
...data.default && { default: data.default }
|
|
62
|
+
}
|
|
63
|
+
), "getConfigData");
|
|
64
|
+
|
|
65
|
+
// src/getConfigFilepath.ts
|
|
66
|
+
var import_path = require("path");
|
|
67
|
+
var import_getHomeDir = require("././getHomeDir");
|
|
68
|
+
var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
69
|
+
var getConfigFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CONFIG_PATH] || (0, import_path.join)((0, import_getHomeDir.getHomeDir)(), ".aws", "config"), "getConfigFilepath");
|
|
70
|
+
|
|
71
|
+
// src/getCredentialsFilepath.ts
|
|
72
|
+
|
|
73
|
+
var import_getHomeDir2 = require("././getHomeDir");
|
|
74
|
+
var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
75
|
+
var getCredentialsFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CREDENTIALS_PATH] || (0, import_path.join)((0, import_getHomeDir2.getHomeDir)(), ".aws", "credentials"), "getCredentialsFilepath");
|
|
76
|
+
|
|
77
|
+
// src/parseIni.ts
|
|
78
|
+
|
|
79
|
+
var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
80
|
+
var profileNameBlockList = ["__proto__", "profile __proto__"];
|
|
81
|
+
var parseIni = /* @__PURE__ */ __name((iniData) => {
|
|
82
|
+
const map = {};
|
|
83
|
+
let currentSection;
|
|
84
|
+
let currentSubSection;
|
|
85
|
+
for (const iniLine of iniData.split(/\r?\n/)) {
|
|
86
|
+
const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
|
|
87
|
+
const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
|
|
88
|
+
if (isSection) {
|
|
89
|
+
currentSection = void 0;
|
|
90
|
+
currentSubSection = void 0;
|
|
91
|
+
const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
|
|
92
|
+
const matches = prefixKeyRegex.exec(sectionName);
|
|
93
|
+
if (matches) {
|
|
94
|
+
const [, prefix, , name] = matches;
|
|
95
|
+
if (Object.values(import_types.IniSectionType).includes(prefix)) {
|
|
96
|
+
currentSection = [prefix, name].join(CONFIG_PREFIX_SEPARATOR);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
currentSection = sectionName;
|
|
100
|
+
}
|
|
101
|
+
if (profileNameBlockList.includes(sectionName)) {
|
|
102
|
+
throw new Error(`Found invalid profile name "${sectionName}"`);
|
|
103
|
+
}
|
|
104
|
+
} else if (currentSection) {
|
|
105
|
+
const indexOfEqualsSign = trimmedLine.indexOf("=");
|
|
106
|
+
if (![0, -1].includes(indexOfEqualsSign)) {
|
|
107
|
+
const [name, value] = [
|
|
108
|
+
trimmedLine.substring(0, indexOfEqualsSign).trim(),
|
|
109
|
+
trimmedLine.substring(indexOfEqualsSign + 1).trim()
|
|
110
|
+
];
|
|
111
|
+
if (value === "") {
|
|
112
|
+
currentSubSection = name;
|
|
113
|
+
} else {
|
|
114
|
+
if (currentSubSection && iniLine.trimStart() === iniLine) {
|
|
115
|
+
currentSubSection = void 0;
|
|
116
|
+
}
|
|
117
|
+
map[currentSection] = map[currentSection] || {};
|
|
118
|
+
const key = currentSubSection ? [currentSubSection, name].join(CONFIG_PREFIX_SEPARATOR) : name;
|
|
119
|
+
map[currentSection][key] = value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return map;
|
|
125
|
+
}, "parseIni");
|
|
126
|
+
|
|
127
|
+
// src/loadSharedConfigFiles.ts
|
|
128
|
+
var import_slurpFile = require("././slurpFile");
|
|
129
|
+
var swallowError = /* @__PURE__ */ __name(() => ({}), "swallowError");
|
|
130
|
+
var CONFIG_PREFIX_SEPARATOR = ".";
|
|
131
|
+
var loadSharedConfigFiles = /* @__PURE__ */ __name(async (init = {}) => {
|
|
132
|
+
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
|
|
133
|
+
const parsedFiles = await Promise.all([
|
|
134
|
+
(0, import_slurpFile.slurpFile)(configFilepath, {
|
|
135
|
+
ignoreCache: init.ignoreCache
|
|
136
|
+
}).then(parseIni).then(getConfigData).catch(swallowError),
|
|
137
|
+
(0, import_slurpFile.slurpFile)(filepath, {
|
|
138
|
+
ignoreCache: init.ignoreCache
|
|
139
|
+
}).then(parseIni).catch(swallowError)
|
|
140
|
+
]);
|
|
141
|
+
return {
|
|
142
|
+
configFile: parsedFiles[0],
|
|
143
|
+
credentialsFile: parsedFiles[1]
|
|
144
|
+
};
|
|
145
|
+
}, "loadSharedConfigFiles");
|
|
146
|
+
|
|
147
|
+
// src/getSsoSessionData.ts
|
|
148
|
+
|
|
149
|
+
var getSsoSessionData = /* @__PURE__ */ __name((data) => Object.entries(data).filter(([key]) => key.startsWith(import_types.IniSectionType.SSO_SESSION + CONFIG_PREFIX_SEPARATOR)).reduce((acc, [key, value]) => ({ ...acc, [key.split(CONFIG_PREFIX_SEPARATOR)[1]]: value }), {}), "getSsoSessionData");
|
|
150
|
+
|
|
151
|
+
// src/loadSsoSessionData.ts
|
|
152
|
+
var import_slurpFile2 = require("././slurpFile");
|
|
153
|
+
var swallowError2 = /* @__PURE__ */ __name(() => ({}), "swallowError");
|
|
154
|
+
var loadSsoSessionData = /* @__PURE__ */ __name(async (init = {}) => (0, import_slurpFile2.slurpFile)(init.configFilepath ?? getConfigFilepath()).then(parseIni).then(getSsoSessionData).catch(swallowError2), "loadSsoSessionData");
|
|
155
|
+
|
|
156
|
+
// src/mergeConfigFiles.ts
|
|
157
|
+
var mergeConfigFiles = /* @__PURE__ */ __name((...files) => {
|
|
158
|
+
const merged = {};
|
|
159
|
+
for (const file of files) {
|
|
160
|
+
for (const [key, values] of Object.entries(file)) {
|
|
161
|
+
if (merged[key] !== void 0) {
|
|
162
|
+
Object.assign(merged[key], values);
|
|
163
|
+
} else {
|
|
164
|
+
merged[key] = values;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return merged;
|
|
169
|
+
}, "mergeConfigFiles");
|
|
170
|
+
|
|
171
|
+
// src/parseKnownFiles.ts
|
|
172
|
+
var parseKnownFiles = /* @__PURE__ */ __name(async (init) => {
|
|
173
|
+
const parsedFiles = await loadSharedConfigFiles(init);
|
|
174
|
+
return mergeConfigFiles(parsedFiles.configFile, parsedFiles.credentialsFile);
|
|
175
|
+
}, "parseKnownFiles");
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
CONFIG_PREFIX_SEPARATOR,
|
|
179
|
+
DEFAULT_PROFILE,
|
|
180
|
+
ENV_PROFILE,
|
|
181
|
+
getProfileName,
|
|
182
|
+
loadSharedConfigFiles,
|
|
183
|
+
loadSsoSessionData,
|
|
184
|
+
parseKnownFiles,
|
|
185
|
+
...require("././getHomeDir"),
|
|
186
|
+
...require("././getSSOTokenFilepath"),
|
|
187
|
+
...require("././getSSOTokenFromFile")
|
|
188
|
+
});
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadSharedConfigFiles = exports.CONFIG_PREFIX_SEPARATOR = void 0;
|
|
4
|
-
const getConfigData_1 = require("./getConfigData");
|
|
5
|
-
const getConfigFilepath_1 = require("./getConfigFilepath");
|
|
6
|
-
const getCredentialsFilepath_1 = require("./getCredentialsFilepath");
|
|
7
|
-
const parseIni_1 = require("./parseIni");
|
|
8
|
-
const slurpFile_1 = require("./slurpFile");
|
|
9
|
-
const swallowError = () => ({});
|
|
10
|
-
exports.CONFIG_PREFIX_SEPARATOR = ".";
|
|
11
|
-
const loadSharedConfigFiles = async (init = {}) => {
|
|
12
|
-
const { filepath = (0, getCredentialsFilepath_1.getCredentialsFilepath)(), configFilepath = (0, getConfigFilepath_1.getConfigFilepath)() } = init;
|
|
13
|
-
const parsedFiles = await Promise.all([
|
|
14
|
-
(0, slurpFile_1.slurpFile)(configFilepath, {
|
|
15
|
-
ignoreCache: init.ignoreCache,
|
|
16
|
-
})
|
|
17
|
-
.then(parseIni_1.parseIni)
|
|
18
|
-
.then(getConfigData_1.getConfigData)
|
|
19
|
-
.catch(swallowError),
|
|
20
|
-
(0, slurpFile_1.slurpFile)(filepath, {
|
|
21
|
-
ignoreCache: init.ignoreCache,
|
|
22
|
-
})
|
|
23
|
-
.then(parseIni_1.parseIni)
|
|
24
|
-
.catch(swallowError),
|
|
25
|
-
]);
|
|
26
|
-
return {
|
|
27
|
-
configFile: parsedFiles[0],
|
|
28
|
-
credentialsFile: parsedFiles[1],
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
exports.loadSharedConfigFiles = loadSharedConfigFiles;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadSsoSessionData = void 0;
|
|
4
|
-
const getConfigFilepath_1 = require("./getConfigFilepath");
|
|
5
|
-
const getSsoSessionData_1 = require("./getSsoSessionData");
|
|
6
|
-
const parseIni_1 = require("./parseIni");
|
|
7
|
-
const slurpFile_1 = require("./slurpFile");
|
|
8
|
-
const swallowError = () => ({});
|
|
9
|
-
const loadSsoSessionData = async (init = {}) => {
|
|
10
|
-
var _a;
|
|
11
|
-
return (0, slurpFile_1.slurpFile)((_a = init.configFilepath) !== null && _a !== void 0 ? _a : (0, getConfigFilepath_1.getConfigFilepath)())
|
|
12
|
-
.then(parseIni_1.parseIni)
|
|
13
|
-
.then(getSsoSessionData_1.getSsoSessionData)
|
|
14
|
-
.catch(swallowError);
|
|
15
|
-
};
|
|
16
|
-
exports.loadSsoSessionData = loadSsoSessionData;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeConfigFiles = void 0;
|
|
4
|
-
const mergeConfigFiles = (...files) => {
|
|
5
|
-
const merged = {};
|
|
6
|
-
for (const file of files) {
|
|
7
|
-
for (const [key, values] of Object.entries(file)) {
|
|
8
|
-
if (merged[key] !== undefined) {
|
|
9
|
-
Object.assign(merged[key], values);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
merged[key] = values;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return merged;
|
|
17
|
-
};
|
|
18
|
-
exports.mergeConfigFiles = mergeConfigFiles;
|
|
1
|
+
module.exports = require("./index.js");
|
package/dist-cjs/parseIni.js
CHANGED
|
@@ -1,56 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseIni = void 0;
|
|
4
|
-
const types_1 = require("@smithy/types");
|
|
5
|
-
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
|
|
6
|
-
const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
7
|
-
const profileNameBlockList = ["__proto__", "profile __proto__"];
|
|
8
|
-
const parseIni = (iniData) => {
|
|
9
|
-
const map = {};
|
|
10
|
-
let currentSection;
|
|
11
|
-
let currentSubSection;
|
|
12
|
-
for (const iniLine of iniData.split(/\r?\n/)) {
|
|
13
|
-
const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
|
|
14
|
-
const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
|
|
15
|
-
if (isSection) {
|
|
16
|
-
currentSection = undefined;
|
|
17
|
-
currentSubSection = undefined;
|
|
18
|
-
const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
|
|
19
|
-
const matches = prefixKeyRegex.exec(sectionName);
|
|
20
|
-
if (matches) {
|
|
21
|
-
const [, prefix, , name] = matches;
|
|
22
|
-
if (Object.values(types_1.IniSectionType).includes(prefix)) {
|
|
23
|
-
currentSection = [prefix, name].join(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
currentSection = sectionName;
|
|
28
|
-
}
|
|
29
|
-
if (profileNameBlockList.includes(sectionName)) {
|
|
30
|
-
throw new Error(`Found invalid profile name "${sectionName}"`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else if (currentSection) {
|
|
34
|
-
const indexOfEqualsSign = trimmedLine.indexOf("=");
|
|
35
|
-
if (![0, -1].includes(indexOfEqualsSign)) {
|
|
36
|
-
const [name, value] = [
|
|
37
|
-
trimmedLine.substring(0, indexOfEqualsSign).trim(),
|
|
38
|
-
trimmedLine.substring(indexOfEqualsSign + 1).trim(),
|
|
39
|
-
];
|
|
40
|
-
if (value === "") {
|
|
41
|
-
currentSubSection = name;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (currentSubSection && iniLine.trimStart() === iniLine) {
|
|
45
|
-
currentSubSection = undefined;
|
|
46
|
-
}
|
|
47
|
-
map[currentSection] = map[currentSection] || {};
|
|
48
|
-
const key = currentSubSection ? [currentSubSection, name].join(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR) : name;
|
|
49
|
-
map[currentSection][key] = value;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return map;
|
|
55
|
-
};
|
|
56
|
-
exports.parseIni = parseIni;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseKnownFiles = void 0;
|
|
4
|
-
const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
|
|
5
|
-
const mergeConfigFiles_1 = require("./mergeConfigFiles");
|
|
6
|
-
const parseKnownFiles = async (init) => {
|
|
7
|
-
const parsedFiles = await (0, loadSharedConfigFiles_1.loadSharedConfigFiles)(init);
|
|
8
|
-
return (0, mergeConfigFiles_1.mergeConfigFiles)(parsedFiles.configFile, parsedFiles.credentialsFile);
|
|
9
|
-
};
|
|
10
|
-
exports.parseKnownFiles = parseKnownFiles;
|
|
1
|
+
module.exports = require("./index.js");
|
package/dist-cjs/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
module.exports = require("./index.js");
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/shared-ini-file-loader",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@smithy/types": "^2.
|
|
5
|
+
"@smithy/types": "^2.9.0",
|
|
6
6
|
"tslib": "^2.5.0"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
18
|
-
"build:cjs": "
|
|
18
|
+
"build:cjs": "node ../../scripts/inline shared-ini-file-loader",
|
|
19
19
|
"build:es": "yarn g:tsc -p tsconfig.es.json",
|
|
20
20
|
"build:types": "yarn g:tsc -p tsconfig.types.json",
|
|
21
21
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
@@ -34,6 +34,16 @@
|
|
|
34
34
|
"main": "./dist-cjs/index.js",
|
|
35
35
|
"module": "./dist-es/index.js",
|
|
36
36
|
"types": "./dist-types/index.d.ts",
|
|
37
|
+
"browser": {
|
|
38
|
+
"./dist-es/getSSOTokenFromFile": false,
|
|
39
|
+
"./dist-es/slurpFile": false
|
|
40
|
+
},
|
|
41
|
+
"react-native": {
|
|
42
|
+
"./dist-cjs/getSSOTokenFromFile": false,
|
|
43
|
+
"./dist-cjs/slurpFile": false,
|
|
44
|
+
"./dist-es/getSSOTokenFromFile": false,
|
|
45
|
+
"./dist-es/slurpFile": false
|
|
46
|
+
},
|
|
37
47
|
"engines": {
|
|
38
48
|
"node": ">=14.0.0"
|
|
39
49
|
},
|