kryptheon 0.1.51 → 0.1.52
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 +8 -0
- package/bin/kryptheon.js +75 -13
- package/kryptheon-dashboard-page.js +9 -2
- package/kryptheon-dashboard.js +7 -2
- package/kryptheon-fixture.js +9 -0
- package/kryptheon-replay.js +19 -0
- package/kryptheon-reporter.js +8 -0
- package/kryptheon-secrets.js +44 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -401,6 +401,14 @@ once, and says so.
|
|
|
401
401
|
A `.env` in the same folder is loaded automatically, and anything you type into a
|
|
402
402
|
password box is replaced with an environment variable rather than written into
|
|
403
403
|
the test. When there is a password, `.env` is added to an existing `.gitignore`.
|
|
404
|
+
Kryptheon's names are always added to the end of your `.env`, never written over
|
|
405
|
+
it, so your app's own values stay. Your app's own `.env.example` is never changed.
|
|
406
|
+
|
|
407
|
+
Each replay gets time by its length: 30 seconds plus 3 per step, at least 60
|
|
408
|
+
seconds and at most 3 minutes. A recording of more than 40 steps still runs, but
|
|
409
|
+
you are told when you make it that shorter ones, one task each, say more clearly
|
|
410
|
+
what broke. A run where every recording was skipped (a password not set yet) is
|
|
411
|
+
still listed under Runs, with each recording and why.
|
|
404
412
|
|
|
405
413
|
## What Kryptheon does not check
|
|
406
414
|
|
package/bin/kryptheon.js
CHANGED
|
@@ -154,6 +154,7 @@ function runPlaywright(args, options) {
|
|
|
154
154
|
cwd: USER_DIR,
|
|
155
155
|
stdio: quiet ? ['inherit', 'inherit', 'pipe'] : 'inherit',
|
|
156
156
|
encoding: 'utf8',
|
|
157
|
+
env: (options && options.env) ? Object.assign({}, process.env, options.env) : process.env,
|
|
157
158
|
});
|
|
158
159
|
|
|
159
160
|
if (result.error) {
|
|
@@ -183,7 +184,13 @@ function ensureBrowser() {
|
|
|
183
184
|
console.log(' Downloading a browser to run your app in.');
|
|
184
185
|
console.log(' This is about 200MB and only happens once.');
|
|
185
186
|
console.log('');
|
|
186
|
-
|
|
187
|
+
// Playwright's install deletes every browser it thinks no other copy of
|
|
188
|
+
// Playwright still uses. With Kryptheon installed in a project and run by
|
|
189
|
+
// npx too, each install deleted the other's browser, so every run
|
|
190
|
+
// downloaded 200MB again (a real user's machine, 2026-10-22). Nothing is
|
|
191
|
+
// deleted now; the version is also pinned exactly in package.json, so
|
|
192
|
+
// every install of one Kryptheon wants the same browser.
|
|
193
|
+
const status = runPlaywright(['install', 'chromium'], { env: { PLAYWRIGHT_SKIP_BROWSER_GC: '1' } }).status;
|
|
187
194
|
if (status !== 0) {
|
|
188
195
|
console.error('');
|
|
189
196
|
console.error(' The browser download did not finish.');
|
|
@@ -1020,22 +1027,29 @@ function reportSecrets(replacements) {
|
|
|
1020
1027
|
// Written rather than described. Asked to make the file themselves, most
|
|
1021
1028
|
// people on Windows reach for Notepad or Out-File, both of which add a byte
|
|
1022
1029
|
// order mark that makes the first line unreadable.
|
|
1030
|
+
// Never "save .env.example as .env": an app's own .env usually exists
|
|
1031
|
+
// already, with its database URL and live keys in it, and saving over it
|
|
1032
|
+
// loses all of them (a real user's app, 2026-10-22). The names are always
|
|
1033
|
+
// added to .env; the example file is only a list of what is needed, and only
|
|
1034
|
+
// ever Kryptheon's own (writeEnvExample leaves an app's example alone).
|
|
1023
1035
|
const hasEnv = fs.existsSync(path.join(USER_DIR, '.env'));
|
|
1024
1036
|
const example = hasEnv ? null : secrets.writeEnvExample(USER_DIR, names);
|
|
1025
1037
|
// Each account has its own name, so the owner's and a member's recordings
|
|
1026
1038
|
// can both sign in (blind round 19).
|
|
1027
1039
|
const whose = (item) => (item.account ? ' (' + String(item.field).toLowerCase() + ' of ' + item.account + ')' : '');
|
|
1040
|
+
if (hasEnv) {
|
|
1041
|
+
console.log(' Before this can be checked, add it to the .env in this folder. Keep');
|
|
1042
|
+
console.log(' everything already in it - your app needs those values:');
|
|
1043
|
+
} else {
|
|
1044
|
+
console.log(' Before this can be checked, put it in a file called .env in this folder:');
|
|
1045
|
+
}
|
|
1046
|
+
for (const item of replacements) console.log(' ' + item.envName + '=yourpassword' + whose(item));
|
|
1047
|
+
console.log('');
|
|
1048
|
+
for (const line of secrets.howToWriteEnv(names)) console.log(line);
|
|
1028
1049
|
if (example) {
|
|
1029
|
-
console.log(' A file called .env.example has been written here:');
|
|
1030
|
-
for (const item of replacements) console.log(' ' + item.envName + '=yourpassword' + whose(item));
|
|
1031
1050
|
console.log('');
|
|
1032
|
-
console.log('
|
|
1033
|
-
|
|
1034
|
-
console.log(' Before this can be checked, put it in a file called .env next to');
|
|
1035
|
-
console.log(' your tests, like this:');
|
|
1036
|
-
for (const item of replacements) {
|
|
1037
|
-
console.log(' ' + item.envName + '=your ' + String(item.field).toLowerCase() + ' here' + whose(item));
|
|
1038
|
-
}
|
|
1051
|
+
console.log(' The names are also listed in .env.example, without the password, for');
|
|
1052
|
+
console.log(' anyone else who runs these checks.');
|
|
1039
1053
|
}
|
|
1040
1054
|
console.log('');
|
|
1041
1055
|
// Said plainly, because the alternative is signing in with a blank password
|
|
@@ -1275,6 +1289,23 @@ function reportReplayRisks(relativeFile) {
|
|
|
1275
1289
|
return risks;
|
|
1276
1290
|
}
|
|
1277
1291
|
|
|
1292
|
+
// A long recording still runs - it gets more time (replay.timeBudget) - but
|
|
1293
|
+
// one that does many things breaks for any of them, and says less about which.
|
|
1294
|
+
// Said once, when it is made, while recording a shorter one is still easy.
|
|
1295
|
+
function reportLength(relativeFile) {
|
|
1296
|
+
const source = readSpec(relativeFile);
|
|
1297
|
+
if (source === null) return 0;
|
|
1298
|
+
const steps = replay.readActions(source).length;
|
|
1299
|
+
if (steps <= replay.LONG_RECORDING) return steps;
|
|
1300
|
+
const secs = Math.round(replay.timeBudget(source) / 1000);
|
|
1301
|
+
console.log(' This recording is long: ' + steps + ' steps. Each replay gets up to ' + secs + ' seconds.');
|
|
1302
|
+
console.log(' It will run, but when it breaks, any one of those steps could be why.');
|
|
1303
|
+
console.log(' Shorter recordings - one task each, like "sign in and add a note" - are');
|
|
1304
|
+
console.log(' faster and say exactly what broke.');
|
|
1305
|
+
console.log('');
|
|
1306
|
+
return steps;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1278
1309
|
// Everything that has to happen to whatever codegen left behind, however
|
|
1279
1310
|
// the run ended. Module level so it can be exercised directly.
|
|
1280
1311
|
async function finaliseRecording(outFile, context) {
|
|
@@ -1315,6 +1346,7 @@ async function finaliseRecording(outFile, context) {
|
|
|
1315
1346
|
await offerToDropLogout(named);
|
|
1316
1347
|
reportReplayRisks(named);
|
|
1317
1348
|
reportFragileSelectors(named);
|
|
1349
|
+
reportLength(named);
|
|
1318
1350
|
|
|
1319
1351
|
return { code: 0, savedAs: named };
|
|
1320
1352
|
}
|
|
@@ -1882,6 +1914,26 @@ function triageSpecs() {
|
|
|
1882
1914
|
};
|
|
1883
1915
|
}
|
|
1884
1916
|
|
|
1917
|
+
/** Each recording the run leaves out, with the reason in a few words. */
|
|
1918
|
+
function skippedOf(triage) {
|
|
1919
|
+
const file = (name) => path.join('tests', name).split(path.sep).join('/');
|
|
1920
|
+
return triage.missingSecrets.map((item) => ({ file: file(item.name), why: item.names.join(', ') + ' not set in .env' }))
|
|
1921
|
+
.concat(triage.notRecordings.map((name) => ({ file: file(name), why: 'not a real recording' })));
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
/** A run that replayed nothing, kept in the history like any other run. */
|
|
1925
|
+
function recordSkippedRun(skipped) {
|
|
1926
|
+
if (!skipped.length) return;
|
|
1927
|
+
const entry = { runAt: new Date().toISOString(), status: 'skipped', durationMs: 0, passed: 0, failed: 0, tests: [], skipped: skipped };
|
|
1928
|
+
try {
|
|
1929
|
+
const file = store.pathsFor(USER_DIR).history;
|
|
1930
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
1931
|
+
fs.appendFileSync(file, JSON.stringify(entry) + '\n', 'utf8');
|
|
1932
|
+
} catch (err) {
|
|
1933
|
+
// The terminal has already said everything; the history is a record of it.
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1885
1937
|
function check(options) {
|
|
1886
1938
|
const quiet = !!(options && options.quiet);
|
|
1887
1939
|
|
|
@@ -1937,8 +1989,8 @@ function check(options) {
|
|
|
1937
1989
|
|
|
1938
1990
|
for (const item of triage.missingSecrets) {
|
|
1939
1991
|
console.log('');
|
|
1940
|
-
const
|
|
1941
|
-
for (const line of secrets.missingSecretLines(path.join('tests', item.name), item.names, {
|
|
1992
|
+
const envExists = fs.existsSync(path.join(USER_DIR, '.env'));
|
|
1993
|
+
for (const line of secrets.missingSecretLines(path.join('tests', item.name), item.names, { envExists: envExists })) {
|
|
1942
1994
|
console.log(line);
|
|
1943
1995
|
}
|
|
1944
1996
|
}
|
|
@@ -1966,13 +2018,19 @@ function check(options) {
|
|
|
1966
2018
|
console.log(' Record it again: npx kryptheon record <url>');
|
|
1967
2019
|
}
|
|
1968
2020
|
|
|
2021
|
+
// What was left out, and why: kept with the run, so the dashboard's Runs
|
|
2022
|
+
// page says it. A run where everything was skipped used to leave no trace
|
|
2023
|
+
// at all - Runs stayed empty and looked as if nothing had happened (a real
|
|
2024
|
+
// user's app, 2026-10-22).
|
|
2025
|
+
const skipped = skippedOf(triage);
|
|
1969
2026
|
if (!triage.runnable.length) {
|
|
2027
|
+
recordSkippedRun(skipped);
|
|
1970
2028
|
console.log('');
|
|
1971
2029
|
console.log(' Nothing could be checked.');
|
|
1972
2030
|
console.log('');
|
|
1973
2031
|
if (triage.missingSecrets.length) {
|
|
1974
2032
|
console.log(' Every recording here needs a password that is not set yet.');
|
|
1975
|
-
console.log('
|
|
2033
|
+
console.log(' Add it to .env as shown above, and run this again.');
|
|
1976
2034
|
} else {
|
|
1977
2035
|
console.log(' None of the files in tests/ is a usable recording.');
|
|
1978
2036
|
console.log(' Record one with: npx kryptheon record <url>');
|
|
@@ -1987,6 +2045,9 @@ function check(options) {
|
|
|
1987
2045
|
// cannot produce diagnostics can never be counted as passing.
|
|
1988
2046
|
const only = triage.runnable.map((name) => path.join('tests', name).split(path.sep).join('/'));
|
|
1989
2047
|
if (quiet) process.env.KRYPTHEON_QUIET = '1';
|
|
2048
|
+
// The reporter writes this run's history line; it adds what was skipped.
|
|
2049
|
+
if (skipped.length) process.env.KRYPTHEON_SKIPPED = JSON.stringify(skipped);
|
|
2050
|
+
else delete process.env.KRYPTHEON_SKIPPED;
|
|
1990
2051
|
|
|
1991
2052
|
// Debug signatures. The workers cannot print: Playwright pipes their
|
|
1992
2053
|
// descriptors and hands the output to reporter stdio hooks that this
|
|
@@ -3702,6 +3763,7 @@ module.exports = {
|
|
|
3702
3763
|
takeOutSecrets: takeOutSecrets,
|
|
3703
3764
|
reportSecrets: reportSecrets,
|
|
3704
3765
|
reportReplayRisks: reportReplayRisks,
|
|
3766
|
+
reportLength: reportLength,
|
|
3705
3767
|
offerToDropLogout: offerToDropLogout,
|
|
3706
3768
|
noWindowLines: noWindowLines,
|
|
3707
3769
|
windowUndetectedLines: windowUndetectedLines,
|
|
@@ -1149,9 +1149,16 @@
|
|
|
1149
1149
|
if (!state.runs.length) { box.appendChild(el('p', 'empty', 'No recorded flows have been replayed yet. Record one with npx kryptheon record, then press Run checks.')); return; }
|
|
1150
1150
|
state.runs.slice(0, 30).forEach(function (r) {
|
|
1151
1151
|
var row = el('div', 'line-row');
|
|
1152
|
-
|
|
1152
|
+
var skipped = r.skipped || [];
|
|
1153
|
+
// Every recording left out: nothing ran, and the row says why, instead
|
|
1154
|
+
// of the run vanishing from this page.
|
|
1155
|
+
var none = r.status === 'skipped' || (!r.passed && !r.failed && skipped.length);
|
|
1156
|
+
row.appendChild(el('span', 'tag ' + (none ? 'muted' : r.failed ? 'ember' : 'leaf'), none ? 'nothing ran' : r.failed ? r.failed + ' broke' : 'held'));
|
|
1153
1157
|
var text = el('div', 'lr-text');
|
|
1154
|
-
text.appendChild(el('div', null,
|
|
1158
|
+
text.appendChild(el('div', null, none
|
|
1159
|
+
? 'Skipped ' + skipped.length + (skipped.length === 1 ? ' recording' : ' recordings')
|
|
1160
|
+
: (r.passed || 0) + ' held, ' + (r.failed || 0) + ' broke' + (skipped.length ? ', ' + skipped.length + ' skipped' : '')));
|
|
1161
|
+
skipped.forEach(function (s) { text.appendChild(el('div', 'lr-sub', s.file + ' - ' + s.why)); });
|
|
1155
1162
|
text.appendChild(el('div', 'lr-sub', when(r.runAt)));
|
|
1156
1163
|
row.appendChild(text);
|
|
1157
1164
|
if (r.failed) row.appendChild(button('sm', 'arrow', 'See the finding', function () { go('findings', 'confirmed'); }));
|
package/kryptheon-dashboard.js
CHANGED
|
@@ -558,7 +558,12 @@ function buildState(root, env) {
|
|
|
558
558
|
|
|
559
559
|
// Recorded flows: the last run's broken tests are the findings. They were
|
|
560
560
|
// replayed in a real browser, so they are confirmed at runtime.
|
|
561
|
-
|
|
561
|
+
// The last run that replayed something. A run where every recording was
|
|
562
|
+
// skipped (no password set) is listed under Runs, but it re-checked
|
|
563
|
+
// nothing, so it neither clears the last real run's findings nor counts as
|
|
564
|
+
// the flows having been replayed.
|
|
565
|
+
const replayed = history.filter((r) => (r.tests || []).length);
|
|
566
|
+
const lastRun = replayed.length ? replayed[replayed.length - 1] : null;
|
|
562
567
|
if (lastRun && config.enabled.regression) {
|
|
563
568
|
for (const t of lastRun.tests || []) {
|
|
564
569
|
if (t.status !== 'failed' && t.status !== 'timedOut') continue;
|
|
@@ -849,7 +854,7 @@ function buildState(root, env) {
|
|
|
849
854
|
notChecked: NOT_CHECKED,
|
|
850
855
|
findings: findings,
|
|
851
856
|
allFixPrompt: combinedPrompt(forAll),
|
|
852
|
-
runs: history.slice().reverse().map((r) => ({ runAt: r.runAt, status: r.status, passed: r.passed, failed: r.failed, durationMs: r.durationMs })),
|
|
857
|
+
runs: history.slice().reverse().map((r) => ({ runAt: r.runAt, status: r.status, passed: r.passed, failed: r.failed, durationMs: r.durationMs, skipped: (r.skipped || []).slice(0, 20) })),
|
|
853
858
|
recordings: recordings,
|
|
854
859
|
steps: steps,
|
|
855
860
|
// Which app this dashboard is for: its web address, kept here, and whether
|
package/kryptheon-fixture.js
CHANGED
|
@@ -440,6 +440,15 @@ const test = base.test.extend({
|
|
|
440
440
|
/* without it, a failure is said as before */
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
+
// Time by length: a long recording gets longer than Playwright's flat 30
|
|
444
|
+
// seconds (kryptheon-replay.js timeBudget). Set here, before the page is
|
|
445
|
+
// handed to the recording, so every step runs under the new limit.
|
|
446
|
+
try {
|
|
447
|
+
testInfo.setTimeout(replay.timeBudget(fs.readFileSync(testInfo.file, 'utf8')));
|
|
448
|
+
} catch (e) {
|
|
449
|
+
/* Playwright's own limit stands */
|
|
450
|
+
}
|
|
451
|
+
|
|
443
452
|
const key = baselineKey(testInfo.file, testInfo.title);
|
|
444
453
|
|
|
445
454
|
// The steps this recording actually performs. Comments, blank lines and
|
package/kryptheon-replay.js
CHANGED
|
@@ -300,8 +300,27 @@ function recordingId(source) {
|
|
|
300
300
|
return require('crypto').createHash('sha1').update(steps.join('\n')).digest('hex').slice(0, 12);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
// How long one replay of this recording may take, in milliseconds.
|
|
304
|
+
//
|
|
305
|
+
// Playwright's own limit is 30 seconds for the whole test, whatever its
|
|
306
|
+
// length. A correct recording of 40 steps against a live site needs more than
|
|
307
|
+
// that, ran out of time partway, and was reported as the app's fault (a real
|
|
308
|
+
// user's app, 2026-10-22). So: 30 seconds plus 3 per step, never under 60
|
|
309
|
+
// seconds and never over 3 minutes - past that, something really is stuck.
|
|
310
|
+
const BUDGET = { base: 30000, perStep: 3000, min: 60000, max: 180000 };
|
|
311
|
+
// Past this many steps a recording is said to be long when it is made.
|
|
312
|
+
const LONG_RECORDING = 40;
|
|
313
|
+
|
|
314
|
+
function timeBudget(source) {
|
|
315
|
+
const steps = readActions(source).length;
|
|
316
|
+
return Math.min(BUDGET.max, Math.max(BUDGET.min, BUDGET.base + steps * BUDGET.perStep));
|
|
317
|
+
}
|
|
318
|
+
|
|
303
319
|
module.exports = {
|
|
304
320
|
recordingId: recordingId,
|
|
321
|
+
timeBudget: timeBudget,
|
|
322
|
+
BUDGET: BUDGET,
|
|
323
|
+
LONG_RECORDING: LONG_RECORDING,
|
|
305
324
|
readActions: readActions,
|
|
306
325
|
findReplayRisks: findReplayRisks,
|
|
307
326
|
scrubSecrets: scrubSecrets,
|
package/kryptheon-reporter.js
CHANGED
|
@@ -1029,6 +1029,14 @@ class KryptheonReporter {
|
|
|
1029
1029
|
failed: failed,
|
|
1030
1030
|
tests: this.records,
|
|
1031
1031
|
};
|
|
1032
|
+
// Recordings the CLI left out before the run (no password set, not a real
|
|
1033
|
+
// recording), so the Runs page can say what was not replayed.
|
|
1034
|
+
try {
|
|
1035
|
+
const skipped = JSON.parse(process.env.KRYPTHEON_SKIPPED || '[]');
|
|
1036
|
+
if (Array.isArray(skipped) && skipped.length) entry.skipped = skipped;
|
|
1037
|
+
} catch (e) {
|
|
1038
|
+
// a malformed list is left out, never a reason to lose the run
|
|
1039
|
+
}
|
|
1032
1040
|
|
|
1033
1041
|
// Append only - existing lines are never rewritten.
|
|
1034
1042
|
let saved = false;
|
package/kryptheon-secrets.js
CHANGED
|
@@ -76,27 +76,44 @@ function missingSecrets(names, options) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* How to
|
|
79
|
+
* How to add the names to .env without a byte order mark.
|
|
80
80
|
*
|
|
81
81
|
* PowerShell's own `Out-File -Encoding utf8` writes one, and so does Notepad,
|
|
82
82
|
* which is why this spells out a command that does not rather than leaving it
|
|
83
83
|
* to whatever the person reaches for first.
|
|
84
|
+
*
|
|
85
|
+
* Always an append, never a write. The app's own .env is usually already
|
|
86
|
+
* there, holding its database URL and live payment keys; a command that
|
|
87
|
+
* replaced the file would wipe all of them for the sake of one test password
|
|
88
|
+
* (a real user's app, 2026-10-22). Appending also creates the file when there
|
|
89
|
+
* is none, so one command serves both. The leading newline keeps the first
|
|
90
|
+
* name off the end of a last line that has none; a blank line is harmless.
|
|
84
91
|
*/
|
|
85
92
|
function howToWriteEnv(names, platform) {
|
|
86
|
-
const
|
|
87
|
-
|
|
93
|
+
const windows = (platform || process.platform) === 'win32';
|
|
94
|
+
const pairs = names.map((name) => name + '=yourpassword');
|
|
95
|
+
if (windows) {
|
|
96
|
+
// PowerShell's newline is `n inside double quotes. "\n" would be written
|
|
97
|
+
// as a backslash and an n, all on one line.
|
|
88
98
|
return [
|
|
89
|
-
' In PowerShell, this
|
|
90
|
-
'
|
|
99
|
+
' In PowerShell, this adds it to the end of .env (it keeps what is',
|
|
100
|
+
' already there, and writes no byte order mark):',
|
|
101
|
+
' [IO.File]::AppendAllText("$PWD\\.env", "`n' + pairs.join('`n') + '`n")',
|
|
91
102
|
'',
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
// Not "avoid Notepad" any more: readEnvFile drops a byte order mark, so
|
|
104
|
+
// editing the file in any editor afterwards is fine.
|
|
105
|
+
' Then open .env and replace yourpassword with the real one.',
|
|
94
106
|
];
|
|
95
107
|
}
|
|
96
|
-
return [
|
|
108
|
+
return [
|
|
109
|
+
' This adds it to the end of .env and keeps what is already there:',
|
|
110
|
+
" printf '\\n" + pairs.join('\\n') + "\\n' >> .env",
|
|
111
|
+
'',
|
|
112
|
+
' Then open .env and replace yourpassword with the real one.',
|
|
113
|
+
];
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
/** What to tell somebody who has not
|
|
116
|
+
/** What to tell somebody who has not set the secret yet. */
|
|
100
117
|
function missingSecretLines(specName, names, options) {
|
|
101
118
|
const opts = options || {};
|
|
102
119
|
const many = names.length > 1;
|
|
@@ -105,13 +122,15 @@ function missingSecretLines(specName, names, options) {
|
|
|
105
122
|
' This recording needs a password' + (many ? ' and other secrets' : '') + ', and there is none set.',
|
|
106
123
|
'',
|
|
107
124
|
];
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
// Never "save .env.example as .env": the example may be the app's own, and
|
|
126
|
+
// saving over an existing .env loses every value the app runs on.
|
|
127
|
+
if (opts.envExists) {
|
|
128
|
+
lines.push(' Add ' + (many ? 'these lines' : 'this line') + ' to the .env in this folder. Keep everything');
|
|
129
|
+
lines.push(' already in it - your app needs those values:');
|
|
111
130
|
} else {
|
|
112
131
|
lines.push(' Create a .env file in this folder containing:');
|
|
113
|
-
for (const name of names) lines.push(' ' + name + '=yourpassword');
|
|
114
132
|
}
|
|
133
|
+
for (const name of names) lines.push(' ' + name + '=yourpassword');
|
|
115
134
|
lines.push('');
|
|
116
135
|
for (const line of howToWriteEnv(names, opts.platform)) lines.push(line);
|
|
117
136
|
lines.push('');
|
|
@@ -128,6 +147,11 @@ function missingSecretLines(specName, names, options) {
|
|
|
128
147
|
* names from an earlier recording, and clobbering it would lose them. A name
|
|
129
148
|
* it does not have yet is added at the end - each account now has its own
|
|
130
149
|
* (blind round 19), so a second account's recording brings a second name.
|
|
150
|
+
*
|
|
151
|
+
* Only a file Kryptheon wrote is added to. Many apps ship their own
|
|
152
|
+
* .env.example, listing their own settings; that file is the app's, committed
|
|
153
|
+
* with it, and is left exactly as it is. A file is Kryptheon's when every name
|
|
154
|
+
* in it is one of Kryptheon's (KRYPTHEON_...).
|
|
131
155
|
* Returns the file when it wrote to it, null when there was nothing to add.
|
|
132
156
|
*/
|
|
133
157
|
function writeEnvExample(dir, names) {
|
|
@@ -137,6 +161,7 @@ function writeEnvExample(dir, names) {
|
|
|
137
161
|
let raw = fs.readFileSync(file, 'utf8');
|
|
138
162
|
if (raw.charCodeAt(0) === 0xfeff) raw = raw.slice(1);
|
|
139
163
|
const there = readEnvFile(file);
|
|
164
|
+
if (!isOwnExample(there)) return null;
|
|
140
165
|
const add = (names || []).filter((name) => !(name in there));
|
|
141
166
|
if (!add.length) return null;
|
|
142
167
|
fs.appendFileSync(file, (raw.length && !raw.endsWith('\n') ? '\n' : '') + add.map((name) => name + '=yourpassword').join('\n') + '\n', { encoding: 'utf8' });
|
|
@@ -150,6 +175,11 @@ function writeEnvExample(dir, names) {
|
|
|
150
175
|
}
|
|
151
176
|
}
|
|
152
177
|
|
|
178
|
+
/** An example file holding only Kryptheon's names (or nothing yet). */
|
|
179
|
+
function isOwnExample(values) {
|
|
180
|
+
return Object.keys(values).every((name) => /^KRYPTHEON_/.test(name));
|
|
181
|
+
}
|
|
182
|
+
|
|
153
183
|
// What must never be committed from a project: the real password. The three
|
|
154
184
|
// files of machine state that used to be listed here - baselines, history and
|
|
155
185
|
// test-results/ - are no longer written into the project at all; they live in
|
|
@@ -197,6 +227,7 @@ module.exports = {
|
|
|
197
227
|
missingSecretLines: missingSecretLines,
|
|
198
228
|
howToWriteEnv: howToWriteEnv,
|
|
199
229
|
writeEnvExample: writeEnvExample,
|
|
230
|
+
isOwnExample: isOwnExample,
|
|
200
231
|
updateGitignore: updateGitignore,
|
|
201
232
|
GITIGNORE_ENTRIES: GITIGNORE_ENTRIES,
|
|
202
233
|
isSet: isSet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kryptheon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "Record what you do in your app and get plain-language reports when it breaks.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"node": ">=20.6.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@playwright/test": "
|
|
61
|
+
"@playwright/test": "1.62.1",
|
|
62
62
|
"pg": "^8.23.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|