configorama 0.9.13 → 0.9.14
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/README.md +2063 -389
- package/cli.js +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/main.js +16 -18
- package/src/resolvers/valueFromEnv.js +3 -6
- package/src/resolvers/valueFromFile.js +4 -4
- package/src/resolvers/valueFromGit.js +101 -62
- package/src/resolvers/valueFromOptions.js +3 -7
- package/src/resolvers/valueFromParam.js +2 -1
- package/src/utils/lodash.js +19 -19
- package/src/utils/parsing/parse.js +1 -1
- package/src/utils/parsing/preProcess.js +16 -10
- package/src/utils/regex/index.js +1 -9
- package/src/utils/variables/cleanVariable.js +0 -21
- package/types/src/main.d.ts.map +1 -1
- package/types/src/resolvers/valueFromEnv.d.ts +1 -1
- package/types/src/resolvers/valueFromEnv.d.ts.map +1 -1
- package/types/src/resolvers/valueFromGit.d.ts.map +1 -1
- package/types/src/resolvers/valueFromOptions.d.ts.map +1 -1
- package/types/src/resolvers/valueFromParam.d.ts.map +1 -1
- package/types/src/utils/parsing/preProcess.d.ts.map +1 -1
- package/types/src/utils/regex/index.d.ts +3 -6
- package/types/src/utils/regex/index.d.ts.map +1 -1
- package/types/src/utils/variables/cleanVariable.d.ts.map +1 -1
- package/src/resolvers/valueFromSelf.js +0 -0
|
@@ -145,6 +145,11 @@ function preProcess(configObject, variableSyntax, variableTypes, options = {}) {
|
|
|
145
145
|
|
|
146
146
|
// Comparison operators for detecting string comparison context
|
|
147
147
|
const comparisonOps = ['===', '!==', '==', '!=']
|
|
148
|
+
// Pre-compile "preceded by string+op" patterns to avoid regex compilation per bare ref
|
|
149
|
+
const precededByPatterns = comparisonOps.map(op => {
|
|
150
|
+
const escaped = op.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
151
|
+
return new RegExp(`["'][^"']*["']\\s*${escaped}\\s*$`)
|
|
152
|
+
})
|
|
148
153
|
|
|
149
154
|
// Find and replace bare refs, skipping those inside ${...} or quoted strings
|
|
150
155
|
// Only quote bare refs that are in string comparison context
|
|
@@ -171,18 +176,14 @@ function preProcess(configObject, variableSyntax, variableTypes, options = {}) {
|
|
|
171
176
|
const afterRef = fullContent.substring(matchEnd).trimStart()
|
|
172
177
|
const beforeRef = fullContent.substring(0, matchStart).trimEnd()
|
|
173
178
|
|
|
174
|
-
const isComparedToString = comparisonOps.some(op => {
|
|
179
|
+
const isComparedToString = comparisonOps.some((op, idx) => {
|
|
175
180
|
// Check if followed by: op "string"
|
|
176
181
|
if (afterRef.startsWith(op)) {
|
|
177
182
|
const afterOp = afterRef.substring(op.length).trimStart()
|
|
178
183
|
return afterOp.startsWith('"') || afterOp.startsWith("'")
|
|
179
184
|
}
|
|
180
185
|
// Check if preceded by: "string" op
|
|
181
|
-
|
|
182
|
-
const pattern = new RegExp(`["'][^"']*["']\\s*${o.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*$`)
|
|
183
|
-
if (pattern.test(beforeRef)) return true
|
|
184
|
-
}
|
|
185
|
-
return false
|
|
186
|
+
return precededByPatterns.some(p => p.test(beforeRef))
|
|
186
187
|
})
|
|
187
188
|
|
|
188
189
|
// Replace with var ref - quoted if string comparison, unquoted otherwise
|
|
@@ -367,11 +368,16 @@ function preProcess(configObject, variableSyntax, variableTypes, options = {}) {
|
|
|
367
368
|
*/
|
|
368
369
|
function traverseAndFix(obj) {
|
|
369
370
|
if (typeof obj === 'string') {
|
|
370
|
-
//
|
|
371
|
-
const
|
|
372
|
-
const
|
|
371
|
+
// Early exits: skip expensive processing when patterns are absent
|
|
372
|
+
const hasHelp = obj.indexOf('help(') !== -1
|
|
373
|
+
const hasEvalOrIf = obj.indexOf('if(') !== -1 || obj.indexOf('eval(') !== -1
|
|
374
|
+
const hasComma = obj.indexOf(',') !== -1
|
|
375
|
+
|
|
376
|
+
const withHelpEscaped = hasHelp ? escapeHelpVariables(obj) : obj
|
|
377
|
+
const withBareRefsConverted = hasEvalOrIf ? convertBareRefsInIf(withHelpEscaped) : withHelpEscaped
|
|
373
378
|
// Skip fallback fixing for object configs (they handle bare refs differently)
|
|
374
|
-
|
|
379
|
+
if (skipFallbackFix || !hasComma) return withBareRefsConverted
|
|
380
|
+
return fixFallbacksInString(withBareRefsConverted)
|
|
375
381
|
}
|
|
376
382
|
|
|
377
383
|
if (Array.isArray(obj)) {
|
package/src/utils/regex/index.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Shared regex patterns and utilities
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
// Legacy regex patterns (can't handle nested parentheses properly)
|
|
6
|
-
const funcRegexSimple = /(\w+)\s*\(((?:[^()]+)*)?\s*\)\s*/
|
|
7
|
-
const funcStartOfLineRegex = /^(\w+)\s*\(((?:[^()]+)*)?\s*\)\s*/
|
|
8
|
-
const subFunctionRegex = /(\w+):(\w+)\s*\(((?:[^()]+)*)?\s*\)\s*/
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* Parse a function call with balanced parentheses support
|
|
12
7
|
* Returns a regex-exec-like array: [fullMatch, funcName, args] with index and input properties
|
|
@@ -98,13 +93,10 @@ const textRefSyntax = /^text\((~?[@\{\}\:\$a-zA-Z0-9._\-\/\\%,'" =+]+?)\)/g
|
|
|
98
93
|
|
|
99
94
|
module.exports = {
|
|
100
95
|
funcRegex,
|
|
101
|
-
funcRegexSimple,
|
|
102
|
-
funcStartOfLineRegex,
|
|
103
|
-
subFunctionRegex,
|
|
104
96
|
fileRefSyntax,
|
|
105
97
|
textRefSyntax,
|
|
106
98
|
combineRegexes,
|
|
107
99
|
parseFunctionCall,
|
|
108
|
-
//
|
|
100
|
+
// Alias used by valueFromGit
|
|
109
101
|
functionRegex: funcRegex
|
|
110
102
|
}
|
|
@@ -58,27 +58,6 @@ module.exports = function cleanVariable(
|
|
|
58
58
|
console.log(`Clean output [${caller}]`, clean)
|
|
59
59
|
}
|
|
60
60
|
return clean
|
|
61
|
-
|
|
62
|
-
// Support for simple variable cleaning with no space tweaks
|
|
63
|
-
if (simple) {
|
|
64
|
-
return clean
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Support for function matches that dont need space alterations
|
|
68
|
-
if (!clean.match(fileRefSyntax) && functionRegex.exec(clean)) {
|
|
69
|
-
return clean
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// If file ref, add spaces after commas
|
|
73
|
-
// Special case for file(thing, arg, argTwo)
|
|
74
|
-
if (clean.match(fileRefSyntax)) {
|
|
75
|
-
// replace spaces before and after commas
|
|
76
|
-
return clean.replace(/\s*,\s*/g, ', ')
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return clean.replace(/\s+(?=([^"']*"[^"']*")*[^"']*$)/g, '')
|
|
80
|
-
// ^ trim White Space OutSide Quotes https://regex101.com/r/BuBNPN/1
|
|
81
|
-
// Needed for fallback values with spaces. ${empty, 'fallback value with space'}
|
|
82
61
|
}
|
|
83
62
|
|
|
84
63
|
|
package/types/src/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.js"],"names":[],"mappings":";AA0GA;IACE,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.js"],"names":[],"mappings":";AA0GA;IACE,0CA2dC;IAndC,cAcW;IAuBX,gBAAqB;IAErB,mCAAoC;IAEpC,sBAAwB;IACxB,qBAAuB;IAGvB,uBAA4B;IAsB5B,uBAAoC;IAIpC,kBAAqC;IACrC,kBAAqC;IAErC,yBAA+F;IAC/F,yBAAuD;IACvD,kCAAyE;IAKvE,uBAAgD;IAKhD,YAAuB;IAEvB,oBAA0C;IAE1C,gBAAoD;IAOpD,uBAAkC;IAElC,uBAA8B;IAE9B,uBAAkC;IASpC,wBAAmC;IAGnC,mBAqHC;IAwED,4BAA8C;IAG9C,iCAAkC;IAalC,aA2EC;IAUD,oBAEC;IAGD,eAiDC;IA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U;QAAC,KAAK,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,QAAQ;QAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAsa9J;IAID;;;;;;;;OAQG;IACH,qEAHa,OAAO,CAAC,GAAG,CAAC,CAoExB;IAKD;;;;;;;OAOG;IACH,0FAFa,OAAO,CAAC,GAAG,CAAC,CAiiBxB;IACD,+EA+BC;IACD,yDAiBC;IACD,oEA6BC;IAKD,8CAQC;IACD,kDAyBC;IACD;;;;;;;;;;;;;OAaG;IACH,wEAoDC;IAKD,4BAOC;IACD,sCAqEC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const envRefSyntax: RegExp;
|
|
2
|
-
declare function getValueFromEnv(variableString: any): Promise<string
|
|
2
|
+
declare function getValueFromEnv(variableString: any): Promise<string>;
|
|
3
3
|
export declare let type: string;
|
|
4
4
|
export declare let source: string;
|
|
5
5
|
export declare let syntax: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFromEnv.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromEnv.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"valueFromEnv.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromEnv.js"],"names":[],"mappings":"AAGA,mCAAqC;AAErC,uEAcC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFromGit.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromGit.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"valueFromGit.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromGit.js"],"names":[],"mappings":"AA2XiB;;;;;;;;EAUhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFromOptions.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromOptions.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"valueFromOptions.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromOptions.js"],"names":[],"mappings":"AAEA,mCAAqC;AAErC,sFAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFromParam.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromParam.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"valueFromParam.d.ts","sourceRoot":"","sources":["../../../src/resolvers/valueFromParam.js"],"names":[],"mappings":"AAEA,qCAAyC;AAEzC;;;;;;;;;;GAUG;AACH,mDALW,MAAM,gCAGJ,OAAO,CAAC,GAAG,CAAC,CAqExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preProcess.d.ts","sourceRoot":"","sources":["../../../../src/utils/parsing/preProcess.js"],"names":[],"mappings":";AASA;;;;;;;;GAQG;AACH,+DANW,MAAM,mCAGd;IAA0B,eAAe,GAAjC,OAAO;CACf,
|
|
1
|
+
{"version":3,"file":"preProcess.d.ts","sourceRoot":"","sources":["../../../../src/utils/parsing/preProcess.js"],"names":[],"mappings":";AASA;;;;;;;;GAQG;AACH,+DANW,MAAM,mCAGd;IAA0B,eAAe,GAAjC,OAAO;CACf,OAgYF"}
|
|
@@ -4,12 +4,6 @@ export namespace funcRegex {
|
|
|
4
4
|
export let source: string;
|
|
5
5
|
export function toString(): string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Shared regex patterns and utilities
|
|
9
|
-
*/
|
|
10
|
-
export const funcRegexSimple: RegExp;
|
|
11
|
-
export const funcStartOfLineRegex: RegExp;
|
|
12
|
-
export const subFunctionRegex: RegExp;
|
|
13
7
|
export const fileRefSyntax: RegExp;
|
|
14
8
|
export const textRefSyntax: RegExp;
|
|
15
9
|
/**
|
|
@@ -18,6 +12,9 @@ export const textRefSyntax: RegExp;
|
|
|
18
12
|
* @returns {RegExp} Combined regex with OR operator
|
|
19
13
|
*/
|
|
20
14
|
export function combineRegexes(regexes: RegExp[]): RegExp;
|
|
15
|
+
/**
|
|
16
|
+
* Shared regex patterns and utilities
|
|
17
|
+
*/
|
|
21
18
|
/**
|
|
22
19
|
* Parse a function call with balanced parentheses support
|
|
23
20
|
* Returns a regex-exec-like array: [fullMatch, funcName, args] with index and input properties
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/regex/index.js"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/regex/index.js"],"names":[],"mappings":";;IA0EQ,wCAAwC;;IAGpC,mCAAkC;;AAa9C,mCAA2E;AAC3E,mCAA2E;AAX3E;;;;GAIG;AACH,wCAHW,MAAM,EAAE,GACN,MAAM,CAKlB;AAxFD;;GAEG;AAEH;;;;;;GAMG;AACH,uCAHW,MAAM,GACJ,GAAG,CAyDf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanVariable.d.ts","sourceRoot":"","sources":["../../../../src/utils/variables/cleanVariable.js"],"names":[],"mappings":"AAUiB,2GAFJ,MAAM,
|
|
1
|
+
{"version":3,"file":"cleanVariable.d.ts","sourceRoot":"","sources":["../../../../src/utils/variables/cleanVariable.js"],"names":[],"mappings":"AAUiB,2GAFJ,MAAM,CAoDlB"}
|
|
File without changes
|