@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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TextPrompt } from './TextPrompt.js';
|
|
2
|
+
import { getLastFrameAfterUnmount, sendInput, waitForInputsToBeReady } from '../../../../testing/ui.js';
|
|
3
|
+
import { unstyled } from '../../../../output.js';
|
|
4
|
+
import { render } from 'ink-testing-library';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
7
|
+
const ENTER = '\r';
|
|
8
|
+
describe('TextPrompt', () => {
|
|
9
|
+
test('default state', () => {
|
|
10
|
+
const { lastFrame } = render(React.createElement(TextPrompt, { onSubmit: () => { }, message: "Test question", placeholder: "Placeholder" }));
|
|
11
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
12
|
+
"? Test question
|
|
13
|
+
> Placeholder
|
|
14
|
+
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
|
|
15
|
+
"
|
|
16
|
+
`);
|
|
17
|
+
});
|
|
18
|
+
test('validation error', async () => {
|
|
19
|
+
const renderInstance = render(React.createElement(TextPrompt, { onSubmit: () => { }, message: "Test question" }));
|
|
20
|
+
await waitForInputsToBeReady();
|
|
21
|
+
await sendInput(renderInstance, ENTER);
|
|
22
|
+
// testing with styles because the color changes to red
|
|
23
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
24
|
+
"? Test question
|
|
25
|
+
[31m>[39m [31m[7m [27m[39m
|
|
26
|
+
[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
27
|
+
[31mPlease enter a value[39m
|
|
28
|
+
"
|
|
29
|
+
`);
|
|
30
|
+
await sendInput(renderInstance, 'A');
|
|
31
|
+
// color changes back to valid color
|
|
32
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
33
|
+
"? Test question
|
|
34
|
+
[36m>[39m [36mA[7m [27m[39m
|
|
35
|
+
[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
36
|
+
"
|
|
37
|
+
`);
|
|
38
|
+
});
|
|
39
|
+
test('submitting the value', async () => {
|
|
40
|
+
const onSubmit = vi.fn();
|
|
41
|
+
const renderInstance = render(React.createElement(TextPrompt, { onSubmit: onSubmit, message: "Test question" }));
|
|
42
|
+
await waitForInputsToBeReady();
|
|
43
|
+
await sendInput(renderInstance, 'A');
|
|
44
|
+
await sendInput(renderInstance, ENTER);
|
|
45
|
+
expect(onSubmit).toHaveBeenCalledWith('A');
|
|
46
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance))).toMatchInlineSnapshot(`
|
|
47
|
+
"? Test question
|
|
48
|
+
✔ A
|
|
49
|
+
"
|
|
50
|
+
`);
|
|
51
|
+
});
|
|
52
|
+
test('text wrapping', async () => {
|
|
53
|
+
// component width is 80 characters wide in tests but because of the question mark and
|
|
54
|
+
// spaces before the question, we only have 77 characters to work with
|
|
55
|
+
const renderInstance = render(React.createElement(TextPrompt, { onSubmit: () => { }, message: "Test question" }));
|
|
56
|
+
await waitForInputsToBeReady();
|
|
57
|
+
await sendInput(renderInstance, 'A'.repeat(77));
|
|
58
|
+
await sendInput(renderInstance, 'B'.repeat(6));
|
|
59
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
60
|
+
"? Test question
|
|
61
|
+
[36m>[39m [36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA[39m
|
|
62
|
+
[36mBBBBBB[7m [27m[39m
|
|
63
|
+
[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
64
|
+
"
|
|
65
|
+
`);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=TextPrompt.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextPrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextPrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAC,wBAAwB,EAAE,SAAS,EAAE,sBAAsB,EAAC,MAAM,2BAA2B,CAAA;AACrG,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAEjD,MAAM,KAAK,GAAG,IAAI,CAAA;AAElB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QACzB,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,eAAe,EAAC,WAAW,EAAC,aAAa,GAAG,CAAC,CAAA;QAEhH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAClC,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,eAAe,GAAG,CAAC,CAAA;QAEzF,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;QACtC,uDAAuD;QACvD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;KAMxD,CAAC,CAAA;QACF,MAAM,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QACpC,oCAAoC;QACpC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKxD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,CAAA;QACxB,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAC,eAAe,GAAG,CAAC,CAAA;QAEzF,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QACpC,MAAM,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;QACtC,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAA;QAC1C,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAIjF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC/B,sFAAsF;QACtF,sEAAsE;QACtE,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,eAAe,GAAG,CAAC,CAAA;QAEzF,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;QAC/C,MAAM,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9C,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;KAMxD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {TextPrompt} from './TextPrompt.js'\nimport {getLastFrameAfterUnmount, sendInput, waitForInputsToBeReady} from '../../../../testing/ui.js'\nimport {unstyled} from '../../../../output.js'\nimport {render} from 'ink-testing-library'\nimport React from 'react'\nimport {describe, expect, test, vi} from 'vitest'\n\nconst ENTER = '\\r'\n\ndescribe('TextPrompt', () => {\n test('default state', () => {\n const {lastFrame} = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" placeholder=\"Placeholder\" />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question\n > Placeholder\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('validation error', async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" />)\n\n await waitForInputsToBeReady()\n await sendInput(renderInstance, ENTER)\n // testing with styles because the color changes to red\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question\n \u001b[31m>\u001b[39m \u001b[31m\u001b[7m \u001b[27m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mPlease enter a value\u001b[39m\n \"\n `)\n await sendInput(renderInstance, 'A')\n // color changes back to valid color\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question\n \u001b[36m>\u001b[39m \u001b[36mA\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test('submitting the value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(<TextPrompt onSubmit={onSubmit} message=\"Test question\" />)\n\n await waitForInputsToBeReady()\n await sendInput(renderInstance, 'A')\n await sendInput(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('A')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question\n ✔ A\n \"\n `)\n })\n\n test('text wrapping', async () => {\n // component width is 80 characters wide in tests but because of the question mark and\n // spaces before the question, we only have 77 characters to work with\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" />)\n\n await waitForInputsToBeReady()\n await sendInput(renderInstance, 'A'.repeat(77))\n await sendInput(renderInstance, 'B'.repeat(6))\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question\n \u001b[36m>\u001b[39m \u001b[36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\u001b[39m\n \u001b[36mBBBBBB\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n})\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TokenizedText } from './TokenizedText.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('TokenizedText', async () => {
|
|
7
7
|
test('renders arrays of items separated by spaces', async () => {
|
|
8
8
|
const item = [
|
|
@@ -31,8 +31,8 @@ describe('TokenizedText', async () => {
|
|
|
31
31
|
filePath: 'src/this/is/a/test.js',
|
|
32
32
|
},
|
|
33
33
|
];
|
|
34
|
-
const {
|
|
35
|
-
expect(unstyled(
|
|
34
|
+
const { lastFrame } = render(React.createElement(TokenizedText, { item: item }));
|
|
35
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
36
36
|
"Run \`cd verification-app\` Example ( https://example.com )! my-app
|
|
37
37
|
• Item 1
|
|
38
38
|
• Item 2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenizedText.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TokenizedText.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"TokenizedText.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TokenizedText.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,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,eAAe,EAAE,KAAK,IAAI,EAAE;IACnC,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,IAAI,GAAG;YACX,KAAK;YACL;gBACE,OAAO,EAAE,qBAAqB;aAC/B;YACD;gBACE,IAAI,EAAE;oBACJ,GAAG,EAAE,qBAAqB;oBAC1B,KAAK,EAAE,SAAS;iBACjB;aACF;YACD;gBACE,IAAI,EAAE,GAAG;aACV;YACD;gBACE,SAAS,EAAE,QAAQ;aACpB;YACD;gBACE,IAAI,EAAE;oBACJ,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;iBACtC;aACF;YACD;gBACE,QAAQ,EAAE,uBAAuB;aAClC;SACF,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAA;QAEzD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;KAMpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {TokenizedText} from './TokenizedText.js'\nimport {unstyled} from '../../../../output.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('TokenizedText', async () => {\n test('renders arrays of items separated by spaces', async () => {\n const item = [\n 'Run',\n {\n command: 'cd verification-app',\n },\n {\n link: {\n url: 'https://example.com',\n label: 'Example',\n },\n },\n {\n char: '!',\n },\n {\n userInput: 'my-app',\n },\n {\n list: {\n items: ['Item 1', 'Item 2', 'Item 3'],\n },\n },\n {\n filePath: 'src/this/is/a/test.js',\n },\n ]\n\n const {lastFrame} = render(<TokenizedText item={item} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"Run \\`cd verification-app\\` Example ( https://example.com )! my-app\n • Item 1\n • Item 2\n • Item 3\n \\\\\"src/this/is/a/test.js\\\\\"\"\n `)\n })\n})\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { UserInput } from './UserInput.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('UserInput', async () => {
|
|
6
6
|
test('renders correctly', async () => {
|
|
7
|
-
const {
|
|
8
|
-
expect(
|
|
7
|
+
const { lastFrame } = render(React.createElement(UserInput, { userInput: "my-app" }));
|
|
8
|
+
expect(lastFrame()).toMatchInlineSnapshot('"[36mmy-app[39m"');
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=UserInput.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserInput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/UserInput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"UserInput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/UserInput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,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,WAAW,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,CAAC,CAAA;QAE5D,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {UserInput} from './UserInput.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('UserInput', async () => {\n test('renders correctly', async () => {\n const {lastFrame} = render(<UserInput userInput=\"my-app\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot('\"\u001b[36mmy-app\u001b[39m\"')\n })\n})\n"]}
|
|
@@ -3,19 +3,28 @@ const MIN_WIDTH = 80;
|
|
|
3
3
|
export default function useLayout() {
|
|
4
4
|
const { stdout } = useStdout();
|
|
5
5
|
const fullWidth = stdout?.columns ?? MIN_WIDTH;
|
|
6
|
-
|
|
7
|
-
let
|
|
6
|
+
let oneThird;
|
|
7
|
+
let twoThirds;
|
|
8
8
|
if (fullWidth <= MIN_WIDTH) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
else if (twoThirdsOfWidth < MIN_WIDTH) {
|
|
12
|
-
width = MIN_WIDTH;
|
|
9
|
+
oneThird = fullWidth;
|
|
10
|
+
twoThirds = fullWidth;
|
|
13
11
|
}
|
|
14
12
|
else {
|
|
15
|
-
|
|
13
|
+
oneThird = column({ fullWidth, fraction: [1, 3], minWidth: MIN_WIDTH });
|
|
14
|
+
twoThirds = column({ fullWidth, fraction: [2, 3], minWidth: MIN_WIDTH });
|
|
16
15
|
}
|
|
17
16
|
return {
|
|
18
|
-
|
|
17
|
+
twoThirds,
|
|
18
|
+
oneThird,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
function column({ fullWidth, fraction, minWidth, }) {
|
|
22
|
+
const fractionedWidth = Math.floor((fullWidth / fraction[1]) * fraction[0]);
|
|
23
|
+
if (fractionedWidth < minWidth) {
|
|
24
|
+
return minWidth;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return fractionedWidth;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
21
30
|
//# sourceMappingURL=use-layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-layout.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/hooks/use-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAA;AAE7B,MAAM,SAAS,GAAG,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"use-layout.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/hooks/use-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAA;AAE7B,MAAM,SAAS,GAAG,EAAE,CAAA;AAOpB,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,MAAM,EAAC,MAAM,EAAC,GAAG,SAAS,EAAE,CAAA;IAE5B,MAAM,SAAS,GAAG,MAAM,EAAE,OAAO,IAAI,SAAS,CAAA;IAC9C,IAAI,QAAQ,CAAA;IACZ,IAAI,SAAS,CAAA;IAEb,IAAI,SAAS,IAAI,SAAS,EAAE;QAC1B,QAAQ,GAAG,SAAS,CAAA;QACpB,SAAS,GAAG,SAAS,CAAA;KACtB;SAAM;QACL,QAAQ,GAAG,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAA;QACrE,SAAS,GAAG,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAA;KACvE;IAED,OAAO;QACL,SAAS;QACT,QAAQ;KACT,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,GAKT;IACC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3E,IAAI,eAAe,GAAG,QAAQ,EAAE;QAC9B,OAAO,QAAQ,CAAA;KAChB;SAAM;QACL,OAAO,eAAe,CAAA;KACvB;AACH,CAAC","sourcesContent":["import {useStdout} from 'ink'\n\nconst MIN_WIDTH = 80\n\ninterface Layout {\n twoThirds: number\n oneThird: number\n}\n\nexport default function useLayout(): Layout {\n const {stdout} = useStdout()\n\n const fullWidth = stdout?.columns ?? MIN_WIDTH\n let oneThird\n let twoThirds\n\n if (fullWidth <= MIN_WIDTH) {\n oneThird = fullWidth\n twoThirds = fullWidth\n } else {\n oneThird = column({fullWidth, fraction: [1, 3], minWidth: MIN_WIDTH})\n twoThirds = column({fullWidth, fraction: [2, 3], minWidth: MIN_WIDTH})\n }\n\n return {\n twoThirds,\n oneThird,\n }\n}\n\nfunction column({\n fullWidth,\n fraction,\n minWidth,\n}: {\n fullWidth: number\n fraction: [number, number]\n minWidth: number\n}): number {\n const fractionedWidth = Math.floor((fullWidth / fraction[1]) * fraction[0])\n\n if (fractionedWidth < minWidth) {\n return minWidth\n } else {\n return fractionedWidth\n }\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Logger, LogLevel } from '../../output.js';
|
|
3
|
-
import { Props as PromptProps } from '../../private/node/ui/components/Prompt.js';
|
|
4
3
|
import { ReactElement } from 'react';
|
|
5
|
-
import { RenderOptions } from 'ink';
|
|
4
|
+
import { Key, RenderOptions } from 'ink';
|
|
6
5
|
import { EventEmitter } from 'events';
|
|
7
6
|
export declare function renderOnce(element: JSX.Element, logLevel?: LogLevel, logger?: Logger): void;
|
|
8
7
|
export declare function render(element: JSX.Element, options?: RenderOptions): Promise<void>;
|
|
@@ -20,5 +19,5 @@ export declare class OutputStream extends EventEmitter {
|
|
|
20
19
|
lastFrame: () => string | undefined;
|
|
21
20
|
}
|
|
22
21
|
export declare const renderString: (element: ReactElement) => Instance;
|
|
23
|
-
export declare function
|
|
22
|
+
export declare function handleCtrlC(input: string, key: Key): void;
|
|
24
23
|
export {};
|
package/dist/private/node/ui.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { isUnitTest } from '../../environment/local.js';
|
|
2
2
|
import { collectLog, consoleLog, outputWhereAppropriate } from '../../output.js';
|
|
3
|
-
import Prompt from '../../private/node/ui/components/Prompt.js';
|
|
4
|
-
import React from 'react';
|
|
5
3
|
import { render as inkRender } from 'ink';
|
|
6
4
|
import { EventEmitter } from 'events';
|
|
7
5
|
export function renderOnce(element, logLevel = 'info', logger = consoleLog) {
|
|
@@ -17,7 +15,6 @@ export function render(element, options) {
|
|
|
17
15
|
const { waitUntilExit } = inkRender(element, options);
|
|
18
16
|
return waitUntilExit();
|
|
19
17
|
}
|
|
20
|
-
const TEST_TERMINAL_WIDTH = 80;
|
|
21
18
|
export class OutputStream extends EventEmitter {
|
|
22
19
|
constructor(options) {
|
|
23
20
|
super();
|
|
@@ -31,8 +28,8 @@ export class OutputStream extends EventEmitter {
|
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
export const renderString = (element) => {
|
|
34
|
-
const stdout = new OutputStream({ columns:
|
|
35
|
-
const stderr = new OutputStream({ columns:
|
|
31
|
+
const stdout = new OutputStream({ columns: process.stdout.columns });
|
|
32
|
+
const stderr = new OutputStream({ columns: process.stderr.columns });
|
|
36
33
|
const instance = inkRender(element, {
|
|
37
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
35
|
stdout: stdout,
|
|
@@ -47,16 +44,10 @@ export const renderString = (element) => {
|
|
|
47
44
|
unmount: instance.unmount,
|
|
48
45
|
};
|
|
49
46
|
};
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const props = {
|
|
56
|
-
...options,
|
|
57
|
-
onChoose: onChooseResolve,
|
|
58
|
-
};
|
|
59
|
-
await render(React.createElement(Prompt, { ...props }), { exitOnCtrlC: false });
|
|
60
|
-
return onChoosePromise;
|
|
47
|
+
export function handleCtrlC(input, key) {
|
|
48
|
+
if (input === 'c' && key.ctrl) {
|
|
49
|
+
// Exceptions thrown in hooks aren't caught by our errorHandler.
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
61
52
|
}
|
|
62
53
|
//# sourceMappingURL=ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AAEhG,OAAO,EAAM,MAAM,IAAI,SAAS,EAAgB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AAEnC,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,WAAqB,MAAM,EAAE,SAAiB,UAAU;IACvG,MAAM,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAE/C,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC9C,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KACjD;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,OAAuB;IAClE,MAAM,EAAC,aAAa,EAAC,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACnD,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAOD,MAAM,OAAO,YAAa,SAAQ,YAAY;IAI5C,YAAY,OAA0B;QACpC,KAAK,EAAE,CAAA;QAIT,UAAK,GAAG,CAAC,KAAa,EAAE,EAAE;YACxB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC,CAAA;QAED,cAAS,GAAG,GAAG,EAAE;YACf,OAAO,IAAI,CAAC,UAAU,CAAA;QACxB,CAAC,CAAA;QATC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;CASF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAY,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAClE,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAElE,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE;QAClC,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,GAAQ;IACjD,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE;QAC7B,gEAAgE;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;AACH,CAAC","sourcesContent":["import {isUnitTest} from '../../environment/local.js'\nimport {collectLog, consoleLog, Logger, LogLevel, outputWhereAppropriate} from '../../output.js'\nimport {ReactElement} from 'react'\nimport {Key, render as inkRender, RenderOptions} from 'ink'\nimport {EventEmitter} from 'events'\n\nexport function renderOnce(element: JSX.Element, logLevel: LogLevel = 'info', logger: Logger = consoleLog) {\n const {output, unmount} = renderString(element)\n\n if (output) {\n if (isUnitTest()) collectLog(logLevel, output)\n outputWhereAppropriate(logLevel, logger, output)\n }\n\n unmount()\n}\n\nexport function render(element: JSX.Element, options?: RenderOptions) {\n const {waitUntilExit} = inkRender(element, options)\n return waitUntilExit()\n}\n\ninterface Instance {\n output: string | undefined\n unmount: () => void\n}\n\nexport class OutputStream extends EventEmitter {\n columns: number\n private _lastFrame?: string\n\n constructor(options: {columns: number}) {\n super()\n this.columns = options.columns\n }\n\n write = (frame: string) => {\n this._lastFrame = frame\n }\n\n lastFrame = () => {\n return this._lastFrame\n }\n}\n\nexport const renderString = (element: ReactElement): Instance => {\n const stdout = new OutputStream({columns: process.stdout.columns})\n const stderr = new OutputStream({columns: process.stderr.columns})\n\n const instance = inkRender(element, {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stdout: stdout as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stderr: stderr as any,\n debug: true,\n exitOnCtrlC: false,\n patchConsole: false,\n })\n\n return {\n output: stdout.lastFrame(),\n unmount: instance.unmount,\n }\n}\n\nexport function handleCtrlC(input: string, key: Key) {\n if (input === 'c' && key.ctrl) {\n // Exceptions thrown in hooks aren't caught by our errorHandler.\n process.exit(1)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAGpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAE,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAwB;IACpE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAmC,CAAA;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAU;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAI,KAAiC,EAAE,QAA0B;IACrF,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,OAAO,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAI,KAAiC,EAAE,GAAG,MAAiB;IACnF,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACrD,OAAO,gBAAgB,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import {createRequire} from 'module'\nimport type {List, ValueIteratee} from 'lodash'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Takes a random value from an array.\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]): T {\n return array[Math.floor(Math.random() * array.length)]!\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]): boolean {\n return array.length !== new Set(array).size\n}\n\n/**\n * This method is like `_.uniq` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * uniqueness is computed. The iteratee is invoked with one argument: (value).\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\nexport function uniqBy<T>(array: List<T> | null | undefined, iteratee: ValueIteratee<T>): T[] {\n const lodashUniqBy = require('lodash/uniqBy')\n return lodashUniqBy(array, iteratee)\n}\n\n/**\n * Creates an array of `array` values not included in the other provided arrays using SameValueZero for\n * equality comparisons. The order and references of result values are determined by the first array.\n *\n * @param array - The array to inspect.\n * @param values - The arrays of values to exclude.\n * @returns Returns the new array of filtered values.\n */\nexport function difference<T>(array: List<T> | null | undefined, ...values: List<T>[]): T[] {\n const lodashDifference = require('lodash/difference')\n return lodashDifference(array, ...values)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/public/common/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/public/common/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAGpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CACrB,UAA2C,EAC3C,QAA2B;IAI3B,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC/C,OAAO,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAI,UAAsC,EAAE,QAA0B;IAC7F,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACnD,OAAO,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["import {createRequire} from 'module'\nimport type {List, ValueIteratee} from 'lodash'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Creates an object composed of keys generated from the results of running each element of collection through\n * iteratee. The corresponding value of each key is an array of the elements responsible for generating the\n * key. The iteratee is invoked with one argument: (value).\n *\n * @param collection - The collection to iterate over.\n * @param iteratee - The function invoked per iteration.\n * @returns Returns the composed aggregate object.\n */\nexport function groupBy<T>(\n collection: ArrayLike<T> | null | undefined,\n iteratee?: ValueIteratee<T>,\n): {\n [index: string]: T[]\n} {\n const lodashBroupBy = require('lodash/groupBy')\n return lodashBroupBy(collection, iteratee)\n}\n\n/**\n * Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for,\n * while the second of which contains elements predicate returns falsey for.\n * The predicate is invoked with three arguments: (value, index|key, collection).\n *\n * @param collection - The collection to iterate over.\n * @param callback - The function called per iteration.\n * @returns Returns the array of grouped elements.\n */\nexport function partition<T>(collection: List<T> | null | undefined, callback: ValueIteratee<T>): [T[], T[]] {\n const lodashPartition = require('lodash/partition')\n return lodashPartition(collection, callback)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/public/common/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/public/common/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAGpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;;GASG;AACH,8DAA8D;AAC9D,MAAM,UAAU,OAAO,CAAkC,IAAO,EAAE,QAA8C;IAC9G,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACzC,OAAO,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAChC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,8DAA8D;AAC9D,MAAM,UAAU,QAAQ,CACtB,IAAO,EACP,IAAa,EACb,OAA0B;IAE1B,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACjD,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import {createRequire} from 'module'\nimport type {DebouncedFunc, DebounceSettings} from 'lodash'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for\n * storing the result based on the arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with\n * the this binding of the memoized function.\n *\n * @param func - The function to have its output memoized.\n * @param resolver - The function to resolve the cache key.\n * @returns Returns the new memoizing function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function memoize<T extends (...args: any) => any>(func: T, resolver?: (...args: Parameters<T>) => unknown): T {\n const memoize = require('lodash/memoize')\n return memoize(func, resolver)\n}\n\n/**\n * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since\n * the last time the debounced function was invoked. The debounced function comes with a cancel method to\n * cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to\n * indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent\n * calls to the debounced function return the result of the last func invocation.\n *\n * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only\n * if the the debounced function is invoked more than once during the wait timeout.\n *\n * See David Corbacho’s article for details over the differences between _.debounce and _.throttle.\n *\n * @param func - The function to debounce.\n * @param wait - The number of milliseconds to delay.\n * @param options - The options object.\n * @returns Returns the new debounced function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function debounce<T extends (...args: any) => any>(\n func: T,\n wait?: number,\n options?: DebounceSettings,\n): DebouncedFunc<T> {\n const lodashDebounce = require('lodash/debounce')\n return lodashDebounce(func, wait, options)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/public/common/lang.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/public/common/lang.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,KAAc;IACpD,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC/C,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are **not** supported.\n *\n * @param value - The value to compare.\n * @param other - The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n * @example\n */\nexport function isEqual(value: unknown, other: unknown): boolean {\n const lodashIsEqual = require('lodash/isEqual')\n return lodashIsEqual(value, other)\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import deepMerge from 'deepmerge';
|
|
2
|
-
import { createRequire } from '
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
/**
|
|
5
5
|
* Deep merges the two objects and returns a new object with the merge result.
|
|
@@ -13,9 +13,6 @@ const require = createRequire(import.meta.url);
|
|
|
13
13
|
export function deepMergeObjects(lhs, rhs, arrayMergeStrategy = unionArrayStrategy) {
|
|
14
14
|
return deepMerge(lhs, rhs, { arrayMerge: arrayMergeStrategy });
|
|
15
15
|
}
|
|
16
|
-
function unionArrayStrategy(destinationArray, sourceArray) {
|
|
17
|
-
return Array.from(new Set([...destinationArray, ...sourceArray]));
|
|
18
|
-
}
|
|
19
16
|
/**
|
|
20
17
|
* Creates an object composed of the `object` properties `predicate` returns
|
|
21
18
|
* truthy for. The predicate is invoked with two arguments: (value, key).
|
|
@@ -42,4 +39,7 @@ export function mapValues(obj, callback) {
|
|
|
42
39
|
const lodashMapValues = require('lodash/mapValues.js');
|
|
43
40
|
return lodashMapValues(obj, callback);
|
|
44
41
|
}
|
|
42
|
+
function unionArrayStrategy(destinationArray, sourceArray) {
|
|
43
|
+
return Array.from(new Set([...destinationArray, ...sourceArray]));
|
|
44
|
+
}
|
|
45
45
|
//# sourceMappingURL=object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,aAAa,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,GAAgB,EAChB,qBAAyF,kBAAkB;IAE3G,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,gEAAgE;AAChE,MAAM,UAAU,MAAM,CACpB,MAAwC,EACxC,SAA+B;IAE/B,MAAM,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAChD,OAAO,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,GAAyB,EACzB,QAAoC;IAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACtD,OAAO,eAAe,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AACvC,CAAC;AAED,SAAS,kBAAkB,CAAC,gBAA2B,EAAE,WAAsB;IAC7E,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AACnE,CAAC","sourcesContent":["import deepMerge from 'deepmerge'\nimport {Dictionary, ObjectIterator, ValueKeyIteratee} from 'lodash'\nimport {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Deep merges the two objects and returns a new object with the merge result.\n *\n * @param lhs - One of the objects to be merged.\n * @param rhs - Another object to be merged.\n * @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid\n * duplicated elements.\n * @returns A Javascrip tobject with th emerged objects.\n */\nexport function deepMergeObjects<T1, T2>(\n lhs: Partial<T1>,\n rhs: Partial<T2>,\n arrayMergeStrategy: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[] = unionArrayStrategy,\n): T1 & T2 {\n return deepMerge(lhs, rhs, {arrayMerge: arrayMergeStrategy})\n}\n\n/**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @param object- The source object.\n * @param predicate - The function invoked per property.\n * @returns Returns the new object.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function pickBy<T, S extends T>(\n object: Dictionary<T> | null | undefined,\n predicate?: ValueKeyIteratee<T>,\n): Dictionary<S> {\n const lodashPickBy = require('lodash/pickBy.js')\n return lodashPickBy(object, predicate)\n}\n\n/**\n * Creates an object with the same keys as object and values generated by running each own\n * enumerable property of object through iteratee. The iteratee function is\n * invoked with three arguments: (value, key, object).\n *\n * @param object - The object to iterate over.\n * @param callback - The function invoked per iteration.\n * @returns Returns the new mapped object.\n */\nexport function mapValues<T extends object, TResult>(\n obj: T | null | undefined,\n callback: ObjectIterator<T, TResult>,\n): {[P in keyof T]: TResult} {\n const lodashMapValues = require('lodash/mapValues.js')\n return lodashMapValues(obj, callback)\n}\n\nfunction unionArrayStrategy(destinationArray: unknown[], sourceArray: unknown[]): unknown[] {\n return Array.from(new Set([...destinationArray, ...sourceArray]))\n}\n"]}
|
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
export declare type RandomNameFamily = 'business' | 'creative';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Generates a random name by combining an adjective and noun.
|
|
4
|
+
*
|
|
5
|
+
* @param family - Theme to use for the random name (business or creative).
|
|
4
6
|
* @returns A random name generated by combining an adjective and noun.
|
|
5
7
|
*/
|
|
6
8
|
export declare function getRandomName(family?: RandomNameFamily): string;
|
|
9
|
+
/**
|
|
10
|
+
* Given a string, it returns it with the first letter capitalized.
|
|
11
|
+
*
|
|
12
|
+
* @param str - String to capitalize.
|
|
13
|
+
* @returns String with the first letter capitalized.
|
|
14
|
+
*/
|
|
15
|
+
export declare function capitalize(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Try to convert a string to an int, falling back to undefined if unable to.
|
|
18
|
+
*
|
|
19
|
+
* @param maybeInt - String to convert to an int.
|
|
20
|
+
* @returns The int if it was able to convert, otherwise undefined.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tryParseInt(maybeInt: string | undefined): number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Transforms a matrix of strings into a single string with the columns aligned.
|
|
25
|
+
*
|
|
26
|
+
* @param lines - Array of rows, where each row is an array of strings (representing columns).
|
|
27
|
+
* @returns A string with the columns aligned.
|
|
28
|
+
*/
|
|
29
|
+
export declare function linesToColumns(lines: string[][]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Given a string, it transforms it to a slug (lowercase, hyphenated, no special chars, trimmed...).
|
|
32
|
+
*
|
|
33
|
+
* @param str - String to slugify.
|
|
34
|
+
* @returns The slugified string.
|
|
35
|
+
*/
|
|
36
|
+
export declare function slugify(str: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Given a string, it returns it with the special regex characters escaped.
|
|
39
|
+
* More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping.
|
|
40
|
+
*
|
|
41
|
+
* @param str - String to escape.
|
|
42
|
+
* @returns The escaped string.
|
|
43
|
+
*/
|
|
44
|
+
export declare function escapeRegExp(str: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Transform a string to camelCase.
|
|
47
|
+
*/
|
|
48
|
+
export { camelCase as camelize } from 'change-case';
|
|
49
|
+
/**
|
|
50
|
+
* Transform a string to param-case.
|
|
51
|
+
*/
|
|
52
|
+
export { paramCase as hyphenate } from 'change-case';
|
|
53
|
+
/**
|
|
54
|
+
* Transform a string to snake_case.
|
|
55
|
+
*/
|
|
56
|
+
export { snakeCase as underscore } from 'change-case';
|
|
57
|
+
/**
|
|
58
|
+
* Transform a string to CONSTANT_CASE.
|
|
59
|
+
*/
|
|
60
|
+
export { constantCase as constantize } from 'change-case';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { takeRandomFromArray } from './array.js';
|
|
2
|
+
import { unstyled } from '../../output.js';
|
|
2
3
|
const SAFE_RANDOM_BUSINESS_ADJECTIVES = [
|
|
3
4
|
'commercial',
|
|
4
5
|
'profitable',
|
|
@@ -90,7 +91,9 @@ const SAFE_RANDOM_CREATIVE_NOUNS = [
|
|
|
90
91
|
'tone',
|
|
91
92
|
];
|
|
92
93
|
/**
|
|
93
|
-
*
|
|
94
|
+
* Generates a random name by combining an adjective and noun.
|
|
95
|
+
*
|
|
96
|
+
* @param family - Theme to use for the random name (business or creative).
|
|
94
97
|
* @returns A random name generated by combining an adjective and noun.
|
|
95
98
|
*/
|
|
96
99
|
export function getRandomName(family = 'business') {
|
|
@@ -106,4 +109,93 @@ export function getRandomName(family = 'business') {
|
|
|
106
109
|
};
|
|
107
110
|
return `${takeRandomFromArray(mapping[family].adjectives)}-${takeRandomFromArray(mapping[family].nouns)}`;
|
|
108
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Given a string, it returns it with the first letter capitalized.
|
|
114
|
+
*
|
|
115
|
+
* @param str - String to capitalize.
|
|
116
|
+
* @returns String with the first letter capitalized.
|
|
117
|
+
*/
|
|
118
|
+
export function capitalize(str) {
|
|
119
|
+
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Try to convert a string to an int, falling back to undefined if unable to.
|
|
123
|
+
*
|
|
124
|
+
* @param maybeInt - String to convert to an int.
|
|
125
|
+
* @returns The int if it was able to convert, otherwise undefined.
|
|
126
|
+
*/
|
|
127
|
+
export function tryParseInt(maybeInt) {
|
|
128
|
+
let asInt;
|
|
129
|
+
if (maybeInt !== undefined) {
|
|
130
|
+
asInt = parseInt(maybeInt, 10);
|
|
131
|
+
if (isNaN(asInt)) {
|
|
132
|
+
asInt = undefined;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return asInt;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Transforms a matrix of strings into a single string with the columns aligned.
|
|
139
|
+
*
|
|
140
|
+
* @param lines - Array of rows, where each row is an array of strings (representing columns).
|
|
141
|
+
* @returns A string with the columns aligned.
|
|
142
|
+
*/
|
|
143
|
+
export function linesToColumns(lines) {
|
|
144
|
+
const widths = [];
|
|
145
|
+
for (let i = 0; lines[0] && i < lines[0].length; i++) {
|
|
146
|
+
const columnRows = lines.map((line) => line[i]);
|
|
147
|
+
widths.push(Math.max(...columnRows.map((row) => unstyled(row).length)));
|
|
148
|
+
}
|
|
149
|
+
const paddedLines = lines
|
|
150
|
+
.map((line) => {
|
|
151
|
+
return line
|
|
152
|
+
.map((col, index) => {
|
|
153
|
+
return `${col}${' '.repeat(widths[index] - unstyled(col).length)}`;
|
|
154
|
+
})
|
|
155
|
+
.join(' ')
|
|
156
|
+
.trimEnd();
|
|
157
|
+
})
|
|
158
|
+
.join('\n');
|
|
159
|
+
return paddedLines;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Given a string, it transforms it to a slug (lowercase, hyphenated, no special chars, trimmed...).
|
|
163
|
+
*
|
|
164
|
+
* @param str - String to slugify.
|
|
165
|
+
* @returns The slugified string.
|
|
166
|
+
*/
|
|
167
|
+
export function slugify(str) {
|
|
168
|
+
return str
|
|
169
|
+
.toLowerCase()
|
|
170
|
+
.trim()
|
|
171
|
+
.replace(/[^\w\s-]/g, '')
|
|
172
|
+
.replace(/[\s_-]+/g, '-')
|
|
173
|
+
.replace(/^-+|-+$/g, '');
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Given a string, it returns it with the special regex characters escaped.
|
|
177
|
+
* More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping.
|
|
178
|
+
*
|
|
179
|
+
* @param str - String to escape.
|
|
180
|
+
* @returns The escaped string.
|
|
181
|
+
*/
|
|
182
|
+
export function escapeRegExp(str) {
|
|
183
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Transform a string to camelCase.
|
|
187
|
+
*/
|
|
188
|
+
export { camelCase as camelize } from 'change-case';
|
|
189
|
+
/**
|
|
190
|
+
* Transform a string to param-case.
|
|
191
|
+
*/
|
|
192
|
+
export { paramCase as hyphenate } from 'change-case';
|
|
193
|
+
/**
|
|
194
|
+
* Transform a string to snake_case.
|
|
195
|
+
*/
|
|
196
|
+
export { snakeCase as underscore } from 'change-case';
|
|
197
|
+
/**
|
|
198
|
+
* Transform a string to CONSTANT_CASE.
|
|
199
|
+
*/
|
|
200
|
+
export { constantCase as constantize } from 'change-case';
|
|
109
201
|
//# sourceMappingURL=string.js.map
|