@guanghechen/commander 4.7.8 → 4.7.9
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/CHANGELOG.md +7 -0
- package/lib/cjs/browser.cjs +68 -6
- package/lib/cjs/node.cjs +68 -6
- package/lib/esm/browser.mjs +68 -6
- package/lib/esm/node.mjs +68 -6
- package/lib/types/browser.d.ts +1 -0
- package/lib/types/node.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/cjs/browser.cjs
CHANGED
|
@@ -1774,11 +1774,14 @@ class CommandPresetProfileParser {
|
|
|
1774
1774
|
return undefined;
|
|
1775
1775
|
}
|
|
1776
1776
|
const manifest = this.#parsePresetProfileManifest(content, profileFile.displayPath, commandPath);
|
|
1777
|
-
const resolvedProfileSelector =
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1777
|
+
const resolvedProfileSelector = this.#resolvePresetProfileSelector({
|
|
1778
|
+
presetProfile,
|
|
1779
|
+
presetProfileSourceName,
|
|
1780
|
+
manifest,
|
|
1781
|
+
commandPath,
|
|
1782
|
+
presetFileDisplayPath: profileFile.displayPath,
|
|
1783
|
+
});
|
|
1784
|
+
const { profileName: resolvedProfileName, variantName: explicitVariantName } = this.#parsePresetProfileSelector(resolvedProfileSelector.selector, resolvedProfileSelector.sourceName, commandPath);
|
|
1782
1785
|
const profile = manifest.profiles[resolvedProfileName];
|
|
1783
1786
|
if (profile === undefined) {
|
|
1784
1787
|
throw new CommanderError('ConfigurationError', `unknown preset profile "${resolvedProfileName}" in "${profileFile.displayPath}"`, commandPath);
|
|
@@ -1859,6 +1862,52 @@ class CommandPresetProfileParser {
|
|
|
1859
1862
|
}
|
|
1860
1863
|
}
|
|
1861
1864
|
}
|
|
1865
|
+
#resolvePresetProfileSelector(params) {
|
|
1866
|
+
const { presetProfile, presetProfileSourceName, manifest, commandPath, presetFileDisplayPath } = params;
|
|
1867
|
+
if (presetProfile !== undefined) {
|
|
1868
|
+
return {
|
|
1869
|
+
selector: presetProfile,
|
|
1870
|
+
sourceName: presetProfileSourceName ?? PRESET_PROFILE_FLAG,
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
const commandPathSuffixProfile = this.#resolveProfileNameByCommandPathSuffix({
|
|
1874
|
+
commandPath,
|
|
1875
|
+
profiles: manifest.profiles,
|
|
1876
|
+
});
|
|
1877
|
+
if (commandPathSuffixProfile !== undefined) {
|
|
1878
|
+
return {
|
|
1879
|
+
selector: commandPathSuffixProfile,
|
|
1880
|
+
sourceName: 'commandPath.suffix',
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
if (manifest.defaults?.profile !== undefined) {
|
|
1884
|
+
return {
|
|
1885
|
+
selector: manifest.defaults.profile,
|
|
1886
|
+
sourceName: 'defaults.profile',
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
if (manifest.profiles.default !== undefined) {
|
|
1890
|
+
return {
|
|
1891
|
+
selector: 'default',
|
|
1892
|
+
sourceName: 'profiles["default"]',
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
throw new CommanderError('ConfigurationError', `missing profile for preset file "${presetFileDisplayPath}": provide "${PRESET_PROFILE_FLAG}", define command-path suffix profile, defaults.profile, or profile "default"`, commandPath);
|
|
1896
|
+
}
|
|
1897
|
+
#resolveProfileNameByCommandPathSuffix(params) {
|
|
1898
|
+
const { commandPath, profiles } = params;
|
|
1899
|
+
const commandNames = commandPath
|
|
1900
|
+
.split(' ')
|
|
1901
|
+
.map(value => value.trim())
|
|
1902
|
+
.filter(Boolean);
|
|
1903
|
+
for (let index = 0; index < commandNames.length; index += 1) {
|
|
1904
|
+
const profileName = commandNames.slice(index).join('.');
|
|
1905
|
+
if (profiles[profileName] !== undefined) {
|
|
1906
|
+
return profileName;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
return undefined;
|
|
1910
|
+
}
|
|
1862
1911
|
#parsePresetProfileManifest(content, filepath, commandPath) {
|
|
1863
1912
|
let parsed;
|
|
1864
1913
|
try {
|
|
@@ -2786,7 +2835,7 @@ function scanPresetDirectives(params) {
|
|
|
2786
2835
|
return { cleanArgv, presetFile, presetProfile };
|
|
2787
2836
|
}
|
|
2788
2837
|
function buildPresetSources(params) {
|
|
2789
|
-
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta } = params;
|
|
2838
|
+
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta, presetResolvedEnvFile, } = params;
|
|
2790
2839
|
const presetSourceMeta = presetMeta === undefined
|
|
2791
2840
|
? undefined
|
|
2792
2841
|
: {
|
|
@@ -2794,6 +2843,11 @@ function buildPresetSources(params) {
|
|
|
2794
2843
|
file: presetMeta.file,
|
|
2795
2844
|
profile: presetMeta.profile,
|
|
2796
2845
|
variant: presetMeta.variant,
|
|
2846
|
+
...(presetResolvedEnvFile === undefined
|
|
2847
|
+
? {}
|
|
2848
|
+
: {
|
|
2849
|
+
resolvedEnvFile: presetResolvedEnvFile,
|
|
2850
|
+
}),
|
|
2797
2851
|
};
|
|
2798
2852
|
const presetState = presetSourceMeta === undefined ? 'none' : 'applied';
|
|
2799
2853
|
const sources = {
|
|
@@ -2900,9 +2954,17 @@ async function runPresetStage(params) {
|
|
|
2900
2954
|
presetArgv,
|
|
2901
2955
|
presetEnvs,
|
|
2902
2956
|
presetMeta: resolvedProfile?.issueMeta,
|
|
2957
|
+
presetResolvedEnvFile: resolvePresetEnvFilePath(resolvedProfile),
|
|
2903
2958
|
});
|
|
2904
2959
|
return { tailArgv, envs, segments, sources };
|
|
2905
2960
|
}
|
|
2961
|
+
function resolvePresetEnvFilePath(resolvedProfile) {
|
|
2962
|
+
if (!resolvedProfile) {
|
|
2963
|
+
return undefined;
|
|
2964
|
+
}
|
|
2965
|
+
return (resolvedProfile.variantEnvFileSource?.absolutePath ??
|
|
2966
|
+
resolvedProfile.profileEnvFileSource?.absolutePath);
|
|
2967
|
+
}
|
|
2906
2968
|
|
|
2907
2969
|
function findSubcommandEntry(entries, token) {
|
|
2908
2970
|
return entries.find(entry => entry.name === token || entry.aliases.includes(token));
|
package/lib/cjs/node.cjs
CHANGED
|
@@ -1787,11 +1787,14 @@ class CommandPresetProfileParser {
|
|
|
1787
1787
|
return undefined;
|
|
1788
1788
|
}
|
|
1789
1789
|
const manifest = this.#parsePresetProfileManifest(content, profileFile.displayPath, commandPath);
|
|
1790
|
-
const resolvedProfileSelector =
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1790
|
+
const resolvedProfileSelector = this.#resolvePresetProfileSelector({
|
|
1791
|
+
presetProfile,
|
|
1792
|
+
presetProfileSourceName,
|
|
1793
|
+
manifest,
|
|
1794
|
+
commandPath,
|
|
1795
|
+
presetFileDisplayPath: profileFile.displayPath,
|
|
1796
|
+
});
|
|
1797
|
+
const { profileName: resolvedProfileName, variantName: explicitVariantName } = this.#parsePresetProfileSelector(resolvedProfileSelector.selector, resolvedProfileSelector.sourceName, commandPath);
|
|
1795
1798
|
const profile = manifest.profiles[resolvedProfileName];
|
|
1796
1799
|
if (profile === undefined) {
|
|
1797
1800
|
throw new CommanderError('ConfigurationError', `unknown preset profile "${resolvedProfileName}" in "${profileFile.displayPath}"`, commandPath);
|
|
@@ -1872,6 +1875,52 @@ class CommandPresetProfileParser {
|
|
|
1872
1875
|
}
|
|
1873
1876
|
}
|
|
1874
1877
|
}
|
|
1878
|
+
#resolvePresetProfileSelector(params) {
|
|
1879
|
+
const { presetProfile, presetProfileSourceName, manifest, commandPath, presetFileDisplayPath } = params;
|
|
1880
|
+
if (presetProfile !== undefined) {
|
|
1881
|
+
return {
|
|
1882
|
+
selector: presetProfile,
|
|
1883
|
+
sourceName: presetProfileSourceName ?? PRESET_PROFILE_FLAG,
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
const commandPathSuffixProfile = this.#resolveProfileNameByCommandPathSuffix({
|
|
1887
|
+
commandPath,
|
|
1888
|
+
profiles: manifest.profiles,
|
|
1889
|
+
});
|
|
1890
|
+
if (commandPathSuffixProfile !== undefined) {
|
|
1891
|
+
return {
|
|
1892
|
+
selector: commandPathSuffixProfile,
|
|
1893
|
+
sourceName: 'commandPath.suffix',
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
if (manifest.defaults?.profile !== undefined) {
|
|
1897
|
+
return {
|
|
1898
|
+
selector: manifest.defaults.profile,
|
|
1899
|
+
sourceName: 'defaults.profile',
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
if (manifest.profiles.default !== undefined) {
|
|
1903
|
+
return {
|
|
1904
|
+
selector: 'default',
|
|
1905
|
+
sourceName: 'profiles["default"]',
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
throw new CommanderError('ConfigurationError', `missing profile for preset file "${presetFileDisplayPath}": provide "${PRESET_PROFILE_FLAG}", define command-path suffix profile, defaults.profile, or profile "default"`, commandPath);
|
|
1909
|
+
}
|
|
1910
|
+
#resolveProfileNameByCommandPathSuffix(params) {
|
|
1911
|
+
const { commandPath, profiles } = params;
|
|
1912
|
+
const commandNames = commandPath
|
|
1913
|
+
.split(' ')
|
|
1914
|
+
.map(value => value.trim())
|
|
1915
|
+
.filter(Boolean);
|
|
1916
|
+
for (let index = 0; index < commandNames.length; index += 1) {
|
|
1917
|
+
const profileName = commandNames.slice(index).join('.');
|
|
1918
|
+
if (profiles[profileName] !== undefined) {
|
|
1919
|
+
return profileName;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
return undefined;
|
|
1923
|
+
}
|
|
1875
1924
|
#parsePresetProfileManifest(content, filepath, commandPath) {
|
|
1876
1925
|
let parsed;
|
|
1877
1926
|
try {
|
|
@@ -2799,7 +2848,7 @@ function scanPresetDirectives(params) {
|
|
|
2799
2848
|
return { cleanArgv, presetFile, presetProfile };
|
|
2800
2849
|
}
|
|
2801
2850
|
function buildPresetSources(params) {
|
|
2802
|
-
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta } = params;
|
|
2851
|
+
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta, presetResolvedEnvFile, } = params;
|
|
2803
2852
|
const presetSourceMeta = presetMeta === undefined
|
|
2804
2853
|
? undefined
|
|
2805
2854
|
: {
|
|
@@ -2807,6 +2856,11 @@ function buildPresetSources(params) {
|
|
|
2807
2856
|
file: presetMeta.file,
|
|
2808
2857
|
profile: presetMeta.profile,
|
|
2809
2858
|
variant: presetMeta.variant,
|
|
2859
|
+
...(presetResolvedEnvFile === undefined
|
|
2860
|
+
? {}
|
|
2861
|
+
: {
|
|
2862
|
+
resolvedEnvFile: presetResolvedEnvFile,
|
|
2863
|
+
}),
|
|
2810
2864
|
};
|
|
2811
2865
|
const presetState = presetSourceMeta === undefined ? 'none' : 'applied';
|
|
2812
2866
|
const sources = {
|
|
@@ -2913,9 +2967,17 @@ async function runPresetStage(params) {
|
|
|
2913
2967
|
presetArgv,
|
|
2914
2968
|
presetEnvs,
|
|
2915
2969
|
presetMeta: resolvedProfile?.issueMeta,
|
|
2970
|
+
presetResolvedEnvFile: resolvePresetEnvFilePath(resolvedProfile),
|
|
2916
2971
|
});
|
|
2917
2972
|
return { tailArgv, envs, segments, sources };
|
|
2918
2973
|
}
|
|
2974
|
+
function resolvePresetEnvFilePath(resolvedProfile) {
|
|
2975
|
+
if (!resolvedProfile) {
|
|
2976
|
+
return undefined;
|
|
2977
|
+
}
|
|
2978
|
+
return (resolvedProfile.variantEnvFileSource?.absolutePath ??
|
|
2979
|
+
resolvedProfile.profileEnvFileSource?.absolutePath);
|
|
2980
|
+
}
|
|
2919
2981
|
|
|
2920
2982
|
function findSubcommandEntry(entries, token) {
|
|
2921
2983
|
return entries.find(entry => entry.name === token || entry.aliases.includes(token));
|
package/lib/esm/browser.mjs
CHANGED
|
@@ -1772,11 +1772,14 @@ class CommandPresetProfileParser {
|
|
|
1772
1772
|
return undefined;
|
|
1773
1773
|
}
|
|
1774
1774
|
const manifest = this.#parsePresetProfileManifest(content, profileFile.displayPath, commandPath);
|
|
1775
|
-
const resolvedProfileSelector =
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1775
|
+
const resolvedProfileSelector = this.#resolvePresetProfileSelector({
|
|
1776
|
+
presetProfile,
|
|
1777
|
+
presetProfileSourceName,
|
|
1778
|
+
manifest,
|
|
1779
|
+
commandPath,
|
|
1780
|
+
presetFileDisplayPath: profileFile.displayPath,
|
|
1781
|
+
});
|
|
1782
|
+
const { profileName: resolvedProfileName, variantName: explicitVariantName } = this.#parsePresetProfileSelector(resolvedProfileSelector.selector, resolvedProfileSelector.sourceName, commandPath);
|
|
1780
1783
|
const profile = manifest.profiles[resolvedProfileName];
|
|
1781
1784
|
if (profile === undefined) {
|
|
1782
1785
|
throw new CommanderError('ConfigurationError', `unknown preset profile "${resolvedProfileName}" in "${profileFile.displayPath}"`, commandPath);
|
|
@@ -1857,6 +1860,52 @@ class CommandPresetProfileParser {
|
|
|
1857
1860
|
}
|
|
1858
1861
|
}
|
|
1859
1862
|
}
|
|
1863
|
+
#resolvePresetProfileSelector(params) {
|
|
1864
|
+
const { presetProfile, presetProfileSourceName, manifest, commandPath, presetFileDisplayPath } = params;
|
|
1865
|
+
if (presetProfile !== undefined) {
|
|
1866
|
+
return {
|
|
1867
|
+
selector: presetProfile,
|
|
1868
|
+
sourceName: presetProfileSourceName ?? PRESET_PROFILE_FLAG,
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
const commandPathSuffixProfile = this.#resolveProfileNameByCommandPathSuffix({
|
|
1872
|
+
commandPath,
|
|
1873
|
+
profiles: manifest.profiles,
|
|
1874
|
+
});
|
|
1875
|
+
if (commandPathSuffixProfile !== undefined) {
|
|
1876
|
+
return {
|
|
1877
|
+
selector: commandPathSuffixProfile,
|
|
1878
|
+
sourceName: 'commandPath.suffix',
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
if (manifest.defaults?.profile !== undefined) {
|
|
1882
|
+
return {
|
|
1883
|
+
selector: manifest.defaults.profile,
|
|
1884
|
+
sourceName: 'defaults.profile',
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
if (manifest.profiles.default !== undefined) {
|
|
1888
|
+
return {
|
|
1889
|
+
selector: 'default',
|
|
1890
|
+
sourceName: 'profiles["default"]',
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
throw new CommanderError('ConfigurationError', `missing profile for preset file "${presetFileDisplayPath}": provide "${PRESET_PROFILE_FLAG}", define command-path suffix profile, defaults.profile, or profile "default"`, commandPath);
|
|
1894
|
+
}
|
|
1895
|
+
#resolveProfileNameByCommandPathSuffix(params) {
|
|
1896
|
+
const { commandPath, profiles } = params;
|
|
1897
|
+
const commandNames = commandPath
|
|
1898
|
+
.split(' ')
|
|
1899
|
+
.map(value => value.trim())
|
|
1900
|
+
.filter(Boolean);
|
|
1901
|
+
for (let index = 0; index < commandNames.length; index += 1) {
|
|
1902
|
+
const profileName = commandNames.slice(index).join('.');
|
|
1903
|
+
if (profiles[profileName] !== undefined) {
|
|
1904
|
+
return profileName;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
return undefined;
|
|
1908
|
+
}
|
|
1860
1909
|
#parsePresetProfileManifest(content, filepath, commandPath) {
|
|
1861
1910
|
let parsed;
|
|
1862
1911
|
try {
|
|
@@ -2784,7 +2833,7 @@ function scanPresetDirectives(params) {
|
|
|
2784
2833
|
return { cleanArgv, presetFile, presetProfile };
|
|
2785
2834
|
}
|
|
2786
2835
|
function buildPresetSources(params) {
|
|
2787
|
-
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta } = params;
|
|
2836
|
+
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta, presetResolvedEnvFile, } = params;
|
|
2788
2837
|
const presetSourceMeta = presetMeta === undefined
|
|
2789
2838
|
? undefined
|
|
2790
2839
|
: {
|
|
@@ -2792,6 +2841,11 @@ function buildPresetSources(params) {
|
|
|
2792
2841
|
file: presetMeta.file,
|
|
2793
2842
|
profile: presetMeta.profile,
|
|
2794
2843
|
variant: presetMeta.variant,
|
|
2844
|
+
...(presetResolvedEnvFile === undefined
|
|
2845
|
+
? {}
|
|
2846
|
+
: {
|
|
2847
|
+
resolvedEnvFile: presetResolvedEnvFile,
|
|
2848
|
+
}),
|
|
2795
2849
|
};
|
|
2796
2850
|
const presetState = presetSourceMeta === undefined ? 'none' : 'applied';
|
|
2797
2851
|
const sources = {
|
|
@@ -2898,9 +2952,17 @@ async function runPresetStage(params) {
|
|
|
2898
2952
|
presetArgv,
|
|
2899
2953
|
presetEnvs,
|
|
2900
2954
|
presetMeta: resolvedProfile?.issueMeta,
|
|
2955
|
+
presetResolvedEnvFile: resolvePresetEnvFilePath(resolvedProfile),
|
|
2901
2956
|
});
|
|
2902
2957
|
return { tailArgv, envs, segments, sources };
|
|
2903
2958
|
}
|
|
2959
|
+
function resolvePresetEnvFilePath(resolvedProfile) {
|
|
2960
|
+
if (!resolvedProfile) {
|
|
2961
|
+
return undefined;
|
|
2962
|
+
}
|
|
2963
|
+
return (resolvedProfile.variantEnvFileSource?.absolutePath ??
|
|
2964
|
+
resolvedProfile.profileEnvFileSource?.absolutePath);
|
|
2965
|
+
}
|
|
2904
2966
|
|
|
2905
2967
|
function findSubcommandEntry(entries, token) {
|
|
2906
2968
|
return entries.find(entry => entry.name === token || entry.aliases.includes(token));
|
package/lib/esm/node.mjs
CHANGED
|
@@ -1785,11 +1785,14 @@ class CommandPresetProfileParser {
|
|
|
1785
1785
|
return undefined;
|
|
1786
1786
|
}
|
|
1787
1787
|
const manifest = this.#parsePresetProfileManifest(content, profileFile.displayPath, commandPath);
|
|
1788
|
-
const resolvedProfileSelector =
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1788
|
+
const resolvedProfileSelector = this.#resolvePresetProfileSelector({
|
|
1789
|
+
presetProfile,
|
|
1790
|
+
presetProfileSourceName,
|
|
1791
|
+
manifest,
|
|
1792
|
+
commandPath,
|
|
1793
|
+
presetFileDisplayPath: profileFile.displayPath,
|
|
1794
|
+
});
|
|
1795
|
+
const { profileName: resolvedProfileName, variantName: explicitVariantName } = this.#parsePresetProfileSelector(resolvedProfileSelector.selector, resolvedProfileSelector.sourceName, commandPath);
|
|
1793
1796
|
const profile = manifest.profiles[resolvedProfileName];
|
|
1794
1797
|
if (profile === undefined) {
|
|
1795
1798
|
throw new CommanderError('ConfigurationError', `unknown preset profile "${resolvedProfileName}" in "${profileFile.displayPath}"`, commandPath);
|
|
@@ -1870,6 +1873,52 @@ class CommandPresetProfileParser {
|
|
|
1870
1873
|
}
|
|
1871
1874
|
}
|
|
1872
1875
|
}
|
|
1876
|
+
#resolvePresetProfileSelector(params) {
|
|
1877
|
+
const { presetProfile, presetProfileSourceName, manifest, commandPath, presetFileDisplayPath } = params;
|
|
1878
|
+
if (presetProfile !== undefined) {
|
|
1879
|
+
return {
|
|
1880
|
+
selector: presetProfile,
|
|
1881
|
+
sourceName: presetProfileSourceName ?? PRESET_PROFILE_FLAG,
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
const commandPathSuffixProfile = this.#resolveProfileNameByCommandPathSuffix({
|
|
1885
|
+
commandPath,
|
|
1886
|
+
profiles: manifest.profiles,
|
|
1887
|
+
});
|
|
1888
|
+
if (commandPathSuffixProfile !== undefined) {
|
|
1889
|
+
return {
|
|
1890
|
+
selector: commandPathSuffixProfile,
|
|
1891
|
+
sourceName: 'commandPath.suffix',
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
if (manifest.defaults?.profile !== undefined) {
|
|
1895
|
+
return {
|
|
1896
|
+
selector: manifest.defaults.profile,
|
|
1897
|
+
sourceName: 'defaults.profile',
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
if (manifest.profiles.default !== undefined) {
|
|
1901
|
+
return {
|
|
1902
|
+
selector: 'default',
|
|
1903
|
+
sourceName: 'profiles["default"]',
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
throw new CommanderError('ConfigurationError', `missing profile for preset file "${presetFileDisplayPath}": provide "${PRESET_PROFILE_FLAG}", define command-path suffix profile, defaults.profile, or profile "default"`, commandPath);
|
|
1907
|
+
}
|
|
1908
|
+
#resolveProfileNameByCommandPathSuffix(params) {
|
|
1909
|
+
const { commandPath, profiles } = params;
|
|
1910
|
+
const commandNames = commandPath
|
|
1911
|
+
.split(' ')
|
|
1912
|
+
.map(value => value.trim())
|
|
1913
|
+
.filter(Boolean);
|
|
1914
|
+
for (let index = 0; index < commandNames.length; index += 1) {
|
|
1915
|
+
const profileName = commandNames.slice(index).join('.');
|
|
1916
|
+
if (profiles[profileName] !== undefined) {
|
|
1917
|
+
return profileName;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
return undefined;
|
|
1921
|
+
}
|
|
1873
1922
|
#parsePresetProfileManifest(content, filepath, commandPath) {
|
|
1874
1923
|
let parsed;
|
|
1875
1924
|
try {
|
|
@@ -2797,7 +2846,7 @@ function scanPresetDirectives(params) {
|
|
|
2797
2846
|
return { cleanArgv, presetFile, presetProfile };
|
|
2798
2847
|
}
|
|
2799
2848
|
function buildPresetSources(params) {
|
|
2800
|
-
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta } = params;
|
|
2849
|
+
const { userCmds, userArgv, userEnvs, presetArgv, presetEnvs, presetMeta, presetResolvedEnvFile, } = params;
|
|
2801
2850
|
const presetSourceMeta = presetMeta === undefined
|
|
2802
2851
|
? undefined
|
|
2803
2852
|
: {
|
|
@@ -2805,6 +2854,11 @@ function buildPresetSources(params) {
|
|
|
2805
2854
|
file: presetMeta.file,
|
|
2806
2855
|
profile: presetMeta.profile,
|
|
2807
2856
|
variant: presetMeta.variant,
|
|
2857
|
+
...(presetResolvedEnvFile === undefined
|
|
2858
|
+
? {}
|
|
2859
|
+
: {
|
|
2860
|
+
resolvedEnvFile: presetResolvedEnvFile,
|
|
2861
|
+
}),
|
|
2808
2862
|
};
|
|
2809
2863
|
const presetState = presetSourceMeta === undefined ? 'none' : 'applied';
|
|
2810
2864
|
const sources = {
|
|
@@ -2911,9 +2965,17 @@ async function runPresetStage(params) {
|
|
|
2911
2965
|
presetArgv,
|
|
2912
2966
|
presetEnvs,
|
|
2913
2967
|
presetMeta: resolvedProfile?.issueMeta,
|
|
2968
|
+
presetResolvedEnvFile: resolvePresetEnvFilePath(resolvedProfile),
|
|
2914
2969
|
});
|
|
2915
2970
|
return { tailArgv, envs, segments, sources };
|
|
2916
2971
|
}
|
|
2972
|
+
function resolvePresetEnvFilePath(resolvedProfile) {
|
|
2973
|
+
if (!resolvedProfile) {
|
|
2974
|
+
return undefined;
|
|
2975
|
+
}
|
|
2976
|
+
return (resolvedProfile.variantEnvFileSource?.absolutePath ??
|
|
2977
|
+
resolvedProfile.profileEnvFileSource?.absolutePath);
|
|
2978
|
+
}
|
|
2917
2979
|
|
|
2918
2980
|
function findSubcommandEntry(entries, token) {
|
|
2919
2981
|
return entries.find(entry => entry.name === token || entry.aliases.includes(token));
|
package/lib/types/browser.d.ts
CHANGED
package/lib/types/node.d.ts
CHANGED