@pixsame/cypress-plugin-visual-regression-diff 0.0.0-stage → 1.0.0

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.
@@ -0,0 +1,43 @@
1
+ const PLUGIN_NAME = 'cp-visual-regression-diff';
2
+ const LINK_PREFIX = `#${PLUGIN_NAME}-`;
3
+ const OVERLAY_CLASS = `${PLUGIN_NAME}-overlay`;
4
+ const FAB_CLASS = `${PLUGIN_NAME}-fab`;
5
+ const FAB_BADGE_CLASS = `${PLUGIN_NAME}-fab-badge`;
6
+ const IMAGE_SNAPSHOT_PREFIX = `__${PLUGIN_NAME}_snapshots__`;
7
+ exports.FILE_SUFFIX = void 0;
8
+ (function (FILE_SUFFIX) {
9
+ FILE_SUFFIX["diff"] = ".diff";
10
+ FILE_SUFFIX["actual"] = ".actual";
11
+ })(exports.FILE_SUFFIX || (exports.FILE_SUFFIX = {}));
12
+ const TASK = {
13
+ getScreenshotPathInfo: `${PLUGIN_NAME}-getScreenshotPathInfo`,
14
+ compareImages: `${PLUGIN_NAME}-compareImages`,
15
+ approveImage: `${PLUGIN_NAME}-approveImage`,
16
+ cleanupImages: `${PLUGIN_NAME}-cleanupImages`,
17
+ doesFileExist: `${PLUGIN_NAME}-doesFileExist`,
18
+ processImgPath: `${PLUGIN_NAME}-processImgPath`,
19
+ recordPendingDiff: `${PLUGIN_NAME}-recordPendingDiff`,
20
+ getPendingDiffs: `${PLUGIN_NAME}-getPendingDiffs`,
21
+ clearPendingDiffs: `${PLUGIN_NAME}-clearPendingDiffs`
22
+ /* c8 ignore next */
23
+ };
24
+ const PATH_VARIABLES = {
25
+ specPath: '{spec_path}',
26
+ unixSystemRootPath: '{unix_system_root_path}',
27
+ winSystemRootPath: '{win_system_root_path}'
28
+ };
29
+ const WINDOWS_LIKE_DRIVE_REGEX = /^[A-Z]:$/;
30
+ const METADATA_KEY = 'FRSOURCE_CPVRD_V';
31
+ const LS_SHOW_NON_FAILING_DIFFS = 'cp-vrd-show-non-failing-diffs';
32
+
33
+ exports.FAB_BADGE_CLASS = FAB_BADGE_CLASS;
34
+ exports.FAB_CLASS = FAB_CLASS;
35
+ exports.IMAGE_SNAPSHOT_PREFIX = IMAGE_SNAPSHOT_PREFIX;
36
+ exports.LINK_PREFIX = LINK_PREFIX;
37
+ exports.LS_SHOW_NON_FAILING_DIFFS = LS_SHOW_NON_FAILING_DIFFS;
38
+ exports.METADATA_KEY = METADATA_KEY;
39
+ exports.OVERLAY_CLASS = OVERLAY_CLASS;
40
+ exports.PATH_VARIABLES = PATH_VARIABLES;
41
+ exports.TASK = TASK;
42
+ exports.WINDOWS_LIKE_DRIVE_REGEX = WINDOWS_LIKE_DRIVE_REGEX;
43
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["const PLUGIN_NAME = 'cp-visual-regression-diff';\nexport const LINK_PREFIX = `#${PLUGIN_NAME}-`;\nexport const OVERLAY_CLASS = `${PLUGIN_NAME}-overlay`;\nexport const FAB_CLASS = `${PLUGIN_NAME}-fab`;\nexport const FAB_BADGE_CLASS = `${PLUGIN_NAME}-fab-badge`;\nexport const IMAGE_SNAPSHOT_PREFIX = `__${PLUGIN_NAME}_snapshots__`;\n\nexport enum FILE_SUFFIX {\n diff = '.diff',\n actual = '.actual',\n}\n\nexport const TASK = {\n getScreenshotPathInfo: `${PLUGIN_NAME}-getScreenshotPathInfo`,\n compareImages: `${PLUGIN_NAME}-compareImages`,\n approveImage: `${PLUGIN_NAME}-approveImage`,\n cleanupImages: `${PLUGIN_NAME}-cleanupImages`,\n doesFileExist: `${PLUGIN_NAME}-doesFileExist`,\n processImgPath: `${PLUGIN_NAME}-processImgPath`,\n recordPendingDiff: `${PLUGIN_NAME}-recordPendingDiff`,\n getPendingDiffs: `${PLUGIN_NAME}-getPendingDiffs`,\n clearPendingDiffs: `${PLUGIN_NAME}-clearPendingDiffs`,\n /* c8 ignore next */\n};\n\nexport const PATH_VARIABLES = {\n specPath: '{spec_path}',\n unixSystemRootPath: '{unix_system_root_path}',\n winSystemRootPath: '{win_system_root_path}',\n} as const;\n\nexport const WINDOWS_LIKE_DRIVE_REGEX = /^[A-Z]:$/;\n\nexport const METADATA_KEY = 'FRSOURCE_CPVRD_V';\n\nexport const LS_SHOW_NON_FAILING_DIFFS = 'cp-vrd-show-non-failing-diffs';\n"],"names":["PLUGIN_NAME","LINK_PREFIX","OVERLAY_CLASS","FAB_CLASS","FAB_BADGE_CLASS","IMAGE_SNAPSHOT_PREFIX","FILE_SUFFIX","TASK","getScreenshotPathInfo","compareImages","approveImage","cleanupImages","doesFileExist","processImgPath","recordPendingDiff","getPendingDiffs","clearPendingDiffs","PATH_VARIABLES","specPath","unixSystemRootPath","winSystemRootPath","WINDOWS_LIKE_DRIVE_REGEX","METADATA_KEY","LS_SHOW_NON_FAILING_DIFFS"],"mappings":"AAAA,MAAMA,WAAW,GAAG,2BAA2B,CAAA;AAClCC,MAAAA,WAAW,GAAG,CAAA,CAAA,EAAID,WAAW,CAAG,CAAA,EAAA;AAChCE,MAAAA,aAAa,GAAG,CAAA,EAAGF,WAAW,CAAU,QAAA,EAAA;AACxCG,MAAAA,SAAS,GAAG,CAAA,EAAGH,WAAW,CAAM,IAAA,EAAA;AAChCI,MAAAA,eAAe,GAAG,CAAA,EAAGJ,WAAW,CAAY,UAAA,EAAA;AAC5CK,MAAAA,qBAAqB,GAAG,CAAA,EAAA,EAAKL,WAAW,CAAc,YAAA,EAAA;AAEvDM,6BAGX;AAHD,CAAA,UAAYA,WAAW,EAAA;AACrBA,EAAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACdA,EAAAA,WAAA,CAAA,QAAA,CAAA,GAAA,SAAkB,CAAA;AACpB,CAAC,EAHWA,mBAAW,KAAXA,mBAAW,GAGtB,EAAA,CAAA,CAAA,CAAA;AAEM,MAAMC,IAAI,GAAG;EAClBC,qBAAqB,EAAE,CAAGR,EAAAA,WAAW,CAAwB,sBAAA,CAAA;EAC7DS,aAAa,EAAE,CAAGT,EAAAA,WAAW,CAAgB,cAAA,CAAA;EAC7CU,YAAY,EAAE,CAAGV,EAAAA,WAAW,CAAe,aAAA,CAAA;EAC3CW,aAAa,EAAE,CAAGX,EAAAA,WAAW,CAAgB,cAAA,CAAA;EAC7CY,aAAa,EAAE,CAAGZ,EAAAA,WAAW,CAAgB,cAAA,CAAA;EAC7Ca,cAAc,EAAE,CAAGb,EAAAA,WAAW,CAAiB,eAAA,CAAA;EAC/Cc,iBAAiB,EAAE,CAAGd,EAAAA,WAAW,CAAoB,kBAAA,CAAA;EACrDe,eAAe,EAAE,CAAGf,EAAAA,WAAW,CAAkB,gBAAA,CAAA;EACjDgB,iBAAiB,EAAE,GAAGhB,WAAW,CAAA,kBAAA,CAAA;AACjC;EACD;AAEM,MAAMiB,cAAc,GAAG;AAC5BC,EAAAA,QAAQ,EAAE,aAAa;AACvBC,EAAAA,kBAAkB,EAAE,yBAAyB;AAC7CC,EAAAA,iBAAiB,EAAE,wBAAA;EACX;AAEH,MAAMC,wBAAwB,GAAG,WAAU;AAE3C,MAAMC,YAAY,GAAG,mBAAkB;AAEvC,MAAMC,yBAAyB,GAAG;;;;;;;;;;;;;"}
@@ -0,0 +1,34 @@
1
+ const PLUGIN_NAME = 'cp-visual-regression-diff';
2
+ const LINK_PREFIX = `#${PLUGIN_NAME}-`;
3
+ const OVERLAY_CLASS = `${PLUGIN_NAME}-overlay`;
4
+ const FAB_CLASS = `${PLUGIN_NAME}-fab`;
5
+ const FAB_BADGE_CLASS = `${PLUGIN_NAME}-fab-badge`;
6
+ const IMAGE_SNAPSHOT_PREFIX = `__${PLUGIN_NAME}_snapshots__`;
7
+ var FILE_SUFFIX;
8
+ (function (FILE_SUFFIX) {
9
+ FILE_SUFFIX["diff"] = ".diff";
10
+ FILE_SUFFIX["actual"] = ".actual";
11
+ })(FILE_SUFFIX || (FILE_SUFFIX = {}));
12
+ const TASK = {
13
+ getScreenshotPathInfo: `${PLUGIN_NAME}-getScreenshotPathInfo`,
14
+ compareImages: `${PLUGIN_NAME}-compareImages`,
15
+ approveImage: `${PLUGIN_NAME}-approveImage`,
16
+ cleanupImages: `${PLUGIN_NAME}-cleanupImages`,
17
+ doesFileExist: `${PLUGIN_NAME}-doesFileExist`,
18
+ processImgPath: `${PLUGIN_NAME}-processImgPath`,
19
+ recordPendingDiff: `${PLUGIN_NAME}-recordPendingDiff`,
20
+ getPendingDiffs: `${PLUGIN_NAME}-getPendingDiffs`,
21
+ clearPendingDiffs: `${PLUGIN_NAME}-clearPendingDiffs`
22
+ /* c8 ignore next */
23
+ };
24
+ const PATH_VARIABLES = {
25
+ specPath: '{spec_path}',
26
+ unixSystemRootPath: '{unix_system_root_path}',
27
+ winSystemRootPath: '{win_system_root_path}'
28
+ };
29
+ const WINDOWS_LIKE_DRIVE_REGEX = /^[A-Z]:$/;
30
+ const METADATA_KEY = 'FRSOURCE_CPVRD_V';
31
+ const LS_SHOW_NON_FAILING_DIFFS = 'cp-vrd-show-non-failing-diffs';
32
+
33
+ export { FAB_BADGE_CLASS, FAB_CLASS, FILE_SUFFIX, IMAGE_SNAPSHOT_PREFIX, LINK_PREFIX, LS_SHOW_NON_FAILING_DIFFS, METADATA_KEY, OVERLAY_CLASS, PATH_VARIABLES, TASK, WINDOWS_LIKE_DRIVE_REGEX };
34
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sources":["../src/constants.ts"],"sourcesContent":["const PLUGIN_NAME = 'cp-visual-regression-diff';\nexport const LINK_PREFIX = `#${PLUGIN_NAME}-`;\nexport const OVERLAY_CLASS = `${PLUGIN_NAME}-overlay`;\nexport const FAB_CLASS = `${PLUGIN_NAME}-fab`;\nexport const FAB_BADGE_CLASS = `${PLUGIN_NAME}-fab-badge`;\nexport const IMAGE_SNAPSHOT_PREFIX = `__${PLUGIN_NAME}_snapshots__`;\n\nexport enum FILE_SUFFIX {\n diff = '.diff',\n actual = '.actual',\n}\n\nexport const TASK = {\n getScreenshotPathInfo: `${PLUGIN_NAME}-getScreenshotPathInfo`,\n compareImages: `${PLUGIN_NAME}-compareImages`,\n approveImage: `${PLUGIN_NAME}-approveImage`,\n cleanupImages: `${PLUGIN_NAME}-cleanupImages`,\n doesFileExist: `${PLUGIN_NAME}-doesFileExist`,\n processImgPath: `${PLUGIN_NAME}-processImgPath`,\n recordPendingDiff: `${PLUGIN_NAME}-recordPendingDiff`,\n getPendingDiffs: `${PLUGIN_NAME}-getPendingDiffs`,\n clearPendingDiffs: `${PLUGIN_NAME}-clearPendingDiffs`,\n /* c8 ignore next */\n};\n\nexport const PATH_VARIABLES = {\n specPath: '{spec_path}',\n unixSystemRootPath: '{unix_system_root_path}',\n winSystemRootPath: '{win_system_root_path}',\n} as const;\n\nexport const WINDOWS_LIKE_DRIVE_REGEX = /^[A-Z]:$/;\n\nexport const METADATA_KEY = 'FRSOURCE_CPVRD_V';\n\nexport const LS_SHOW_NON_FAILING_DIFFS = 'cp-vrd-show-non-failing-diffs';\n"],"names":["PLUGIN_NAME","LINK_PREFIX","OVERLAY_CLASS","FAB_CLASS","FAB_BADGE_CLASS","IMAGE_SNAPSHOT_PREFIX","FILE_SUFFIX","TASK","getScreenshotPathInfo","compareImages","approveImage","cleanupImages","doesFileExist","processImgPath","recordPendingDiff","getPendingDiffs","clearPendingDiffs","PATH_VARIABLES","specPath","unixSystemRootPath","winSystemRootPath","WINDOWS_LIKE_DRIVE_REGEX","METADATA_KEY","LS_SHOW_NON_FAILING_DIFFS"],"mappings":"AAAA,MAAMA,WAAW,GAAG,2BAA2B,CAAA;AAClCC,MAAAA,WAAW,GAAG,CAAA,CAAA,EAAID,WAAW,CAAG,CAAA,EAAA;AAChCE,MAAAA,aAAa,GAAG,CAAA,EAAGF,WAAW,CAAU,QAAA,EAAA;AACxCG,MAAAA,SAAS,GAAG,CAAA,EAAGH,WAAW,CAAM,IAAA,EAAA;AAChCI,MAAAA,eAAe,GAAG,CAAA,EAAGJ,WAAW,CAAY,UAAA,EAAA;AAC5CK,MAAAA,qBAAqB,GAAG,CAAA,EAAA,EAAKL,WAAW,CAAc,YAAA,EAAA;IAEvDM,YAGX;AAHD,CAAA,UAAYA,WAAW,EAAA;AACrBA,EAAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACdA,EAAAA,WAAA,CAAA,QAAA,CAAA,GAAA,SAAkB,CAAA;AACpB,CAAC,EAHWA,WAAW,KAAXA,WAAW,GAGtB,EAAA,CAAA,CAAA,CAAA;AAEM,MAAMC,IAAI,GAAG;EAClBC,qBAAqB,EAAE,CAAGR,EAAAA,WAAW,CAAwB,sBAAA,CAAA;EAC7DS,aAAa,EAAE,CAAGT,EAAAA,WAAW,CAAgB,cAAA,CAAA;EAC7CU,YAAY,EAAE,CAAGV,EAAAA,WAAW,CAAe,aAAA,CAAA;EAC3CW,aAAa,EAAE,CAAGX,EAAAA,WAAW,CAAgB,cAAA,CAAA;EAC7CY,aAAa,EAAE,CAAGZ,EAAAA,WAAW,CAAgB,cAAA,CAAA;EAC7Ca,cAAc,EAAE,CAAGb,EAAAA,WAAW,CAAiB,eAAA,CAAA;EAC/Cc,iBAAiB,EAAE,CAAGd,EAAAA,WAAW,CAAoB,kBAAA,CAAA;EACrDe,eAAe,EAAE,CAAGf,EAAAA,WAAW,CAAkB,gBAAA,CAAA;EACjDgB,iBAAiB,EAAE,GAAGhB,WAAW,CAAA,kBAAA,CAAA;AACjC;EACD;AAEM,MAAMiB,cAAc,GAAG;AAC5BC,EAAAA,QAAQ,EAAE,aAAa;AACvBC,EAAAA,kBAAkB,EAAE,yBAAyB;AAC7CC,EAAAA,iBAAiB,EAAE,wBAAA;EACX;AAEH,MAAMC,wBAAwB,GAAG,WAAU;AAE3C,MAAMC,YAAY,GAAG,mBAAkB;AAEvC,MAAMC,yBAAyB,GAAG;;;;"}
@@ -0,0 +1,22 @@
1
+ import type { Agent } from 'package-manager-detector';
2
+ export declare const OLD_PACKAGE_NAME = "@frsource/cypress-plugin-visual-regression-diff";
3
+ export declare const NEW_PACKAGE_NAME = "@pixsame/cypress-plugin-visual-regression-diff";
4
+ export declare const NEW_PACKAGE_RANGE = "^1.0.0";
5
+ export type PackageManager = Agent;
6
+ export interface FileEdit {
7
+ file: string;
8
+ replacements: number;
9
+ content: string;
10
+ }
11
+ export interface Io {
12
+ stdout: (line: string) => void;
13
+ stderr: (line: string) => void;
14
+ isInteractive: boolean;
15
+ confirm: (question: string) => Promise<boolean>;
16
+ install: (pm: PackageManager, cwd: string) => number;
17
+ }
18
+ export declare function detectPackageManager(cwd: string): Promise<PackageManager>;
19
+ /** Reads the tree below `cwd` and returns the edits, writes nothing. */
20
+ export declare function planMigration(cwd: string): FileEdit[];
21
+ export declare function applyMigration(edits: FileEdit[]): void;
22
+ export declare function main(argv: string[], io?: Io): Promise<1 | 0>;
@@ -0,0 +1,554 @@
1
+ var fs$1 = require('fs');
2
+ var path$1 = require('path');
3
+ var child_process = require('child_process');
4
+ var readline = require('readline');
5
+ var fs = require('node:fs/promises');
6
+ var path = require('node:path');
7
+ var process$1 = require('node:process');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var fs__default$1 = /*#__PURE__*/_interopDefaultLegacy(fs$1);
12
+ var path__default$1 = /*#__PURE__*/_interopDefaultLegacy(path$1);
13
+ var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
14
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
15
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
16
+ var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1);
17
+
18
+ function splitRunArgs(args, valueFlags = []) {
19
+ for (let i = 0; i < args.length; i++) {
20
+ if (args[i].startsWith("-"))
21
+ continue;
22
+ if (i > 0 && valueFlags.includes(args[i - 1]))
23
+ continue;
24
+ return { before: args.slice(0, i), script: args[i], after: args.slice(i + 1) };
25
+ }
26
+ return { before: args, script: void 0, after: [] };
27
+ }
28
+ function dashDashArg(agent, agentCommand, valueFlags = []) {
29
+ return (args) => {
30
+ const { before, script, after } = splitRunArgs(args, valueFlags);
31
+ if (script === void 0)
32
+ return [agent, agentCommand, ...before];
33
+ if (after.length > 0)
34
+ return [agent, agentCommand, ...before, script, "--", ...after];
35
+ return [agent, agentCommand, ...before, script];
36
+ };
37
+ }
38
+ const npm = {
39
+ "agent": ["npm", 0],
40
+ "run": dashDashArg("npm", "run", ["-w", "--workspace"]),
41
+ "install": ["npm", "i", 0],
42
+ "frozen": ["npm", "ci", 0],
43
+ "global": ["npm", "i", "-g", 0],
44
+ "add": ["npm", "i", 0],
45
+ "upgrade": ["npm", "update", 0],
46
+ "upgrade-interactive": null,
47
+ "dedupe": ["npm", "dedupe", 0],
48
+ "execute": ["npx", 0],
49
+ "execute-local": ["npx", 0],
50
+ "uninstall": ["npm", "uninstall", 0],
51
+ "global_uninstall": ["npm", "uninstall", "-g", 0]
52
+ };
53
+ const yarn = {
54
+ "agent": ["yarn", 0],
55
+ "run": ["yarn", "run", 0],
56
+ "install": ["yarn", "install", 0],
57
+ "frozen": ["yarn", "install", "--frozen-lockfile", 0],
58
+ "global": ["yarn", "global", "add", 0],
59
+ "add": ["yarn", "add", 0],
60
+ "upgrade": ["yarn", "upgrade", 0],
61
+ "upgrade-interactive": ["yarn", "upgrade-interactive", 0],
62
+ "dedupe": null,
63
+ "execute": ["npx", 0],
64
+ "execute-local": dashDashArg("yarn", "exec"),
65
+ "uninstall": ["yarn", "remove", 0],
66
+ "global_uninstall": ["yarn", "global", "remove", 0]
67
+ };
68
+ const yarnBerry = {
69
+ ...yarn,
70
+ "frozen": ["yarn", "install", "--immutable", 0],
71
+ "upgrade": ["yarn", "up", 0],
72
+ "upgrade-interactive": ["yarn", "up", "-i", 0],
73
+ "dedupe": ["yarn", "dedupe", 0],
74
+ "execute": ["yarn", "dlx", 0],
75
+ "execute-local": ["yarn", "exec", 0],
76
+ // Yarn 2+ removed 'global', see https://github.com/yarnpkg/berry/issues/821
77
+ "global": ["npm", "i", "-g", 0],
78
+ "global_uninstall": ["npm", "uninstall", "-g", 0]
79
+ };
80
+ function createPnpmCommands(cli) {
81
+ return {
82
+ "agent": [cli, 0],
83
+ "run": [cli, "run", 0],
84
+ "install": [cli, "i", 0],
85
+ "frozen": [cli, "i", "--frozen-lockfile", 0],
86
+ "global": [cli, "add", "-g", 0],
87
+ "add": [cli, "add", 0],
88
+ "upgrade": [cli, "update", 0],
89
+ "upgrade-interactive": [cli, "update", "-i", 0],
90
+ "dedupe": [cli, "dedupe", 0],
91
+ "execute": [cli, "dlx", 0],
92
+ "execute-local": [cli, "exec", 0],
93
+ "uninstall": [cli, "remove", 0],
94
+ "global_uninstall": [cli, "remove", "--global", 0]
95
+ };
96
+ }
97
+ const pnpm = createPnpmCommands("pnpm");
98
+ const pnpmRush = createPnpmCommands("rush-pnpm");
99
+ const bun = {
100
+ "agent": ["bun", 0],
101
+ "run": ["bun", "run", 0],
102
+ "install": ["bun", "install", 0],
103
+ "frozen": ["bun", "install", "--frozen-lockfile", 0],
104
+ "global": ["bun", "add", "-g", 0],
105
+ "add": ["bun", "add", 0],
106
+ "upgrade": ["bun", "update", 0],
107
+ "upgrade-interactive": ["bun", "update", "-i", 0],
108
+ "dedupe": null,
109
+ "execute": ["bun", "x", 0],
110
+ "execute-local": ["bun", "x", 0],
111
+ "uninstall": ["bun", "remove", 0],
112
+ "global_uninstall": ["bun", "remove", "-g", 0]
113
+ };
114
+ const aube = {
115
+ "agent": ["aube", 0],
116
+ "run": ["aube", "run", 0],
117
+ "install": ["aube", "install", 0],
118
+ "frozen": ["aube", "install", "--frozen-lockfile", 0],
119
+ "global": ["aube", "add", "-g", 0],
120
+ "add": ["aube", "add", 0],
121
+ "upgrade": ["aube", "update", 0],
122
+ "upgrade-interactive": ["aube", "update", "-i", 0],
123
+ "dedupe": ["aube", "dedupe", 0],
124
+ "execute": ["aube", "dlx", 0],
125
+ "execute-local": ["aube", "exec", 0],
126
+ "uninstall": ["aube", "remove", 0],
127
+ "global_uninstall": ["aube", "remove", "-g", 0]
128
+ };
129
+ const deno = {
130
+ "agent": ["deno", 0],
131
+ "run": ["deno", "task", 0],
132
+ "install": ["deno", "install", 0],
133
+ "frozen": ["deno", "install", "--frozen", 0],
134
+ "global": ["deno", "install", "-g", 0],
135
+ "add": ["deno", "add", 0],
136
+ "upgrade": ["deno", "outdated", "--update", 0],
137
+ "upgrade-interactive": ["deno", "outdated", "--update", 0],
138
+ "dedupe": null,
139
+ "execute": ["deno", "x", 0],
140
+ "execute-local": ["deno", "task", "--eval", 0],
141
+ "uninstall": ["deno", "remove", 0],
142
+ "global_uninstall": ["deno", "uninstall", "-g", 0]
143
+ };
144
+ const nub = {
145
+ "agent": ["nub", 0],
146
+ "run": ["nub", "run", 0],
147
+ "install": ["nub", "install", 0],
148
+ "frozen": ["nub", "install", "--frozen-lockfile", 0],
149
+ "global": ["nub", "add", "-g", 0],
150
+ "add": ["nub", "add", 0],
151
+ "upgrade": ["nub", "update", 0],
152
+ "upgrade-interactive": ["nub", "update", "-i", 0],
153
+ "dedupe": ["nub", "dedupe", 0],
154
+ "execute": ["nubx", 0],
155
+ "execute-local": ["nub", "exec", 0],
156
+ "uninstall": ["nub", "remove", 0],
157
+ "global_uninstall": ["nub", "remove", "-g", 0]
158
+ };
159
+ const COMMANDS = {
160
+ "npm": npm,
161
+ "yarn": yarn,
162
+ "yarn@berry": yarnBerry,
163
+ "pnpm": pnpm,
164
+ // pnpm v6.x or below
165
+ "pnpm@6": {
166
+ ...pnpm,
167
+ run: dashDashArg("pnpm", "run", ["-F", "--filter"])
168
+ },
169
+ "pnpm-rush": pnpmRush,
170
+ "bun": bun,
171
+ "aube": aube,
172
+ "deno": deno,
173
+ "nub": nub
174
+ };
175
+ function resolveCommand(agent, command, args) {
176
+ const value = COMMANDS[agent][command];
177
+ return constructCommand(value, args);
178
+ }
179
+ function constructCommand(value, args) {
180
+ if (value == null)
181
+ return null;
182
+ const list = typeof value === "function" ? value(args) : value.flatMap((v) => {
183
+ if (typeof v === "number")
184
+ return args;
185
+ return [v];
186
+ });
187
+ return {
188
+ command: list[0],
189
+ args: list.slice(1)
190
+ };
191
+ }
192
+
193
+ const AGENTS = [
194
+ "npm",
195
+ "yarn",
196
+ "yarn@berry",
197
+ "pnpm",
198
+ "pnpm@6",
199
+ "pnpm-rush",
200
+ "bun",
201
+ "deno",
202
+ "nub",
203
+ "aube"
204
+ ];
205
+ const LOCKS = {
206
+ "aube-lock.yaml": "aube",
207
+ "aube-workspace.yaml": "aube",
208
+ "bun.lock": "bun",
209
+ "bun.lockb": "bun",
210
+ "deno.lock": "deno",
211
+ "nub.lock": "nub",
212
+ "pnpm-lock.yaml": "pnpm",
213
+ "pnpm-workspace.yaml": "pnpm",
214
+ "yarn.lock": "yarn",
215
+ "package-lock.json": "npm",
216
+ "npm-shrinkwrap.json": "npm"
217
+ };
218
+ const INSTALL_METADATA = {
219
+ "node_modules/.aube/": "aube",
220
+ "node_modules/.deno/": "deno",
221
+ "node_modules/.pnpm/": "pnpm",
222
+ "node_modules/.yarn-state.yml": "yarn",
223
+ // yarn v2+ (node-modules)
224
+ "node_modules/.yarn_integrity": "yarn",
225
+ // yarn v1
226
+ "node_modules/.package-lock.json": "npm",
227
+ ".pnp.cjs": "yarn",
228
+ // yarn v3+ (pnp)
229
+ ".pnp.js": "yarn",
230
+ // yarn v2 (pnp)
231
+ "bun.lock": "bun",
232
+ "bun.lockb": "bun"
233
+ };
234
+
235
+ async function pathExists(path2, type) {
236
+ try {
237
+ const stat = await fs__default["default"].stat(path2);
238
+ return type === "file" ? stat.isFile() : stat.isDirectory();
239
+ } catch {
240
+ return false;
241
+ }
242
+ }
243
+ function* lookup(cwd = process__default["default"].cwd()) {
244
+ let directory = path__default["default"].resolve(cwd);
245
+ const { root } = path__default["default"].parse(directory);
246
+ while (directory && directory !== root) {
247
+ yield directory;
248
+ directory = path__default["default"].dirname(directory);
249
+ }
250
+ }
251
+ async function parsePackageJson(filepath, options) {
252
+ if (!filepath || !await pathExists(filepath, "file"))
253
+ return null;
254
+ return await handlePackageManager(filepath, options);
255
+ }
256
+ async function detect(options = {}) {
257
+ const {
258
+ cwd,
259
+ strategies = ["lockfile", "packageManager-field", "devEngines-field"]
260
+ } = options;
261
+ let stopDir;
262
+ if (typeof options.stopDir === "string") {
263
+ const resolved = path__default["default"].resolve(options.stopDir);
264
+ stopDir = (dir) => dir === resolved;
265
+ } else {
266
+ stopDir = options.stopDir;
267
+ }
268
+ for (const directory of lookup(cwd)) {
269
+ for (const strategy of strategies) {
270
+ switch (strategy) {
271
+ case "lockfile": {
272
+ if (await pathExists(path__default["default"].join(directory, "rush.json"), "file")) {
273
+ return { name: "pnpm", agent: "pnpm-rush" };
274
+ }
275
+ for (const lock of Object.keys(LOCKS)) {
276
+ if (await pathExists(path__default["default"].join(directory, lock), "file")) {
277
+ const name = LOCKS[lock];
278
+ const result = await parsePackageJson(path__default["default"].join(directory, "package.json"), options);
279
+ if (result)
280
+ return result;
281
+ else
282
+ return { name, agent: name };
283
+ }
284
+ }
285
+ break;
286
+ }
287
+ case "packageManager-field":
288
+ case "devEngines-field": {
289
+ const result = await parsePackageJson(path__default["default"].join(directory, "package.json"), options);
290
+ if (result)
291
+ return result;
292
+ break;
293
+ }
294
+ case "install-metadata": {
295
+ for (const metadata of Object.keys(INSTALL_METADATA)) {
296
+ const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
297
+ if (await pathExists(path__default["default"].join(directory, metadata), fileOrDir)) {
298
+ const name = INSTALL_METADATA[metadata];
299
+ const agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
300
+ return { name, agent };
301
+ }
302
+ }
303
+ break;
304
+ }
305
+ }
306
+ }
307
+ if (stopDir?.(directory))
308
+ break;
309
+ }
310
+ return null;
311
+ }
312
+ function getNameAndVer(pkg) {
313
+ const handelVer = (version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version;
314
+ if (typeof pkg.packageManager === "string") {
315
+ const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
316
+ return { name, ver: handelVer(ver) };
317
+ }
318
+ if (typeof pkg.devEngines?.packageManager?.name === "string") {
319
+ return {
320
+ name: pkg.devEngines.packageManager.name,
321
+ ver: handelVer(pkg.devEngines.packageManager.version)
322
+ };
323
+ }
324
+ return void 0;
325
+ }
326
+ async function handlePackageManager(filepath, options) {
327
+ try {
328
+ const content = await fs__default["default"].readFile(filepath, "utf8");
329
+ const pkg = options.packageJsonParser ? await options.packageJsonParser(content, filepath) : JSON.parse(content);
330
+ let agent;
331
+ const nameAndVer = getNameAndVer(pkg);
332
+ if (nameAndVer) {
333
+ const name = nameAndVer.name;
334
+ const ver = nameAndVer.ver;
335
+ let version = ver;
336
+ if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
337
+ agent = "yarn@berry";
338
+ version = "berry";
339
+ return { name, agent, version };
340
+ } else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
341
+ agent = "pnpm@6";
342
+ return { name, agent, version };
343
+ } else if (AGENTS.includes(name)) {
344
+ agent = name;
345
+ return { name, agent, version };
346
+ } else {
347
+ return options.onUnknown?.(pkg.packageManager) ?? null;
348
+ }
349
+ }
350
+ } catch {
351
+ }
352
+ return null;
353
+ }
354
+ function isMetadataYarnClassic(metadataPath) {
355
+ return metadataPath.endsWith(".yarn_integrity");
356
+ }
357
+
358
+ const OLD_PACKAGE_NAME = '@frsource/cypress-plugin-visual-regression-diff';
359
+ const NEW_PACKAGE_NAME = '@pixsame/cypress-plugin-visual-regression-diff';
360
+ const NEW_PACKAGE_RANGE = '^1.0.0';
361
+ const DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
362
+ const SOURCE_EXTENSIONS = /\.(?:[cm]?[jt]sx?|json|jsonc)$/;
363
+ const SKIPPED_DIRECTORIES = new Set(['node_modules', '.git', '.yarn', 'dist', 'build', 'coverage', 'screenshots', 'videos']);
364
+ // Not followed by a word character or `-`, so `…-diff-foo` is left alone.
365
+ const oldNameRegex = () => new RegExp(`${OLD_PACKAGE_NAME.replace(/[/-]/g, '\\$&')}(?![\\w-])`, 'g');
366
+ async function detectPackageManager(cwd) {
367
+ var _await$detect$agent, _await$detect;
368
+ return (_await$detect$agent = (_await$detect = await detect({
369
+ cwd
370
+ })) == null ? void 0 : _await$detect.agent) != null ? _await$detect$agent : 'npm';
371
+ }
372
+ function* walk(dir) {
373
+ for (const entry of fs__default$1["default"].readdirSync(dir, {
374
+ withFileTypes: true
375
+ })) {
376
+ if (entry.isDirectory()) {
377
+ if (!SKIPPED_DIRECTORIES.has(entry.name)) {
378
+ yield* walk(path__default$1["default"].join(dir, entry.name));
379
+ }
380
+ } else if (entry.isFile() && SOURCE_EXTENSIONS.test(entry.name)) {
381
+ yield path__default$1["default"].join(dir, entry.name);
382
+ }
383
+ }
384
+ }
385
+ function indentOf(json) {
386
+ var _exec$, _exec;
387
+ return (_exec$ = (_exec = /^([ \t]+)"/m.exec(json)) == null ? void 0 : _exec[1]) != null ? _exec$ : 2;
388
+ }
389
+ function sortKeys(record) {
390
+ return Object.fromEntries(Object.entries(record).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
391
+ }
392
+ function migratePackageJson(source) {
393
+ let pkg;
394
+ try {
395
+ pkg = JSON.parse(source);
396
+ } catch {
397
+ return null;
398
+ }
399
+ let changed = false;
400
+ for (const field of DEPENDENCY_FIELDS) {
401
+ const deps = pkg[field];
402
+ if (!deps || !(OLD_PACKAGE_NAME in deps)) continue;
403
+ // Keep an existing new-name entry; the old one only duplicates it.
404
+ const others = Object.entries(deps).filter(([n]) => n !== OLD_PACKAGE_NAME);
405
+ pkg[field] = sortKeys({
406
+ [NEW_PACKAGE_NAME]: NEW_PACKAGE_RANGE,
407
+ ...Object.fromEntries(others)
408
+ });
409
+ changed = true;
410
+ }
411
+ if (!changed) return null;
412
+ const eol = source.endsWith('\n') ? '\n' : '';
413
+ return JSON.stringify(pkg, null, indentOf(source)) + eol;
414
+ }
415
+ /** Reads the tree below `cwd` and returns the edits, writes nothing. */
416
+ function planMigration(cwd) {
417
+ const edits = [];
418
+ for (const file of walk(cwd)) {
419
+ var _source$match;
420
+ const source = fs__default$1["default"].readFileSync(file, 'utf8');
421
+ if (!source.includes(OLD_PACKAGE_NAME)) continue;
422
+ const replacements = ((_source$match = source.match(oldNameRegex())) != null ? _source$match : []).length;
423
+ if (!replacements) continue;
424
+ const content = path__default$1["default"].basename(file) === 'package.json' ? migratePackageJson(source) : source.replace(oldNameRegex(), NEW_PACKAGE_NAME);
425
+ if (content === null || content === source) continue;
426
+ edits.push({
427
+ file,
428
+ replacements,
429
+ content
430
+ });
431
+ }
432
+ return edits;
433
+ }
434
+ function applyMigration(edits) {
435
+ for (const {
436
+ file,
437
+ content
438
+ } of edits) fs__default$1["default"].writeFileSync(file, content);
439
+ }
440
+ const HELP = `Usage: cypress-plugin-visual-regression-diff migrate [options]
441
+
442
+ Migration tool from ${OLD_PACKAGE_NAME}
443
+ to ${NEW_PACKAGE_NAME}: renames the dependency in package.json,
444
+ updates imports and type references, then reinstalls.
445
+
446
+ Options:
447
+ --dry-run Only list the files that would change
448
+ --yes, -y Do not ask for confirmation (required without a terminal)
449
+ --no-install Do not run the package manager afterwards
450
+ --cwd <dir> Project directory (default: current directory)
451
+ --help, -h Show this help
452
+ `;
453
+ async function main(argv, io = defaultIo()) {
454
+ var _rest;
455
+ const [command, ...rest] = argv;
456
+ const wantsHelp = !command || ['--help', '-h'].includes(command) || rest.includes('--help') || rest.includes('-h');
457
+ if (command !== 'migrate' && !wantsHelp) {
458
+ io.stderr(`Unknown command: ${command}\n\n${HELP}`);
459
+ return 1;
460
+ }
461
+ if (wantsHelp) {
462
+ io.stdout(HELP);
463
+ return 0;
464
+ }
465
+ const dryRun = rest.includes('--dry-run');
466
+ const yes = rest.includes('--yes') || rest.includes('-y');
467
+ const install = !rest.includes('--no-install');
468
+ const cwdFlag = rest.indexOf('--cwd');
469
+ const cwd = path__default$1["default"].resolve(cwdFlag === -1 ? '.' : (_rest = rest[cwdFlag + 1]) != null ? _rest : '');
470
+ if (!fs__default$1["default"].existsSync(cwd) || !fs__default$1["default"].statSync(cwd).isDirectory()) {
471
+ io.stderr(`Not a directory: ${cwd}`);
472
+ return 1;
473
+ }
474
+ const edits = planMigration(cwd);
475
+ if (!edits.length) {
476
+ io.stdout(`Nothing to migrate: no reference to ${OLD_PACKAGE_NAME} found.`);
477
+ return 0;
478
+ }
479
+ io.stdout([`Migration tool: ${OLD_PACKAGE_NAME} → ${NEW_PACKAGE_NAME}`, '', `Found usages of ${OLD_PACKAGE_NAME} in these files, they will be updated by the migration (number of occurrences in parentheses):`, ''].join('\n'));
480
+ for (const {
481
+ file,
482
+ replacements
483
+ } of edits) {
484
+ io.stdout(` • ${path__default$1["default"].relative(cwd, file)} (${replacements})`);
485
+ }
486
+ if (dryRun) {
487
+ io.stdout('\nDry run, nothing was written.');
488
+ return 0;
489
+ }
490
+ if (!yes) {
491
+ if (!io.isInteractive) {
492
+ io.stderr('\nNo terminal to ask for confirmation, nothing was written. Re-run with --yes to apply.');
493
+ return 1;
494
+ }
495
+ if (!(await io.confirm('\nApply these changes? (y/N) '))) {
496
+ io.stdout('Aborted, nothing was written.');
497
+ return 1;
498
+ }
499
+ }
500
+ applyMigration(edits);
501
+ io.stdout(`\n✔ Updated ${edits.length} file${edits.length === 1 ? '' : 's'}. Review the changes with \`git diff\`.`);
502
+ if (!install) return 0;
503
+ const pm = await detectPackageManager(cwd);
504
+ io.stdout(`\nRunning \`${pm} install\` to refresh the lockfile…\n`);
505
+ const status = io.install(pm, cwd);
506
+ if (status !== 0) {
507
+ io.stderr(`\`${pm} install\` failed (exit ${status}). Run it yourself.`);
508
+ return 1;
509
+ }
510
+ return 0;
511
+ }
512
+ /* c8 ignore start */
513
+ /* eslint-disable no-console */
514
+ function defaultIo() {
515
+ return {
516
+ stdout: line => console.log(line),
517
+ stderr: line => console.error(line),
518
+ isInteractive: !!process.stdin.isTTY && !process.env.CI,
519
+ confirm: question => new Promise(resolve => {
520
+ const rl = readline__default["default"].createInterface({
521
+ input: process.stdin,
522
+ output: process.stdout
523
+ });
524
+ rl.question(question, answer => {
525
+ rl.close();
526
+ resolve(/^y(es)?$/i.test(answer.trim()));
527
+ });
528
+ }),
529
+ install: (pm, cwd) => {
530
+ var _spawnSync$status;
531
+ const resolved = resolveCommand(pm, 'install', []);
532
+ if (!resolved) return 1;
533
+ const {
534
+ command,
535
+ args
536
+ } = resolved;
537
+ return (_spawnSync$status = child_process.spawnSync(command, args, {
538
+ cwd,
539
+ stdio: 'inherit',
540
+ shell: process.platform === 'win32'
541
+ }).status) != null ? _spawnSync$status : 1;
542
+ }
543
+ };
544
+ }
545
+ /* c8 ignore stop */
546
+
547
+ exports.NEW_PACKAGE_NAME = NEW_PACKAGE_NAME;
548
+ exports.NEW_PACKAGE_RANGE = NEW_PACKAGE_RANGE;
549
+ exports.OLD_PACKAGE_NAME = OLD_PACKAGE_NAME;
550
+ exports.applyMigration = applyMigration;
551
+ exports.detectPackageManager = detectPackageManager;
552
+ exports.main = main;
553
+ exports.planMigration = planMigration;
554
+ //# sourceMappingURL=migrate.js.map