@shopify/cli-kit 3.56.3 → 3.57.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.
- package/dist/private/node/content-tokens.js +1 -1
- package/dist/private/node/content-tokens.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +1 -3
- package/dist/private/node/ui/components/AutocompletePrompt.js +2 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +0 -29
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.d.ts +1 -3
- package/dist/private/node/ui/components/Prompts/PromptLayout.js +3 -5
- package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js +2 -14
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.d.ts +1 -3
- package/dist/private/node/ui/components/SelectPrompt.js +2 -2
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +0 -27
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/partners.d.ts +1 -0
- package/dist/public/node/api/partners.js +1 -2
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/ink.d.ts +1 -0
- package/dist/public/node/ink.js +2 -0
- package/dist/public/node/ink.js.map +1 -0
- package/dist/public/node/ui.d.ts +2 -2
- package/dist/public/node/ui.js +1 -2
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -4
- package/dist/private/node/ui/components/Prompts/GitDiff.d.ts +0 -17
- package/dist/private/node/ui/components/Prompts/GitDiff.js +0 -48
- package/dist/private/node/ui/components/Prompts/GitDiff.js.map +0 -1
- package/dist/private/node/ui/components/Prompts/GitDiff.test.d.ts +0 -1
- package/dist/private/node/ui/components/Prompts/GitDiff.test.js +0 -126
- package/dist/private/node/ui/components/Prompts/GitDiff.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/cli-kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.57.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A set of utilities, interfaces, and models that are common across all the platform features",
|
|
6
6
|
"keywords": [
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@bugsnag/js": "7.21.0",
|
|
85
85
|
"@iarna/toml": "2.2.5",
|
|
86
|
-
"@oclif/core": "3.
|
|
86
|
+
"@oclif/core": "3.19.6",
|
|
87
87
|
"@opentelemetry/api": "1.6.0",
|
|
88
88
|
"@opentelemetry/core": "1.17.1",
|
|
89
89
|
"@opentelemetry/exporter-metrics-otlp-http": "0.43.0",
|
|
@@ -115,7 +115,6 @@
|
|
|
115
115
|
"fs-extra": "11.1.0",
|
|
116
116
|
"fuzzy": "0.1.3",
|
|
117
117
|
"get-port-please": "3.0.1",
|
|
118
|
-
"git-diff": "2.0.6",
|
|
119
118
|
"gradient-string": "2.0.2",
|
|
120
119
|
"graphql": "16.8.1",
|
|
121
120
|
"graphql-request": "5.2.0",
|
|
@@ -151,7 +150,6 @@
|
|
|
151
150
|
"@types/cross-zip": "^4.0.0",
|
|
152
151
|
"@types/diff": "^5.0.3",
|
|
153
152
|
"@types/fs-extra": "9.0.13",
|
|
154
|
-
"@types/git-diff": "^2.0.3",
|
|
155
153
|
"@types/gradient-string": "^1.1.2",
|
|
156
154
|
"@types/lodash": "4.14.195",
|
|
157
155
|
"@types/node": "18.19.3",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
export interface GitDiffProps {
|
|
3
|
-
gitDiff: {
|
|
4
|
-
baselineContent: string;
|
|
5
|
-
updatedContent: string;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* `GitDiff` displays a git diff between two strings.
|
|
10
|
-
* @example
|
|
11
|
-
* \@\@ -1,2 +1,2 \@\@
|
|
12
|
-
* - deleted line
|
|
13
|
-
* unchanged line
|
|
14
|
-
* + added line
|
|
15
|
-
*/
|
|
16
|
-
declare const GitDiff: FunctionComponent<GitDiffProps>;
|
|
17
|
-
export { GitDiff };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { unstyled, shouldDisplayColors } from '../../../../../public/node/output.js';
|
|
2
|
-
import { Text } from 'ink';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { createRequire } from 'module';
|
|
5
|
-
const require = createRequire(import.meta.url);
|
|
6
|
-
const gitDiff = require('git-diff');
|
|
7
|
-
/**
|
|
8
|
-
* `GitDiff` displays a git diff between two strings.
|
|
9
|
-
* @example
|
|
10
|
-
* \@\@ -1,2 +1,2 \@\@
|
|
11
|
-
* - deleted line
|
|
12
|
-
* unchanged line
|
|
13
|
-
* + added line
|
|
14
|
-
*/
|
|
15
|
-
const GitDiff = ({ gitDiff: { baselineContent, updatedContent } }) => {
|
|
16
|
-
const rawDiffContents = gitDiff(baselineContent, updatedContent, {
|
|
17
|
-
color: shouldDisplayColors(),
|
|
18
|
-
// Show minimal context to accommodate small terminals.
|
|
19
|
-
flags: '--unified=1 --inter-hunk-context=1',
|
|
20
|
-
noHeaders: true,
|
|
21
|
-
});
|
|
22
|
-
if (!rawDiffContents) {
|
|
23
|
-
return React.createElement(Text, null, "No changes.");
|
|
24
|
-
}
|
|
25
|
-
const diffContents = rawDiffContents
|
|
26
|
-
.split('\n')
|
|
27
|
-
.map((line, index) => {
|
|
28
|
-
const unstyledLine = unstyled(line);
|
|
29
|
-
if (unstyledLine === '\') {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
else if (unstyledLine.match(/^@@/)) {
|
|
33
|
-
const addNewline = index !== 0;
|
|
34
|
-
return line.replace('@@', `${addNewline ? '\n' : ''} @@`);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return line.replace(/([+\- ])/, (match) => {
|
|
38
|
-
return `${match} `;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
.filter((line) => line !== undefined)
|
|
43
|
-
.join('\n')
|
|
44
|
-
.trimEnd();
|
|
45
|
-
return React.createElement(Text, null, diffContents);
|
|
46
|
-
};
|
|
47
|
-
export { GitDiff };
|
|
48
|
-
//# sourceMappingURL=GitDiff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitDiff.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/GitDiff.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,mBAAmB,EAAC,MAAM,sCAAsC,CAAA;AAClF,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAA0B,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AASnC;;;;;;;GAOG;AACH,MAAM,OAAO,GAAoC,CAAC,EAAC,OAAO,EAAE,EAAC,eAAe,EAAE,cAAc,EAAC,EAAC,EAAe,EAAE;IAC7G,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,EAAE,cAAc,EAAE;QAC/D,KAAK,EAAE,mBAAmB,EAAE;QAC5B,uDAAuD;QACvD,KAAK,EAAE,oCAAoC;QAC3C,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;IACF,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,oBAAC,IAAI,sBAAmB,CAAA;KAChC;IACD,MAAM,YAAY,GAAG,eAAe;SACjC,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAY,EAAE,KAAa,EAAsB,EAAE;QACvD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;QACnC,IAAI,YAAY,KAAK,8BAA8B,EAAE;YACnD,OAAO,SAAS,CAAA;SACjB;aAAM,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YACpC,MAAM,UAAU,GAAG,KAAK,KAAK,CAAC,CAAA;YAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;SAC3D;aAAM;YACL,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;gBACxC,OAAO,GAAG,KAAK,GAAG,CAAA;YACpB,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAwB,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;SACxD,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,EAAE,CAAA;IACZ,OAAO,oBAAC,IAAI,QAAE,YAAY,CAAQ,CAAA;AACpC,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {unstyled, shouldDisplayColors} from '../../../../../public/node/output.js'\nimport {Text} from 'ink'\nimport React, {FunctionComponent} from 'react'\nimport {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\nconst gitDiff = require('git-diff')\n\nexport interface GitDiffProps {\n gitDiff: {\n baselineContent: string\n updatedContent: string\n }\n}\n\n/**\n * `GitDiff` displays a git diff between two strings.\n * @example\n * \\@\\@ -1,2 +1,2 \\@\\@\n * - deleted line\n * unchanged line\n * + added line\n */\nconst GitDiff: FunctionComponent<GitDiffProps> = ({gitDiff: {baselineContent, updatedContent}}): JSX.Element => {\n const rawDiffContents = gitDiff(baselineContent, updatedContent, {\n color: shouldDisplayColors(),\n // Show minimal context to accommodate small terminals.\n flags: '--unified=1 --inter-hunk-context=1',\n noHeaders: true,\n })\n if (!rawDiffContents) {\n return <Text>No changes.</Text>\n }\n const diffContents = rawDiffContents\n .split('\\n')\n .map((line: string, index: number): string | undefined => {\n const unstyledLine = unstyled(line)\n if (unstyledLine === '\\\') {\n return undefined\n } else if (unstyledLine.match(/^@@/)) {\n const addNewline = index !== 0\n return line.replace('@@', `${addNewline ? '\\n' : ''} @@`)\n } else {\n return line.replace(/([+\\- ])/, (match) => {\n return `${match} `\n })\n }\n })\n .filter((line: string | undefined) => line !== undefined)\n .join('\\n')\n .trimEnd()\n return <Text>{diffContents}</Text>\n}\n\nexport {GitDiff}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { GitDiff } from './GitDiff.js';
|
|
2
|
-
import { render } from '../../../testing/ui.js';
|
|
3
|
-
import { unstyled } from '../../../../../public/node/output.js';
|
|
4
|
-
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { platformAndArch } from '@shopify/cli-kit/node/os';
|
|
7
|
-
afterEach(async () => {
|
|
8
|
-
await vi.unstubAllGlobals();
|
|
9
|
-
});
|
|
10
|
-
const runningOnWindows = platformAndArch().platform === 'windows';
|
|
11
|
-
describe('GitDiff', async () => {
|
|
12
|
-
test('renders correctly when no changes exist', async () => {
|
|
13
|
-
const gitDiff = {
|
|
14
|
-
baselineContent: 'hello',
|
|
15
|
-
updatedContent: 'hello',
|
|
16
|
-
};
|
|
17
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
18
|
-
expect(lastFrame()).toEqual('No changes.');
|
|
19
|
-
});
|
|
20
|
-
test('renders correctly when changes exist', async () => {
|
|
21
|
-
const gitDiff = {
|
|
22
|
-
baselineContent: 'hello\n',
|
|
23
|
-
updatedContent: 'world\n',
|
|
24
|
-
};
|
|
25
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
26
|
-
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
27
|
-
"- hello
|
|
28
|
-
+ world"
|
|
29
|
-
`);
|
|
30
|
-
});
|
|
31
|
-
test('renders correctly when changes exist and are several lines long', async () => {
|
|
32
|
-
const gitDiff = {
|
|
33
|
-
baselineContent: 'hello\nworld\nfoobar\n',
|
|
34
|
-
updatedContent: 'world\nfoobar\nhello\n',
|
|
35
|
-
};
|
|
36
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
37
|
-
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
38
|
-
"- hello
|
|
39
|
-
world
|
|
40
|
-
foobar
|
|
41
|
-
+ hello"
|
|
42
|
-
`);
|
|
43
|
-
});
|
|
44
|
-
test.skipIf(runningOnWindows)('displays color correctly', async () => {
|
|
45
|
-
const gitDiff = {
|
|
46
|
-
baselineContent: 'hello\nworld\n',
|
|
47
|
-
updatedContent: 'world\nhello\n',
|
|
48
|
-
};
|
|
49
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
50
|
-
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
51
|
-
"[31m- hello[m[39m
|
|
52
|
-
world[m
|
|
53
|
-
[32m+ [m[32mhello[m[0m[39m"
|
|
54
|
-
`);
|
|
55
|
-
});
|
|
56
|
-
test.skipIf(runningOnWindows)('respects no-color mode', async () => {
|
|
57
|
-
vi.stubGlobal('process', { ...process, env: { ...process.env, FORCE_COLOR: '0' } });
|
|
58
|
-
const gitDiff = {
|
|
59
|
-
baselineContent: 'hello\nworld\n',
|
|
60
|
-
updatedContent: 'world\nhello\n',
|
|
61
|
-
};
|
|
62
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
63
|
-
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
64
|
-
"- hello
|
|
65
|
-
world
|
|
66
|
-
+ hello"
|
|
67
|
-
`);
|
|
68
|
-
});
|
|
69
|
-
test.skipIf(runningOnWindows)('ignores newline changes', async () => {
|
|
70
|
-
const expectedDiff = `
|
|
71
|
-
"- hello
|
|
72
|
-
world
|
|
73
|
-
foobar
|
|
74
|
-
+ hello"
|
|
75
|
-
`;
|
|
76
|
-
const gitDiff = {
|
|
77
|
-
baselineContent: 'hello\nworld\nfoobar\n',
|
|
78
|
-
updatedContent: 'world\nfoobar\nhello',
|
|
79
|
-
};
|
|
80
|
-
// Removing a newline
|
|
81
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
82
|
-
expect(unstyled(lastFrame())).toMatchInlineSnapshot(expectedDiff);
|
|
83
|
-
expect(unstyled(lastFrame())).toMatchInlineSnapshot(expectedDiff);
|
|
84
|
-
});
|
|
85
|
-
test.skipIf(runningOnWindows)('renders correctly when changes exist in multiple areas of a file', async () => {
|
|
86
|
-
const baselineContent = `hello
|
|
87
|
-
world
|
|
88
|
-
foobar
|
|
89
|
-
lorem
|
|
90
|
-
ipsum
|
|
91
|
-
dolor
|
|
92
|
-
sit
|
|
93
|
-
amet
|
|
94
|
-
foo
|
|
95
|
-
bar
|
|
96
|
-
`;
|
|
97
|
-
const updatedContent = `world
|
|
98
|
-
foobar
|
|
99
|
-
hello
|
|
100
|
-
lorem
|
|
101
|
-
ipsum
|
|
102
|
-
dolor
|
|
103
|
-
sit
|
|
104
|
-
amet
|
|
105
|
-
foo
|
|
106
|
-
qux`;
|
|
107
|
-
const gitDiff = {
|
|
108
|
-
baselineContent,
|
|
109
|
-
updatedContent,
|
|
110
|
-
};
|
|
111
|
-
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
112
|
-
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
113
|
-
"- hello
|
|
114
|
-
world
|
|
115
|
-
foobar
|
|
116
|
-
+ hello
|
|
117
|
-
lorem
|
|
118
|
-
|
|
119
|
-
@@ -9,2 +9,2 @@ amet
|
|
120
|
-
foo
|
|
121
|
-
- bar
|
|
122
|
-
+ qux"
|
|
123
|
-
`);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
//# sourceMappingURL=GitDiff.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitDiff.test.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/GitDiff.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAA;AAC7D,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAC5D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAExD,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAA;AAC7B,CAAC,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAA;AAEjE,QAAQ,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IAC7B,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,OAAO,GAAG;YACd,eAAe,EAAE,OAAO;YACxB,cAAc,EAAE,OAAO;SACxB,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAA;QAEzD,MAAM,CAAC,SA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AAe;YACf,cAAc;SACf,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAA;QAEzD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;KAWpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {GitDiff} from './GitDiff.js'\nimport {render} from '../../../testing/ui.js'\nimport {unstyled} from '../../../../../public/node/output.js'\nimport {afterEach, describe, expect, test, vi} from 'vitest'\nimport React from 'react'\nimport {platformAndArch} from '@shopify/cli-kit/node/os'\n\nafterEach(async () => {\n await vi.unstubAllGlobals()\n})\n\nconst runningOnWindows = platformAndArch().platform === 'windows'\n\ndescribe('GitDiff', async () => {\n test('renders correctly when no changes exist', async () => {\n const gitDiff = {\n baselineContent: 'hello',\n updatedContent: 'hello',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()).toEqual('No changes.')\n })\n\n test('renders correctly when changes exist', async () => {\n const gitDiff = {\n baselineContent: 'hello\\n',\n updatedContent: 'world\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n + world\"\n `)\n })\n\n test('renders correctly when changes exist and are several lines long', async () => {\n const gitDiff = {\n baselineContent: 'hello\\nworld\\nfoobar\\n',\n updatedContent: 'world\\nfoobar\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n world\n foobar\n + hello\"\n `)\n })\n\n test.skipIf(runningOnWindows)('displays color correctly', async () => {\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m- hello\u001b[m\u001b[39m\n world\u001b[m\n \u001b[32m+ \u001b[m\u001b[32mhello\u001b[m\u001b[0m\u001b[39m\"\n `)\n })\n\n test.skipIf(runningOnWindows)('respects no-color mode', async () => {\n vi.stubGlobal('process', {...process, env: {...process.env, FORCE_COLOR: '0'}})\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()!).toMatchInlineSnapshot(`\n \"- hello\n world\n + hello\"\n `)\n })\n\n test.skipIf(runningOnWindows)('ignores newline changes', async () => {\n const expectedDiff = `\n \"- hello\n world\n foobar\n + hello\"\n `\n\n const gitDiff = {\n baselineContent: 'hello\\nworld\\nfoobar\\n',\n updatedContent: 'world\\nfoobar\\nhello',\n }\n\n // Removing a newline\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(expectedDiff)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(expectedDiff)\n })\n\n test.skipIf(runningOnWindows)('renders correctly when changes exist in multiple areas of a file', async () => {\n const baselineContent = `hello\nworld\nfoobar\nlorem\nipsum\ndolor\nsit\namet\nfoo\nbar\n`\n const updatedContent = `world\nfoobar\nhello\nlorem\nipsum\ndolor\nsit\namet\nfoo\nqux`\n\n const gitDiff = {\n baselineContent,\n updatedContent,\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n world\n foobar\n + hello\n lorem\n\n @@ -9,2 +9,2 @@ amet\n foo\n - bar\n + qux\"\n `)\n })\n})\n"]}
|