@shopify/cli-kit 3.31.1 → 3.32.1
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 +1 -1
- package/dist/api.d.ts +2 -5
- package/dist/api.js +2 -5
- package/dist/api.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/environment/local.d.ts +1 -0
- package/dist/environment/local.js +4 -1
- package/dist/environment/local.js.map +1 -1
- package/dist/file.d.ts +10 -3
- package/dist/file.js +34 -34
- package/dist/file.js.map +1 -1
- package/dist/http/fetch.js +1 -1
- package/dist/http/fetch.js.map +1 -1
- package/dist/http.d.ts +0 -1
- package/dist/http.js +0 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/monorail.d.ts +1 -1
- package/dist/monorail.js.map +1 -1
- package/dist/npm.js +1 -1
- package/dist/npm.js.map +1 -1
- package/dist/output.d.ts +2 -2
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +3 -1
- package/dist/path.js +2 -2
- package/dist/path.js.map +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{json.d.ts → private/common/json.d.ts} +0 -0
- package/dist/{json.js → private/common/json.js} +0 -0
- package/dist/private/common/json.js.map +1 -0
- package/dist/private/node/analytics.d.ts +27 -0
- package/dist/private/node/analytics.js +57 -0
- package/dist/private/node/analytics.js.map +1 -0
- package/dist/private/node/api/graphql.d.ts +5 -0
- package/dist/private/node/api/graphql.js +63 -0
- package/dist/private/node/api/graphql.js.map +1 -0
- package/dist/{api/common.d.ts → private/node/api/headers.d.ts} +3 -8
- package/dist/{api/common.js → private/node/api/headers.js} +20 -60
- package/dist/private/node/api/headers.js.map +1 -0
- package/dist/private/node/ui/components/Alert.test.js +5 -5
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/Banner.js +5 -5
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/private/node/ui/components/Banner.test.js +11 -11
- package/dist/private/node/ui/components/Banner.test.js.map +1 -1
- package/dist/private/node/ui/components/Command.test.js +3 -3
- package/dist/private/node/ui/components/Command.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +3 -3
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +9 -9
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/FilePath.test.js +3 -3
- package/dist/private/node/ui/components/FilePath.test.js.map +1 -1
- package/dist/private/node/ui/components/FullScreen.js +11 -9
- package/dist/private/node/ui/components/FullScreen.js.map +1 -1
- package/dist/private/node/ui/components/Link.test.js +5 -5
- package/dist/private/node/ui/components/Link.test.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js +5 -5
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.d.ts +2 -2
- package/dist/private/node/ui/components/SelectInput.js +16 -24
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +62 -32
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/{Prompt.d.ts → SelectPrompt.d.ts} +4 -3
- package/dist/private/node/ui/components/SelectPrompt.js +46 -0
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -0
- package/dist/private/node/ui/components/{Prompt.test.d.ts → SelectPrompt.test.d.ts} +0 -0
- package/dist/private/node/ui/components/{Prompt.test.js → SelectPrompt.test.js} +7 -6
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/Table.js +2 -2
- package/dist/private/node/ui/components/Table.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.d.ts +1 -1
- package/dist/private/node/ui/components/Tasks.js +3 -3
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +4 -4
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.d.ts +9 -0
- package/dist/private/node/ui/components/TextInput.js +74 -0
- package/dist/private/node/ui/components/TextInput.js.map +1 -0
- package/dist/private/node/ui/components/TextInput.test.d.ts +1 -0
- package/dist/private/node/ui/components/TextInput.test.js +139 -0
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -0
- package/dist/private/node/ui/components/TextPrompt.d.ts +8 -0
- package/dist/private/node/ui/components/TextPrompt.js +52 -0
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -0
- package/dist/private/node/ui/components/TextPrompt.test.d.ts +1 -0
- package/dist/private/node/ui/components/TextPrompt.test.js +68 -0
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/TokenizedText.test.js +3 -3
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui/components/UserInput.test.js +3 -3
- package/dist/private/node/ui/components/UserInput.test.js.map +1 -1
- package/dist/private/node/ui/hooks/use-layout.d.ts +6 -3
- package/dist/private/node/ui/hooks/use-layout.js +17 -8
- package/dist/private/node/ui/hooks/use-layout.js.map +1 -1
- package/dist/private/node/ui.d.ts +2 -3
- package/dist/private/node/ui.js +7 -16
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/array.js +1 -1
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/collection.js +1 -1
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/function.js +1 -1
- package/dist/public/common/function.js.map +1 -1
- package/dist/public/common/lang.js +1 -1
- package/dist/public/common/lang.js.map +1 -1
- package/dist/public/common/object.js +4 -4
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/string.d.ts +55 -1
- package/dist/public/common/string.js +93 -1
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/url.d.ts +7 -0
- package/dist/public/common/url.js +17 -0
- package/dist/public/common/url.js.map +1 -0
- package/dist/public/node/abort.d.ts +16 -0
- package/dist/public/node/abort.js +17 -0
- package/dist/public/node/abort.js.map +1 -0
- package/dist/public/node/analytics.d.ts +13 -0
- package/dist/public/node/analytics.js +82 -0
- package/dist/public/node/analytics.js.map +1 -0
- package/dist/public/node/api/admin.d.ts +11 -0
- package/dist/public/node/api/admin.js +70 -0
- package/dist/public/node/api/admin.js.map +1 -0
- package/dist/public/node/api/oxygen.d.ts +22 -0
- package/dist/public/node/api/oxygen.js +40 -0
- package/dist/public/node/api/oxygen.js.map +1 -0
- package/dist/{api → public/node/api}/partners.d.ts +11 -3
- package/dist/public/node/api/partners.js +40 -0
- package/dist/public/node/api/partners.js.map +1 -0
- package/dist/public/node/archiver.js +1 -1
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js +1 -1
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/crypto.d.ts +42 -0
- package/dist/public/node/crypto.js +55 -0
- package/dist/public/node/crypto.js.map +1 -0
- package/dist/public/node/error-handler.js +3 -2
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/framework.js +1 -1
- package/dist/public/node/framework.js.map +1 -1
- package/dist/public/node/hooks/postrun.js +2 -2
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.js +2 -2
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/{template.d.ts → public/node/liquid.d.ts} +10 -2
- package/dist/{template.js → public/node/liquid.js} +18 -13
- package/dist/public/node/liquid.js.map +1 -0
- package/dist/public/node/node-package-manager.d.ts +3 -3
- package/dist/public/node/node-package-manager.js +1 -1
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/os.d.ts +16 -0
- package/dist/{os.js → public/node/os.js} +33 -29
- package/dist/public/node/os.js.map +1 -0
- package/dist/public/node/presets.d.ts +1 -1
- package/dist/public/node/presets.js +2 -2
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +13 -9
- package/dist/public/node/ruby.js +91 -23
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/tcp.d.ts +2 -0
- package/dist/public/node/tcp.js +9 -0
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/toml.d.ts +15 -0
- package/dist/public/node/toml.js +20 -0
- package/dist/public/node/toml.js.map +1 -0
- package/dist/public/node/ui.d.ts +12 -17
- package/dist/public/node/ui.js +25 -29
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vscode.d.ts +14 -0
- package/dist/{vscode.js → public/node/vscode.js} +13 -7
- package/dist/public/node/vscode.js.map +1 -0
- package/dist/session/authorize.d.ts +4 -0
- package/dist/session/authorize.js +8 -3
- package/dist/session/authorize.js.map +1 -1
- package/dist/{api/identity.d.ts → session/identity-token-validation.d.ts} +0 -0
- package/dist/{api/identity.js → session/identity-token-validation.js} +1 -1
- package/dist/session/identity-token-validation.js.map +1 -0
- package/dist/session/redirect-listener.js +6 -3
- package/dist/session/redirect-listener.js.map +1 -1
- package/dist/session/schema.d.ts +18 -18
- package/dist/session/store.js +1 -1
- package/dist/session/store.js.map +1 -1
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/system.d.ts +2 -2
- package/dist/system.js +1 -1
- package/dist/system.js.map +1 -1
- package/dist/testing/ui.d.ts +1 -1
- package/dist/testing/ui.js +1 -1
- package/dist/testing/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.d.ts +2 -2
- package/dist/ui/inquirer/autocomplete.js +1 -1
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/dist/ui/inquirer/input.d.ts +2 -2
- package/dist/ui/inquirer/input.js.map +1 -1
- package/dist/ui/inquirer/password.d.ts +2 -2
- package/dist/ui/inquirer/password.js.map +1 -1
- package/dist/ui/inquirer/select.d.ts +2 -2
- package/dist/ui/inquirer/select.js +2 -2
- package/dist/ui/inquirer/select.js.map +1 -1
- package/package.json +30 -27
- package/dist/abort.d.ts +0 -1
- package/dist/abort.js +0 -2
- package/dist/abort.js.map +0 -1
- package/dist/analytics.d.ts +0 -44
- package/dist/analytics.js +0 -154
- package/dist/analytics.js.map +0 -1
- package/dist/api/admin.d.ts +0 -3
- package/dist/api/admin.js +0 -56
- package/dist/api/admin.js.map +0 -1
- package/dist/api/common.js.map +0 -1
- package/dist/api/identity.js.map +0 -1
- package/dist/api/oxygen.d.ts +0 -5
- package/dist/api/oxygen.js +0 -30
- package/dist/api/oxygen.js.map +0 -1
- package/dist/api/partners.js +0 -44
- package/dist/api/partners.js.map +0 -1
- package/dist/http/graphql.d.ts +0 -13
- package/dist/http/graphql.js +0 -12
- package/dist/http/graphql.js.map +0 -1
- package/dist/id.d.ts +0 -6
- package/dist/id.js +0 -18
- package/dist/id.js.map +0 -1
- package/dist/json.js.map +0 -1
- package/dist/os.d.ts +0 -10
- package/dist/os.js.map +0 -1
- package/dist/private/node/ui/components/Prompt.js +0 -23
- package/dist/private/node/ui/components/Prompt.js.map +0 -1
- package/dist/private/node/ui/components/Prompt.test.js.map +0 -1
- package/dist/string.d.ts +0 -28
- package/dist/string.js +0 -77
- package/dist/string.js.map +0 -1
- package/dist/template.js.map +0 -1
- package/dist/toml.d.ts +0 -3
- package/dist/toml.js +0 -8
- package/dist/toml.js.map +0 -1
- package/dist/vscode.d.ts +0 -8
- package/dist/vscode.js.map +0 -1
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ClientError } from 'graphql-request';
|
|
6
|
-
import { randomUUID } from 'crypto';
|
|
1
|
+
import constants from '../../../constants.js';
|
|
2
|
+
import { firstPartyDev } from '../../../environment/local.js';
|
|
3
|
+
import { ExtendableError } from '../../../error.js';
|
|
4
|
+
import { randomUUID } from '../../../public/node/crypto.js';
|
|
7
5
|
export class RequestClientError extends ExtendableError {
|
|
8
6
|
constructor(message, statusCode) {
|
|
9
7
|
super(message);
|
|
10
8
|
this.statusCode = statusCode;
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
|
-
export async function buildHeaders(token) {
|
|
14
|
-
const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`;
|
|
15
|
-
const headers = {
|
|
16
|
-
'User-Agent': userAgent,
|
|
17
|
-
// 'Sec-CH-UA': secCHUA, This header requires the Git sha.
|
|
18
|
-
'Sec-CH-UA-PLATFORM': process.platform,
|
|
19
|
-
'X-Request-Id': randomUUID(),
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
...(firstPartyDev() && { 'X-Shopify-Cli-Employee': '1' }),
|
|
22
|
-
};
|
|
23
|
-
if (token) {
|
|
24
|
-
// eslint-disable-next-line dot-notation
|
|
25
|
-
headers['authorization'] = `Bearer ${token}`;
|
|
26
|
-
headers['X-Shopify-Access-Token'] = `Bearer ${token}`;
|
|
27
|
-
}
|
|
28
|
-
return headers;
|
|
29
|
-
}
|
|
30
11
|
/**
|
|
31
12
|
* Removes the sensitive data from the headers and outputs them as a string.
|
|
32
13
|
* @param headers - HTTP headers.
|
|
@@ -46,42 +27,21 @@ export function sanitizedHeadersOutput(headers) {
|
|
|
46
27
|
})
|
|
47
28
|
.join('\n');
|
|
48
29
|
}
|
|
49
|
-
export function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return await action();
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
if (error instanceof ClientError) {
|
|
67
|
-
const errorMessage = stringifyMessage(content `
|
|
68
|
-
The ${token.raw(api)} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
69
|
-
|
|
70
|
-
${outputToken.json(error.response.errors)}
|
|
71
|
-
`);
|
|
72
|
-
let mappedError;
|
|
73
|
-
if (error.response.status < 500) {
|
|
74
|
-
mappedError = new RequestClientError(errorMessage, error.response.status);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
mappedError = new Abort(errorMessage);
|
|
78
|
-
}
|
|
79
|
-
mappedError.stack = error.stack;
|
|
80
|
-
throw mappedError;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
30
|
+
export async function buildHeaders(token) {
|
|
31
|
+
const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`;
|
|
32
|
+
const headers = {
|
|
33
|
+
'User-Agent': userAgent,
|
|
34
|
+
// 'Sec-CH-UA': secCHUA, This header requires the Git sha.
|
|
35
|
+
'Sec-CH-UA-PLATFORM': process.platform,
|
|
36
|
+
'X-Request-Id': randomUUID(),
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
...(firstPartyDev() && { 'X-Shopify-Cli-Employee': '1' }),
|
|
39
|
+
};
|
|
40
|
+
if (token) {
|
|
41
|
+
// eslint-disable-next-line dot-notation
|
|
42
|
+
headers['authorization'] = `Bearer ${token}`;
|
|
43
|
+
headers['X-Shopify-Access-Token'] = `Bearer ${token}`;
|
|
85
44
|
}
|
|
45
|
+
return headers;
|
|
86
46
|
}
|
|
87
|
-
//# sourceMappingURL=
|
|
47
|
+
//# sourceMappingURL=headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,u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,0DAA0D;QAC1D,oBAAoB,EAAE,OAAO,CAAC,QAAQ;QACtC,cAAc,EAAE,UAAU,EAAE;QAC5B,cAAc,EAAE,kBAAkB;QAClC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAC,wBAAwB,EAAE,GAAG,EAAC,CAAC;KACxD,CAAA;IACD,IAAI,KAAK,EAAE;QACT,wCAAwC;QACxC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAA;QAC5C,OAAO,CAAC,wBAAwB,CAAC,GAAG,UAAU,KAAK,EAAE,CAAA;KACtD;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import constants from '../../../constants.js'\nimport {firstPartyDev} from '../../../environment/local.js'\nimport {ExtendableError} from '../../../error.js'\nimport {randomUUID} from '../../../public/node/crypto.js'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport async function buildHeaders(token?: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n // eslint-disable-next-line dot-notation\n headers['authorization'] = `Bearer ${token}`\n headers['X-Shopify-Access-Token'] = `Bearer ${token}`\n }\n\n return headers\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Alert } from './Alert.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { unstyled } from '../../../../output.js';
|
|
4
3
|
import { describe, expect, test } from 'vitest';
|
|
5
4
|
import React from 'react';
|
|
5
|
+
import { render } from 'ink-testing-library';
|
|
6
6
|
describe('Alert', async () => {
|
|
7
7
|
test('renders correctly with all the options', async () => {
|
|
8
8
|
const options = {
|
|
@@ -51,8 +51,8 @@ describe('Alert', async () => {
|
|
|
51
51
|
url: 'https://shopify.com',
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
const {
|
|
55
|
-
expect(unstyled(
|
|
54
|
+
const { lastFrame } = render(React.createElement(Alert, { type: "info", ...options }));
|
|
55
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
56
56
|
"
|
|
57
57
|
╭─ info ───────────────────────────────────────────────────────────────────────╮
|
|
58
58
|
│ │
|
|
@@ -80,8 +80,8 @@ describe('Alert', async () => {
|
|
|
80
80
|
const options = {
|
|
81
81
|
headline: 'Title',
|
|
82
82
|
};
|
|
83
|
-
const {
|
|
84
|
-
expect(unstyled(
|
|
83
|
+
const { lastFrame } = render(React.createElement(Alert, { type: "info", ...options }));
|
|
84
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
85
85
|
"
|
|
86
86
|
╭─ info ───────────────────────────────────────────────────────────────────────╮
|
|
87
87
|
│ │
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"Alert.test.js","sourceRoot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O,GAAI,CAAC,CAAA;QAE9D,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;KAsBpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,OAAO;SAClB,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,KAAK,IAAC,IAAI,EAAC,MAAM,KAAK,OAAO,GAAI,CAAC,CAAA;QAE9D,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;KAQpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Alert} from './Alert.js'\nimport {unstyled} from '../../../../output.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('Alert', async () => {\n test('renders correctly with all the options', async () => {\n const options = {\n headline: [{userInput: 'my-app'}, 'initialized and ready to build.'],\n body: ['You can find the build files in the ', {filePath: 'dist'}, 'folder.'],\n nextSteps: [\n [\n 'Run',\n {\n command: 'cd santorini-goods',\n },\n ],\n [\n 'To preview your project, run',\n {\n command: 'npm app dev',\n },\n ],\n [\n 'To add extensions, run',\n {\n command: 'npm generate extension',\n },\n ],\n ],\n reference: [\n [\n 'Run',\n {\n command: 'npm shopify help',\n },\n ],\n [\n // testing link wrapping behavior\n \"Press 'return' to open the really amazing and clean\",\n {\n link: {\n label: 'dev docs',\n url: 'https://shopify.dev',\n },\n },\n ],\n ],\n link: {\n label: 'Link',\n url: 'https://shopify.com',\n },\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ my-app initialized and ready to build. │\n │ │\n │ You can find the build files in the \\\\\"dist\\\\\" folder. │\n │ │\n │ Next steps │\n │ • Run \\`cd santorini-goods\\` │\n │ • To preview your project, run \\`npm app dev\\` │\n │ • To add extensions, run \\`npm generate extension\\` │\n │ │\n │ Reference │\n │ • Run \\`npm shopify help\\` │\n │ • Press 'return' to open the really amazing and clean dev docs ( │\n │ https://shopify.dev ) │\n │ │\n │ Link ( https://shopify.com ) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with only required options', async () => {\n const options = {\n headline: 'Title',\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ Title │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n})\n"]}
|
|
@@ -11,23 +11,23 @@ function typeToColor(type) {
|
|
|
11
11
|
}[type];
|
|
12
12
|
}
|
|
13
13
|
const BoxWithBorder = ({ type, marginY, children }) => {
|
|
14
|
-
const {
|
|
15
|
-
return (React.createElement(Box, { width:
|
|
14
|
+
const { twoThirds } = useLayout();
|
|
15
|
+
return (React.createElement(Box, { width: twoThirds, paddingY: 1, paddingX: 2, marginY: marginY, borderStyle: "round", flexDirection: "column", borderColor: typeToColor(type) },
|
|
16
16
|
React.createElement(Box, { marginTop: -2, marginBottom: 1, marginLeft: -1 },
|
|
17
17
|
React.createElement(Text, null, ` ${type.replace(/_/g, ' ')} `)),
|
|
18
18
|
children));
|
|
19
19
|
};
|
|
20
20
|
const BoxWithTopBottomLines = ({ type, marginY, children }) => {
|
|
21
|
-
const {
|
|
21
|
+
const { twoThirds } = useLayout();
|
|
22
22
|
return (React.createElement(Box, { marginY: marginY, flexDirection: "column" },
|
|
23
23
|
React.createElement(Box, { marginBottom: 1 },
|
|
24
24
|
React.createElement(Text, null,
|
|
25
25
|
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(2)),
|
|
26
26
|
React.createElement(Text, null, ` ${type.replace(/_/g, ' ')} `),
|
|
27
|
-
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(
|
|
27
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(twoThirds - 2 - type.length - 2)))),
|
|
28
28
|
children,
|
|
29
29
|
React.createElement(Box, { marginTop: 1 },
|
|
30
|
-
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(
|
|
30
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(twoThirds)))));
|
|
31
31
|
};
|
|
32
32
|
const Banner = ({ children, ...props }) => {
|
|
33
33
|
if (props.type === 'external_error') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,SAAS,WAAW,CAAC,IAAmB;IACtC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,KAAK;QACX,cAAc,EAAE,KAAK;KACtB,CAAC,IAAI,CAAC,CAAA;AACT,CAAC;AAED,MAAM,aAAa,GAAoB,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,EAAE,EAAE;IACnE,MAAM,EAAC,
|
|
1
|
+
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,K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ACtD,oBAAC,IAAI,QAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAQ;gBAE7C,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAQ,CAC/E,CACH;QAEL,QAAQ;QAET,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAQ,CAC1D,CACF,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAoB,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAC,EAAE,EAAE;IACvD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACnC,OAAO,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KACnE;SAAM;QACL,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KAC3D;AACH,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import useLayout from '../hooks/use-layout.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error'\n\ninterface Props {\n type: BannerType\n marginY?: number\n}\n\nfunction typeToColor(type: Props['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n external_error: 'red',\n }[type]\n}\n\nconst BoxWithBorder: React.FC<Props> = ({type, marginY, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box\n width={twoThirds}\n paddingY={1}\n paddingX={2}\n marginY={marginY}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-2} marginBottom={1} marginLeft={-1}>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n </Box>\n {children}\n </Box>\n )\n}\n\nconst BoxWithTopBottomLines: React.FC<Props> = ({type, marginY, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box marginY={marginY} flexDirection=\"column\">\n <Box marginBottom={1}>\n <Text>\n <Text color={typeToColor(type)}>{'─'.repeat(2)}</Text>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n {/* 2 initial dashes + 2 spaces surrounding the type */}\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds - 2 - type.length - 2)}</Text>\n </Text>\n </Box>\n\n {children}\n\n <Box marginTop={1}>\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds)}</Text>\n </Box>\n </Box>\n )\n}\n\nconst Banner: React.FC<Props> = ({children, ...props}) => {\n if (props.type === 'external_error') {\n return React.createElement(BoxWithTopBottomLines, props, children)\n } else {\n return React.createElement(BoxWithBorder, props, children)\n }\n}\n\nexport {Banner}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Banner } from './Banner.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { describe, expect, test } from 'vitest';
|
|
4
3
|
import React from 'react';
|
|
4
|
+
import { render } from 'ink-testing-library';
|
|
5
5
|
describe('Banner', async () => {
|
|
6
6
|
test('renders with a border for success', async () => {
|
|
7
|
-
const {
|
|
8
|
-
expect(
|
|
7
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "success" }));
|
|
8
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
9
9
|
"[32m╭─[39m success [32m────────────────────────────────────────────────────────────────────╮[39m
|
|
10
10
|
[32m│[39m [32m│[39m
|
|
11
11
|
[32m│[39m [32m│[39m
|
|
@@ -13,8 +13,8 @@ describe('Banner', async () => {
|
|
|
13
13
|
`);
|
|
14
14
|
});
|
|
15
15
|
test('renders with a border for info', async () => {
|
|
16
|
-
const {
|
|
17
|
-
expect(
|
|
16
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "info" }));
|
|
17
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
18
18
|
"[2m╭─[22m info [2m───────────────────────────────────────────────────────────────────────╮[22m
|
|
19
19
|
[2m│[22m [2m│[22m
|
|
20
20
|
[2m│[22m [2m│[22m
|
|
@@ -22,8 +22,8 @@ describe('Banner', async () => {
|
|
|
22
22
|
`);
|
|
23
23
|
});
|
|
24
24
|
test('renders with a border for warning', async () => {
|
|
25
|
-
const {
|
|
26
|
-
expect(
|
|
25
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "warning" }));
|
|
26
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
27
27
|
"[33m╭─[39m warning [33m────────────────────────────────────────────────────────────────────╮[39m
|
|
28
28
|
[33m│[39m [33m│[39m
|
|
29
29
|
[33m│[39m [33m│[39m
|
|
@@ -31,8 +31,8 @@ describe('Banner', async () => {
|
|
|
31
31
|
`);
|
|
32
32
|
});
|
|
33
33
|
test('renders with a border for error', async () => {
|
|
34
|
-
const {
|
|
35
|
-
expect(
|
|
34
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "error" }));
|
|
35
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
36
36
|
"[31m╭─[39m error [31m──────────────────────────────────────────────────────────────────────╮[39m
|
|
37
37
|
[31m│[39m [31m│[39m
|
|
38
38
|
[31m│[39m [31m│[39m
|
|
@@ -40,8 +40,8 @@ describe('Banner', async () => {
|
|
|
40
40
|
`);
|
|
41
41
|
});
|
|
42
42
|
test('renders with a top and bottom lines only for external errors', async () => {
|
|
43
|
-
const {
|
|
44
|
-
expect(
|
|
43
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "external_error" }));
|
|
44
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
45
45
|
"[31m──[39m external error [31m──────────────────────────────────────────────────────────────[39m
|
|
46
46
|
|
|
47
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"Banner.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,QAAQ,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;IAC5B,IAAI,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,IAAI,EAAC,SAAS,GAAG,CAAC,CAAA;QAErD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,IAAI,EAAC,MAAM,GAAG,CAAC,CAAA;QAClD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,IAAI,EAAC,SAAS,GAAG,CAAC,CAAA;QACrD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,IAAI,EAAC,OAAO,GAAG,CAAC,CAAA;QACnD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,MAAM,IAAC,IAAI,EAAC,gBAAgB,GAAG,CAAC,CAAA;QAE5D,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Banner} from './Banner.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('Banner', async () => {\n test('renders with a border for success', async () => {\n const {lastFrame} = render(<Banner type=\"success\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[32m╭─\u001b[39m success \u001b[32m────────────────────────────────────────────────────────────────────╮\u001b[39m\n \u001b[32m│\u001b[39m \u001b[32m│\u001b[39m\n \u001b[32m│\u001b[39m \u001b[32m│\u001b[39m\n \u001b[32m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[39m\"\n `)\n })\n\n test('renders with a border for info', async () => {\n const {lastFrame} = render(<Banner type=\"info\" />)\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[2m╭─\u001b[22m info \u001b[2m───────────────────────────────────────────────────────────────────────╮\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[22m\"\n `)\n })\n\n test('renders with a border for warning', async () => {\n const {lastFrame} = render(<Banner type=\"warning\" />)\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[33m╭─\u001b[39m warning \u001b[33m────────────────────────────────────────────────────────────────────╮\u001b[39m\n \u001b[33m│\u001b[39m \u001b[33m│\u001b[39m\n \u001b[33m│\u001b[39m \u001b[33m│\u001b[39m\n \u001b[33m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[39m\"\n `)\n })\n\n test('renders with a border for error', async () => {\n const {lastFrame} = render(<Banner type=\"error\" />)\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m╭─\u001b[39m error \u001b[31m──────────────────────────────────────────────────────────────────────╮\u001b[39m\n \u001b[31m│\u001b[39m \u001b[31m│\u001b[39m\n \u001b[31m│\u001b[39m \u001b[31m│\u001b[39m\n \u001b[31m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[39m\"\n `)\n })\n\n test('renders with a top and bottom lines only for external errors', async () => {\n const {lastFrame} = render(<Banner type=\"external_error\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m──\u001b[39m external error \u001b[31m──────────────────────────────────────────────────────────────\u001b[39m\n\n\n \u001b[31m────────────────────────────────────────────────────────────────────────────────\u001b[39m\"\n `)\n })\n})\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Command } from './Command.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { describe, expect, test } from 'vitest';
|
|
4
3
|
import React from 'react';
|
|
4
|
+
import { render } from 'ink-testing-library';
|
|
5
5
|
describe('Command', async () => {
|
|
6
6
|
test('renders correctly', async () => {
|
|
7
|
-
const {
|
|
8
|
-
expect(
|
|
7
|
+
const { lastFrame } = render(React.createElement(Command, { command: "npm install" }));
|
|
8
|
+
expect(lastFrame()).toMatchInlineSnapshot('"`npm install`"');
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=Command.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"Command.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,QAAQ,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IAC7B,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,OAAO,EAAC,aAAa,GAAG,CAAC,CAAA;QAE7D,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Command} from './Command.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('Command', async () => {\n test('renders correctly', async () => {\n const {lastFrame} = render(<Command command=\"npm install\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot('\"`npm install`\"')\n })\n})\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { OutputProcess } from '../../../../output.js';
|
|
3
|
+
import { AbortController } from '../../../../public/node/abort.js';
|
|
3
4
|
import { FunctionComponent } from 'react';
|
|
4
|
-
import
|
|
5
|
-
import { Writable } from 'node:stream';
|
|
5
|
+
import { Writable } from 'stream';
|
|
6
6
|
export declare type WritableStream = (process: OutputProcess, index: number) => Writable;
|
|
7
7
|
interface Props {
|
|
8
8
|
processes: OutputProcess[];
|
|
@@ -2,7 +2,7 @@ import useAsyncAndUnmount from '../hooks/use-async-and-unmount.js';
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { Box, Static, Text } from 'ink';
|
|
4
4
|
import stripAnsi from 'strip-ansi';
|
|
5
|
-
import { Writable } from '
|
|
5
|
+
import { Writable } from 'stream';
|
|
6
6
|
/**
|
|
7
7
|
* Renders output from concurrent processes to the terminal.
|
|
8
8
|
* Output will be divided in a three column layout
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AACA,OAAO,kBAAkB,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AACA,OAAO,kBAAkB,MAAM,mCAAmC,CAAA;AAElE,OAAO,KAAK,EAAE,EAAoB,QAAQ,EAAC,MAAM,OAAO,CAAA;AACxD,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AACrC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAe/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,gBAAgB,GAA6B,CAAC,EAAC,SAAS,EAAE,eAAe,EAAE,cAAc,GAAG,IAAI,EAAC,EAAE,EAAE;IACzG,MAAM,CAAC,aAAa,EAAE,gBAAgB,CA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AQ,CAC3C;YAEN,oBAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,KAAK,CAAC,KAAK,QAEtB;YAEP,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;gBAC9B,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAG,IAAI,CAAQ,CACnC,CACF,CACP,CAAC,CACE,CACP,CAAA;IACH,CAAC,CACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA","sourcesContent":["import {OutputProcess} from '../../../../output.js'\nimport useAsyncAndUnmount from '../hooks/use-async-and-unmount.js'\nimport {AbortController} from '../../../../public/node/abort.js'\nimport React, {FunctionComponent, useState} from 'react'\nimport {Box, Static, Text} from 'ink'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'stream'\n\nexport type WritableStream = (process: OutputProcess, index: number) => Writable\n\ninterface Props {\n processes: OutputProcess[]\n abortController: AbortController\n showTimestamps?: boolean\n}\ninterface Chunk {\n color: string\n prefix: string\n lines: string[]\n}\n\n/**\n * Renders output from concurrent processes to the terminal.\n * Output will be divided in a three column layout\n * with the left column containing the timestamp,\n * the right column containing the output,\n * and the middle column containing the process prefix.\n * Every process will be rendered with a different color, up to 4 colors.\n *\n * For example running `shopify app dev`:\n *\n * ```shell\n * 2022-10-10 13:11:03 | backend | npm\n * 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev\n * 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev\n * 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | backend | [nodemon] 2.0.19\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`\n * 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/\n * 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json\n * 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`\n * 2022-10-10 13:11:03 | backend |\n *\n * ```\n */\nconst ConcurrentOutput: FunctionComponent<Props> = ({processes, abortController, showTimestamps = true}) => {\n const [processOutput, setProcessOutput] = useState<Chunk[]>([])\n const concurrentColors = ['yellow', 'cyan', 'magenta', 'green', 'blue']\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n\n function lineColor(index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n return concurrentColors[colorIndex]!\n }\n\n const writableStream = (process: OutputProcess, index: number) => {\n return new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsi(chunk.toString('ascii').replace(/(\\n)$/, '')).split(/\\n/)\n\n setProcessOutput((previousProcessOutput) => [\n ...previousProcessOutput,\n {\n color: lineColor(index),\n prefix: process.prefix,\n lines,\n },\n ])\n\n next()\n },\n })\n }\n\n const runProcesses = () => {\n return Promise.all(\n processes.map(async (process, index) => {\n const stdout = writableStream(process, index)\n const stderr = writableStream(process, index)\n\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n }\n\n useAsyncAndUnmount(runProcesses, {onRejected: () => abortController.abort()})\n\n return (\n <Static items={processOutput}>\n {(chunk, index) => {\n return (\n <Box flexDirection=\"column\" key={index}>\n {chunk.lines.map((line, index) => (\n <Box key={index} flexDirection=\"row\">\n {showTimestamps && (\n <Box>\n <Box marginRight={1}>\n <Text color={chunk.color}>{new Date().toISOString().replace(/T/, ' ').replace(/\\..+/, '')}</Text>\n </Box>\n\n <Text bold color={chunk.color}>\n |\n </Text>\n </Box>\n )}\n\n <Box width={prefixColumnSize} marginX={1}>\n <Text color={chunk.color}>{chunk.prefix}</Text>\n </Box>\n\n <Text bold color={chunk.color}>\n |\n </Text>\n\n <Box flexGrow={1} paddingLeft={1}>\n <Text color={chunk.color}>{line}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )\n }}\n </Static>\n )\n}\n\nexport default ConcurrentOutput\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ConcurrentOutput from './ConcurrentOutput.js';
|
|
2
2
|
import { unstyled } from '../../../../output.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getLastFrameAfterUnmount } from '../../../../testing/ui.js';
|
|
4
|
+
import { AbortController } from '../../../../public/node/abort.js';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { describe, expect, test } from 'vitest';
|
|
6
|
-
import { AbortController } from 'abort-controller';
|
|
7
7
|
import { render } from 'ink-testing-library';
|
|
8
8
|
describe('ConcurrentOutput', () => {
|
|
9
9
|
test('renders a stream of concurrent outputs from sub-processes', async () => {
|
|
@@ -40,7 +40,7 @@ describe('ConcurrentOutput', () => {
|
|
|
40
40
|
// wait for all output to be rendered
|
|
41
41
|
await frontendPromise;
|
|
42
42
|
// Then
|
|
43
|
-
expect(unstyled(
|
|
43
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance)).replace(/\d/g, '0')).toMatchInlineSnapshot(`
|
|
44
44
|
"0000-00-00 00:00:00 | backend | first backend message
|
|
45
45
|
0000-00-00 00:00:00 | backend | second backend message
|
|
46
46
|
0000-00-00 00:00:00 | backend | third backend message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConcurrentOutput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"ConcurrentOutput.test.js","sourceRoot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K,EAAE,MAAgB,EAAE,OAAiB,EAAE,OAAoB,EAAE,EAAE;gBAC1E,MAAM,cAAc,CAAA;gBAEpB,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;gBACtC,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;gBACvC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;gBAEtC,sBAAsB,EAAE,CAAA;YAC1B,CAAC;SACF,CAAA;QACD,OAAO;QAEP,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,gBAAgB,IAAC,SAAS,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,eAAe,EAAE,IAAI,eAAe,EAAE,GAAI,CAC3G,CAAA;QAED,qCAAqC;QACrC,MAAM,eAAe,CAAA;QAErB,OAAO;QACP,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;KAQrG,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import ConcurrentOutput from './ConcurrentOutput.js'\nimport {unstyled} from '../../../../output.js'\nimport {getLastFrameAfterUnmount} from '../../../../testing/ui.js'\nimport {AbortController, AbortSignal} from '../../../../public/node/abort.js'\nimport React from 'react'\nimport {describe, expect, test} from 'vitest'\nimport {render} from 'ink-testing-library'\nimport {Writable} from 'stream'\n\ndescribe('ConcurrentOutput', () => {\n test('renders a stream of concurrent outputs from sub-processes', async () => {\n // Given\n let backendPromiseResolve: () => void\n let frontendPromiseResolve: () => void\n\n const backendPromise = new Promise<void>(function (resolve, _reject) {\n backendPromiseResolve = resolve\n })\n\n const frontendPromise = new Promise<void>(function (resolve, _reject) {\n frontendPromiseResolve = resolve\n })\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendPromiseResolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendPromise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n\n frontendPromiseResolve()\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess, frontendProcess]} abortController={new AbortController()} />,\n )\n\n // wait for all output to be rendered\n await frontendPromise\n\n // Then\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!).replace(/\\d/g, '0')).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 | backend | first backend message\n 0000-00-00 00:00:00 | backend | second backend message\n 0000-00-00 00:00:00 | backend | third backend message\n 0000-00-00 00:00:00 | frontend | first frontend message\n 0000-00-00 00:00:00 | frontend | second frontend message\n 0000-00-00 00:00:00 | frontend | third frontend message\n \"\n `)\n })\n})\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { FatalError } from './FatalError.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { unstyled } from '../../../../output.js';
|
|
4
3
|
import { Abort, Bug, ExternalError } from '../../../../error.js';
|
|
5
4
|
import { describe, expect, test } from 'vitest';
|
|
6
5
|
import React from 'react';
|
|
6
|
+
import { render } from 'ink-testing-library';
|
|
7
7
|
describe('FatalError', async () => {
|
|
8
8
|
test('renders correctly with a just a message and tryMessage', async () => {
|
|
9
9
|
const error = new Abort('test', 'try this');
|
|
10
|
-
const {
|
|
11
|
-
expect(unstyled(
|
|
10
|
+
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
11
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
12
12
|
"
|
|
13
13
|
╭─ error ──────────────────────────────────────────────────────────────────────╮
|
|
14
14
|
│ │
|
|
@@ -29,8 +29,8 @@ describe('FatalError', async () => {
|
|
|
29
29
|
at Module.load (internal/modules/cjs/loader.js:985:32)
|
|
30
30
|
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
|
|
31
31
|
`;
|
|
32
|
-
const {
|
|
33
|
-
expect(unstyled(
|
|
32
|
+
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
33
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
34
34
|
"
|
|
35
35
|
╭─ error ──────────────────────────────────────────────────────────────────────╮
|
|
36
36
|
│ │
|
|
@@ -76,8 +76,8 @@ describe('FatalError', async () => {
|
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
78
|
];
|
|
79
|
-
const {
|
|
80
|
-
expect(unstyled(
|
|
79
|
+
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
80
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
81
81
|
"
|
|
82
82
|
╭─ error ──────────────────────────────────────────────────────────────────────╮
|
|
83
83
|
│ │
|
|
@@ -102,8 +102,8 @@ describe('FatalError', async () => {
|
|
|
102
102
|
});
|
|
103
103
|
test('renders correctly an external error', async () => {
|
|
104
104
|
const error = new ExternalError('Unexpected error', 'yarn', ['install']);
|
|
105
|
-
const {
|
|
106
|
-
expect(unstyled(
|
|
105
|
+
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
106
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
107
107
|
"
|
|
108
108
|
── external error ──────────────────────────────────────────────────────────────
|
|
109
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FatalError.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FatalError.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"FatalError.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FatalError.test.tsx"],"names":[],"mappings":"AAAA,OAAO,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kBAAkB,CAAC,CAAA;QACzC,KAAK,CAAC,KAAK,GAAG;;;;;;KAMb,CAAA;QAED,KAAK,CAAC,SAAS,GAAG;YAChB;gBACE,UAAU;gBACV;oBACE,IAAI,EAAE;wBACJ,KAAK,EAAE,yCAAyC;wBAChD,GAAG,EAAE,qCAAqC;qBAC3C;iBACF;gBACD;oBACE,IAAI,EAAE,GAAG;iBACV;aACF;YACD,gEAAgE;YAChE;gBACE,gFAAgF;gBAChF;oBACE,OAAO,EAAE,SAAS;iBACnB;aACF;SACF,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;QAExD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;KAqBpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;QAExE,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;QAExD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;KAUpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {FatalError} from './FatalError.js'\nimport {unstyled} from '../../../../output.js'\nimport {Abort, Bug, ExternalError} from '../../../../error.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('FatalError', async () => {\n test('renders correctly with a just a message and tryMessage', async () => {\n const error = new Abort('test', 'try this')\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ test │\n │ │\n │ try this │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a message and a stack', async () => {\n const error = new Bug('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a message, a stack, and next steps', async () => {\n const error = new Bug('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n error.nextSteps = [\n [\n 'Have you',\n {\n link: {\n label: 'created a Shopify Partners organization',\n url: 'https://partners.shopify.com/signup',\n },\n },\n {\n char: '?',\n },\n ],\n 'Have you confirmed your accounts from the emails you received?',\n [\n 'Need to connect to a different App or organization? Run the command again with',\n {\n command: '--reset',\n },\n ],\n ]\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ Next steps │\n │ • Have you created a Shopify Partners organization ( │\n │ https://partners.shopify.com/signup )? │\n │ • Have you confirmed your accounts from the emails you received? │\n │ • Need to connect to a different App or organization? Run the command │\n │ again with \\`--reset\\` │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly an external error', async () => {\n const error = new ExternalError('Unexpected error', 'yarn', ['install'])\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ── external error ──────────────────────────────────────────────────────────────\n\n Error coming from \\`yarn install\\`\n\n Unexpected error\n\n ────────────────────────────────────────────────────────────────────────────────\n \"\n `)\n })\n})\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FilePath } from './FilePath.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { describe, expect, test } from 'vitest';
|
|
4
3
|
import React from 'react';
|
|
4
|
+
import { render } from 'ink-testing-library';
|
|
5
5
|
describe('FilePath', async () => {
|
|
6
6
|
test('renders correctly', async () => {
|
|
7
|
-
const {
|
|
8
|
-
expect(
|
|
7
|
+
const { lastFrame } = render(React.createElement(FilePath, { filePath: "src/this/is/a/test.js" }));
|
|
8
|
+
expect(lastFrame()).toMatchInlineSnapshot('"\\"src/this/is/a/test.js\\""');
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=FilePath.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePath.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FilePath.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"FilePath.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FilePath.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,QAAQ,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;IAC9B,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,QAAQ,IAAC,QAAQ,EAAC,uBAAuB,GAAG,CAAC,CAAA;QAEzE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC,+BAA+B,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {FilePath} from './FilePath.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('FilePath', async () => {\n test('renders correctly', async () => {\n const {lastFrame} = render(<FilePath filePath=\"src/this/is/a/test.js\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot('\"\\\\\"src/this/is/a/test.js\\\\\"\"')\n })\n})\n"]}
|