@referalli/cli 0.4.7 → 0.4.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 +21 -0
- package/dist/src/apply.d.ts +31 -5
- package/dist/src/apply.js +363 -41
- package/dist/src/commands.d.ts +3 -1
- package/dist/src/commands.js +22 -4
- package/dist/src/config.d.ts +4 -0
- package/dist/src/config.js +5 -1
- package/dist/src/doctor.d.ts +6 -2
- package/dist/src/doctor.js +214 -53
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +11 -3
- package/dist/src/scan.js +20 -14
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/scan.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { LEGACY_ENV, LEGACY_ENV_REMOVAL } from './config.js';
|
|
3
4
|
import { printChecks } from './doctor.js';
|
|
4
5
|
const MAX_BYTES = 1024 * 1024;
|
|
5
6
|
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build', '.next']);
|
|
6
7
|
const LOCKFILE = /\.(lock|lockb)$|^(pnpm-lock\.yaml|package-lock\.json|npm-shrinkwrap\.json|go\.sum)$/;
|
|
7
|
-
const
|
|
8
|
+
const REMOVAL = `removal ${LEGACY_ENV_REMOVAL}`;
|
|
8
9
|
const PUBLISHED = new Set(['cli', 'express', 'mcp', 'next', 'react', 'react-native']);
|
|
9
10
|
const packageName = (old) => {
|
|
10
11
|
const name = old.slice('@referally/'.length);
|
|
@@ -12,23 +13,27 @@ const packageName = (old) => {
|
|
|
12
13
|
return 'referalli';
|
|
13
14
|
return PUBLISHED.has(name) ? `@referalli/${name}` : 'no published replacement';
|
|
14
15
|
};
|
|
15
|
-
// Dates come from docs: Renamed from Referally
|
|
16
|
+
// Dates come from docs: Renamed from Referally (the cookie twin goes first, the rest on one later date).
|
|
16
17
|
const RULES = [
|
|
17
|
-
{ re: /\w*REFERALLY_\w*/g, to: (o) => o.replace('REFERALLY_', 'REFERALLI_'), removal:
|
|
18
|
-
{ re: /referally-version/gi, to: () => 'referalli-version', removal:
|
|
18
|
+
{ re: /\w*REFERALLY_\w*/g, to: (o) => o.replace('REFERALLY_', 'REFERALLI_'), removal: REMOVAL },
|
|
19
|
+
{ re: /referally-version/gi, to: () => 'referalli-version', removal: REMOVAL },
|
|
19
20
|
{ re: /referally_ctx/g, to: () => 'referalli_ctx', removal: 'removal 2027-01-31' },
|
|
20
|
-
{ re: /x-referally-[\w-]*/gi, to: (o) => o.toLowerCase().replace('referally', 'referalli'), removal:
|
|
21
|
-
{ re: /@referally\/[\w.-]*/g, to: packageName, removal:
|
|
21
|
+
{ re: /x-referally-[\w-]*/gi, to: (o) => o.toLowerCase().replace('referally', 'referalli'), removal: REMOVAL },
|
|
22
|
+
{ re: /@referally\/[\w.-]*/g, to: packageName, removal: REMOVAL },
|
|
22
23
|
];
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* One line per old name per line. An env name is a warning only when Referalli itself read it;
|
|
26
|
+
* any other REFERALLY_* is the app's own name (info): nothing of ours stops reading it.
|
|
27
|
+
*/
|
|
24
28
|
function scanFile(path, text) {
|
|
25
29
|
if (!/referally/i.test(text))
|
|
26
30
|
return [];
|
|
27
|
-
return text.split('\n').flatMap((line, i) => RULES.flatMap(({ re, to, removal }) => [...new Set(line.match(re) ?? [])].map((old) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
return text.split('\n').flatMap((line, i) => RULES.flatMap(({ re, to, removal }) => [...new Set(line.match(re) ?? [])].map((old) => {
|
|
32
|
+
const own = /REFERALLY_/.test(old) && !LEGACY_ENV.includes(old);
|
|
33
|
+
return own
|
|
34
|
+
? { id: `${path}:${i + 1}`, status: 'info', message: `${old}: your own name (Referalli never read it); rename it to ${to(old)} if you like` }
|
|
35
|
+
: { id: `${path}:${i + 1}`, status: 'warn', message: `${old} → ${to(old)} (${removal})` };
|
|
36
|
+
})));
|
|
32
37
|
}
|
|
33
38
|
/** `referalli doctor --scan <dir> [--strict]`: old names in a source tree. Needs no key and calls no API. */
|
|
34
39
|
export function runScan(out, err, dir, opts) {
|
|
@@ -65,7 +70,8 @@ export function runScan(out, err, dir, opts) {
|
|
|
65
70
|
if (!existsSync(dir) || !statSync(dir).isDirectory())
|
|
66
71
|
throw new Error(`${dir}: not a directory`);
|
|
67
72
|
walk(dir);
|
|
73
|
+
const warnings = hits.filter((h) => h.status === 'warn').length;
|
|
68
74
|
printChecks(out, hits.length ? hits : [{ id: 'names', status: 'ok', message: 'no old Referally names found' }], opts.json);
|
|
69
|
-
err(`Scanned ${files} file(s), ${
|
|
70
|
-
return opts.strict &&
|
|
75
|
+
err(`Scanned ${files} file(s), ${warnings} old name(s) Referalli reads, ${hits.length - warnings} of your own; skipped ${skipped} (over 1 MB, binary or unreadable).`);
|
|
76
|
+
return opts.strict && warnings ? 1 : 0;
|
|
71
77
|
}
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept in step with package.json by test/version.test.ts. */
|
|
2
|
-
export declare const VERSION = "0.4.
|
|
2
|
+
export declare const VERSION = "0.4.9";
|
package/dist/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept in step with package.json by test/version.test.ts. */
|
|
2
|
-
export const VERSION = '0.4.
|
|
2
|
+
export const VERSION = '0.4.9';
|
package/package.json
CHANGED