@intuned/runtime-dev 1.3.27-dev1 → 1.3.27-dev3
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.
|
@@ -46,20 +46,51 @@ const DEFAULT_USER_PREFERENCES = {
|
|
|
46
46
|
async function createUserDirWithPreferences(profileTemplatePath) {
|
|
47
47
|
const playwrightTempDir = await (0, _fsExtra.mkdtemp)("/tmp/pw-");
|
|
48
48
|
const userDir = (0, _path.join)(playwrightTempDir, "userdir");
|
|
49
|
+
const defaultDir = (0, _path.join)(userDir, "Default");
|
|
50
|
+
const preferencesPath = (0, _path.join)(defaultDir, "Preferences");
|
|
49
51
|
if (profileTemplatePath && (await fs.pathExists(profileTemplatePath))) {
|
|
50
52
|
await fs.copy(profileTemplatePath, userDir, {
|
|
51
53
|
overwrite: true,
|
|
52
54
|
errorOnExist: false
|
|
53
55
|
});
|
|
56
|
+
await (0, _fsExtra.mkdir)(defaultDir, {
|
|
57
|
+
recursive: true
|
|
58
|
+
});
|
|
59
|
+
let templatePreferences = {};
|
|
60
|
+
if (await fs.pathExists(preferencesPath)) {
|
|
61
|
+
try {
|
|
62
|
+
templatePreferences = await fs.readJson(preferencesPath);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.warn(`Failed to parse Preferences from profile template at ${preferencesPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const mergedPreferences = mergePreferences(templatePreferences, DEFAULT_USER_PREFERENCES);
|
|
68
|
+
await (0, _fsExtra.writeFile)(preferencesPath, JSON.stringify(mergedPreferences));
|
|
54
69
|
return userDir;
|
|
55
70
|
}
|
|
56
|
-
const defaultDir = (0, _path.join)(userDir, "Default");
|
|
57
71
|
await (0, _fsExtra.mkdir)(defaultDir, {
|
|
58
72
|
recursive: true
|
|
59
73
|
});
|
|
60
|
-
await (0, _fsExtra.writeFile)(
|
|
74
|
+
await (0, _fsExtra.writeFile)(preferencesPath, JSON.stringify(DEFAULT_USER_PREFERENCES));
|
|
61
75
|
return userDir;
|
|
62
76
|
}
|
|
77
|
+
function isPlainObject(value) {
|
|
78
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
79
|
+
}
|
|
80
|
+
function mergePreferences(base, overrides) {
|
|
81
|
+
const result = {
|
|
82
|
+
...base
|
|
83
|
+
};
|
|
84
|
+
for (const [key, overrideValue] of Object.entries(overrides)) {
|
|
85
|
+
const baseValue = result[key];
|
|
86
|
+
if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {
|
|
87
|
+
result[key] = mergePreferences(baseValue, overrideValue);
|
|
88
|
+
} else {
|
|
89
|
+
result[key] = overrideValue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
63
94
|
async function getIgnoreHttpErrorsFromConfig(cliOption) {
|
|
64
95
|
if (cliOption === true) {
|
|
65
96
|
return true;
|
|
Binary file
|