@shopify/cli-kit 3.33.0 → 3.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +2 -5
- package/dist/constants.js +0 -3
- package/dist/constants.js.map +1 -1
- package/dist/file.d.ts +1 -1
- package/dist/git.js +1 -1
- package/dist/git.js.map +1 -1
- package/dist/http.js +2 -2
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +1 -1
- package/dist/path.js +5 -3
- package/dist/path.js.map +1 -1
- package/dist/private/node/analytics.js +6 -9
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/graphql.js +1 -0
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/api/rest.d.ts +1 -1
- package/dist/private/node/api/rest.js.map +1 -1
- package/dist/private/node/environment/service.d.ts +18 -0
- package/dist/private/node/environment/service.js +32 -0
- package/dist/private/node/environment/service.js.map +1 -0
- package/dist/{environment → private/node/environment}/spin-cache.d.ts +0 -0
- package/dist/{environment → private/node/environment}/spin-cache.js +0 -0
- package/dist/private/node/environment/spin-cache.js.map +1 -0
- package/dist/{environment → private/node/environment}/utilities.d.ts +0 -0
- package/dist/{environment → private/node/environment}/utilities.js +0 -0
- package/dist/private/node/environment/utilities.js.map +1 -0
- package/dist/{session → private/node/session}/authorize.d.ts +1 -5
- package/dist/{session → private/node/session}/authorize.js +9 -9
- package/dist/private/node/session/authorize.js.map +1 -0
- package/dist/{session → private/node/session}/device-authorization.d.ts +0 -0
- package/dist/{session → private/node/session}/device-authorization.js +7 -9
- package/dist/private/node/session/device-authorization.js.map +1 -0
- package/dist/{session → private/node/session}/exchange.d.ts +2 -2
- package/dist/{session → private/node/session}/exchange.js +5 -5
- package/dist/private/node/session/exchange.js.map +1 -0
- package/dist/{session → private/node/session}/identity-token-validation.d.ts +0 -0
- package/dist/{session → private/node/session}/identity-token-validation.js +4 -4
- package/dist/private/node/session/identity-token-validation.js.map +1 -0
- package/dist/{session → private/node/session}/identity.d.ts +1 -1
- package/dist/{session → private/node/session}/identity.js +2 -3
- package/dist/private/node/session/identity.js.map +1 -0
- package/dist/{session → private/node/session}/post-auth.d.ts +1 -1
- package/dist/{session → private/node/session}/post-auth.js +3 -3
- package/dist/private/node/session/post-auth.js.map +1 -0
- package/dist/{session → private/node/session}/redirect-listener.d.ts +0 -0
- package/dist/{session → private/node/session}/redirect-listener.js +2 -2
- package/dist/private/node/session/redirect-listener.js.map +1 -0
- package/dist/{session → private/node/session}/schema.d.ts +1 -1
- package/dist/{session → private/node/session}/schema.js +1 -1
- package/dist/private/node/session/schema.js.map +1 -0
- package/dist/{session → private/node/session}/scopes.d.ts +1 -1
- package/dist/{session → private/node/session}/scopes.js +2 -2
- package/dist/private/node/session/scopes.js.map +1 -0
- package/dist/{session → private/node/session}/store.d.ts +0 -0
- package/dist/{session → private/node/session}/store.js +5 -5
- package/dist/private/node/session/store.js.map +1 -0
- package/dist/{session → private/node/session}/validate.d.ts +0 -0
- package/dist/{session → private/node/session}/validate.js +3 -3
- package/dist/private/node/session/validate.js.map +1 -0
- package/dist/private/node/session.d.ts +56 -0
- package/dist/{session.js → private/node/session.js} +97 -133
- package/dist/private/node/session.js.map +1 -0
- package/dist/private/node/ui.js +1 -1
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/node/analytics.js +3 -3
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +1 -1
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/partners.js +1 -1
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/base-command.js +2 -2
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli.d.ts +8 -0
- package/dist/public/node/cli.js +21 -4
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/environment/fqdn.d.ts +26 -0
- package/dist/{environment → public/node/environment}/fqdn.js +15 -31
- package/dist/public/node/environment/fqdn.js.map +1 -0
- package/dist/{environment → public/node/environment}/local.d.ts +62 -15
- package/dist/{environment → public/node/environment}/local.js +66 -21
- package/dist/public/node/environment/local.js.map +1 -0
- package/dist/public/node/environment/spin.d.ts +43 -0
- package/dist/{environment → public/node/environment}/spin.js +28 -35
- package/dist/public/node/environment/spin.js.map +1 -0
- 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/ruby.d.ts +1 -1
- package/dist/public/node/ruby.js +11 -12
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/session.d.ts +53 -0
- package/dist/public/node/session.js +95 -0
- package/dist/public/node/session.js.map +1 -0
- package/dist/public/node/system.d.ts +44 -0
- package/dist/{system.js → public/node/system.js} +34 -54
- package/dist/public/node/system.js.map +1 -0
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +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.js +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +9 -6
- package/dist/cli.d.ts +0 -8
- package/dist/cli.js +0 -18
- package/dist/cli.js.map +0 -1
- package/dist/environment/fqdn.d.ts +0 -29
- package/dist/environment/fqdn.js.map +0 -1
- package/dist/environment/local.js.map +0 -1
- package/dist/environment/service.d.ts +0 -4
- package/dist/environment/service.js +0 -19
- package/dist/environment/service.js.map +0 -1
- package/dist/environment/spin-cache.js.map +0 -1
- package/dist/environment/spin.d.ts +0 -50
- package/dist/environment/spin.js.map +0 -1
- package/dist/environment/utilities.js.map +0 -1
- package/dist/environment.d.ts +0 -7
- package/dist/environment.js +0 -8
- package/dist/environment.js.map +0 -1
- package/dist/network/service.d.ts +0 -14
- package/dist/network/service.js +0 -11
- package/dist/network/service.js.map +0 -1
- package/dist/session/authorize.js.map +0 -1
- package/dist/session/device-authorization.js.map +0 -1
- package/dist/session/exchange.js.map +0 -1
- package/dist/session/identity-token-validation.js.map +0 -1
- package/dist/session/identity.js.map +0 -1
- package/dist/session/post-auth.js.map +0 -1
- package/dist/session/redirect-listener.js.map +0 -1
- package/dist/session/schema.js.map +0 -1
- package/dist/session/scopes.js.map +0 -1
- package/dist/session/store.js.map +0 -1
- package/dist/session/token.d.ts +0 -40
- package/dist/session/token.js +0 -22
- package/dist/session/token.js.map +0 -1
- package/dist/session/validate.js.map +0 -1
- package/dist/session.d.ts +0 -96
- package/dist/session.js.map +0 -1
- package/dist/system.d.ts +0 -51
- package/dist/system.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/public/node/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,WAAW,MAAM,qCAAqC,CAAA;AAElE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AACjF,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAA;AAClC,OAAO,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AAUjE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,SAAmB,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IACxF,KAAK,CAAC,OAAO,CAAA;EACb,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAA;IACA,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,oB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GAAG,EAAE,YAAY,CAAC,CAAA;IAC3G,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,MAAM,IAAI,GAAG,CAAC,mDAAmD,CAAC,CAAA;KACnE;IACD,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,KAAa,EACb,QAA4B,EAC5B,SAAmB,EAAE,EACrB,YAAY,GAAG,KAAK;IAEpB,KAAK,CAAC,OAAO,CAAA;EACb,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAA;IACA,IAAI,QAAQ;QAAE,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAAC,CAAA;IAClF,OAAO,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {normalizeStoreFqdn} from './environment/fqdn.js'\nimport * as secureStore from '../../private/node/session/store.js'\n\nimport {exchangeCustomPartnerToken} from '../../private/node/session/exchange.js'\nimport constants from '../../constants.js'\nimport {content, token, debug} from '../../output.js'\nimport {Bug} from '../../error.js'\nimport {ensureAuthenticated} from '../../private/node/session.js'\n\n/**\n * Session Object to access the Admin API, includes the token and the store FQDN.\n */\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param env - Optional environment variables to use.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(scopes: string[] = [], env = process.env): Promise<string> {\n debug(content`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${token.json(scopes)}\n`)\n const envToken = env[constants.environmentVariables.partnersToken]\n if (envToken) {\n return (await exchangeCustomPartnerToken(envToken)).accessToken\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}})\n if (!tokens.partners) {\n throw new Bug('No partners token found after ensuring authenticated')\n }\n return tokens.partners\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param password - Optional password to use.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n): Promise<string> {\n if (password) return password\n\n debug(content`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${token.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}})\n if (!tokens.storefront) {\n throw new Bug('No storefront token found after ensuring authenticated')\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n *\n * @param store - Store fqdn to request auth for.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Admin API.\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n debug(content`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${token.raw(\n store,\n )}:\n${token.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, forceRefresh)\n if (!tokens.admin) {\n throw new Bug('No admin token found after ensuring authenticated')\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n *\n * @param store - Store fqdn to request auth for.\n * @param password - Password generated from Theme Access app.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token and store.\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n debug(content`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${token.json(scopes)}\n`)\n if (password) return {token: password, storeFqdn: await normalizeStoreFqdn(store)}\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * Logout from Shopify.\n *\n * @returns A promise that resolves when the logout is complete.\n */\nexport function logout(): Promise<void> {\n return secureStore.remove()\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AbortSignal } from './abort.js';
|
|
3
|
+
import type { Writable, Readable } from 'stream';
|
|
4
|
+
export interface ExecOptions {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
env?: {
|
|
7
|
+
[key: string]: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
stdin?: Readable | 'inherit';
|
|
10
|
+
stdout?: Writable | 'inherit';
|
|
11
|
+
stderr?: Writable | 'inherit';
|
|
12
|
+
stdio?: 'inherit';
|
|
13
|
+
input?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opens a URL in the user's default browser.
|
|
18
|
+
*
|
|
19
|
+
* @param url - URL to open.
|
|
20
|
+
*/
|
|
21
|
+
export declare function openURL(url: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Runs a command asynchronously, aggregates the stdout data, and returns it.
|
|
24
|
+
*
|
|
25
|
+
* @param command - Command to be executed.
|
|
26
|
+
* @param args - Arguments to pass to the command.
|
|
27
|
+
* @param options - Optional settings for how to run the command.
|
|
28
|
+
* @returns A promise that resolves with the aggregatted stdout of the command.
|
|
29
|
+
*/
|
|
30
|
+
export declare function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Runs a command asynchronously.
|
|
33
|
+
*
|
|
34
|
+
* @param command - Command to be executed.
|
|
35
|
+
* @param args - Arguments to pass to the command.
|
|
36
|
+
* @param options - Optional settings for how to run the command.
|
|
37
|
+
*/
|
|
38
|
+
export declare function exec(command: string, args: string[], options?: ExecOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Waits for a given number of seconds.
|
|
41
|
+
*
|
|
42
|
+
* @param seconds - Number of seconds to wait.
|
|
43
|
+
*/
|
|
44
|
+
export declare function sleep(seconds: number): Promise<void>;
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Abort, ExternalError } from './error.js';
|
|
4
|
-
import { renderConcurrent } from './public/node/ui.js';
|
|
1
|
+
import { Abort, ExternalError } from '../../error.js';
|
|
2
|
+
import { shouldDisplayColors, debug } from '../../output.js';
|
|
5
3
|
import { execa } from 'execa';
|
|
6
4
|
import treeKill from 'tree-kill';
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Opens a URL in the user's default browser.
|
|
7
|
+
*
|
|
8
|
+
* @param url - URL to open.
|
|
9
|
+
*/
|
|
10
|
+
export async function openURL(url) {
|
|
8
11
|
const externalOpen = await import('open');
|
|
9
12
|
await externalOpen.default(url);
|
|
10
|
-
}
|
|
13
|
+
}
|
|
11
14
|
/**
|
|
12
15
|
* Runs a command asynchronously, aggregates the stdout data, and returns it.
|
|
16
|
+
*
|
|
13
17
|
* @param command - Command to be executed.
|
|
14
18
|
* @param args - Arguments to pass to the command.
|
|
19
|
+
* @param options - Optional settings for how to run the command.
|
|
15
20
|
* @returns A promise that resolves with the aggregatted stdout of the command.
|
|
16
21
|
*/
|
|
17
|
-
export
|
|
22
|
+
export async function captureOutput(command, args, options) {
|
|
18
23
|
const result = await buildExec(command, args, options);
|
|
19
24
|
return result.stdout;
|
|
20
|
-
}
|
|
21
|
-
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Runs a command asynchronously.
|
|
28
|
+
*
|
|
29
|
+
* @param command - Command to be executed.
|
|
30
|
+
* @param args - Arguments to pass to the command.
|
|
31
|
+
* @param options - Optional settings for how to run the command.
|
|
32
|
+
*/
|
|
33
|
+
export async function exec(command, args, options) {
|
|
22
34
|
const commandProcess = buildExec(command, args, options);
|
|
23
35
|
if (options?.stderr && options.stderr !== 'inherit') {
|
|
24
36
|
commandProcess.stderr?.pipe(options.stderr);
|
|
@@ -50,8 +62,16 @@ export const exec = async (command, args, options) => {
|
|
|
50
62
|
abortError.stack = processError.stack;
|
|
51
63
|
throw abortError;
|
|
52
64
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Runs a command asynchronously.
|
|
68
|
+
*
|
|
69
|
+
* @param command - Command to be executed.
|
|
70
|
+
* @param args - Arguments to pass to the command.
|
|
71
|
+
* @param options - Optional settings for how to run the command.
|
|
72
|
+
* @returns A promise for a result with stdout and stderr properties.
|
|
73
|
+
*/
|
|
74
|
+
function buildExec(command, args, options) {
|
|
55
75
|
const env = options?.env ?? process.env;
|
|
56
76
|
if (shouldDisplayColors()) {
|
|
57
77
|
env.FORCE_COLOR = '1';
|
|
@@ -74,52 +94,12 @@ Running system process:
|
|
|
74
94
|
· Working directory: ${options?.cwd ?? process.cwd()}
|
|
75
95
|
`);
|
|
76
96
|
return commandProcess;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Runs commands concurrently and combines the standard output and error data
|
|
80
|
-
* into a single stream. See {@link renderConcurrent} for more information about
|
|
81
|
-
* the output format.
|
|
82
|
-
*
|
|
83
|
-
* If one of the processes fails, it aborts the running ones and exits with that error.
|
|
84
|
-
* @param commands - Commands to execute.
|
|
85
|
-
*/
|
|
86
|
-
export const concurrentExec = async (commands) => {
|
|
87
|
-
await renderConcurrent({
|
|
88
|
-
processes: commands.map((command) => {
|
|
89
|
-
return {
|
|
90
|
-
prefix: command.prefix,
|
|
91
|
-
action: async (stdout, stderr, signal) => {
|
|
92
|
-
await exec(command.executable, command.args, {
|
|
93
|
-
stdout,
|
|
94
|
-
stderr,
|
|
95
|
-
cwd: command.cwd,
|
|
96
|
-
signal,
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
}),
|
|
101
|
-
});
|
|
102
|
-
};
|
|
97
|
+
}
|
|
103
98
|
/**
|
|
104
|
-
*
|
|
105
|
-
* reasonable default for the user's OS:
|
|
99
|
+
* Waits for a given number of seconds.
|
|
106
100
|
*
|
|
107
|
-
* @param
|
|
101
|
+
* @param seconds - Number of seconds to wait.
|
|
108
102
|
*/
|
|
109
|
-
export async function page(filename) {
|
|
110
|
-
let executable;
|
|
111
|
-
if (process.env.PAGER) {
|
|
112
|
-
executable = process.env.PAGER;
|
|
113
|
-
}
|
|
114
|
-
else if ((await platformAndArch()).platform === 'windows') {
|
|
115
|
-
executable = 'more';
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
executable = 'less -NR';
|
|
119
|
-
}
|
|
120
|
-
const [command, ...args] = [...executable.split(' '), filename];
|
|
121
|
-
await exec(command, args, { stdout: 'inherit', stdin: 'inherit' });
|
|
122
|
-
}
|
|
123
103
|
export async function sleep(seconds) {
|
|
124
104
|
return new Promise((resolve) => {
|
|
125
105
|
setTimeout(resolve, 1000 * seconds);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAC,mBAAmB,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAC,KAAK,EAAoB,MAAM,OAAO,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAchC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,YAAY,GAAG,MAAM,MA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AAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {Abort, ExternalError} from '../../error.js'\nimport {shouldDisplayColors, debug} from '../../output.js'\nimport {execa, ExecaChildProcess} from 'execa'\nimport treeKill from 'tree-kill'\nimport type {Writable, Readable} from 'stream'\n\nexport interface ExecOptions {\n cwd?: string\n env?: {[key: string]: string | undefined}\n stdin?: Readable | 'inherit'\n stdout?: Writable | 'inherit'\n stderr?: Writable | 'inherit'\n stdio?: 'inherit'\n input?: string\n signal?: AbortSignal\n}\n\n/**\n * Opens a URL in the user's default browser.\n *\n * @param url - URL to open.\n */\nexport async function openURL(url: string): Promise<void> {\n const externalOpen = await import('open')\n await externalOpen.default(url)\n}\n\n/**\n * Runs a command asynchronously, aggregates the stdout data, and returns it.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise that resolves with the aggregatted stdout of the command.\n */\nexport async function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string> {\n const result = await buildExec(command, args, options)\n return result.stdout\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n */\nexport async function exec(command: string, args: string[], options?: ExecOptions): Promise<void> {\n const commandProcess = buildExec(command, args, options)\n if (options?.stderr && options.stderr !== 'inherit') {\n commandProcess.stderr?.pipe(options.stderr)\n }\n if (options?.stdout && options.stdout !== 'inherit') {\n commandProcess.stdout?.pipe(options.stdout)\n }\n let aborted = false\n options?.signal?.addEventListener('abort', () => {\n const pid = commandProcess.pid\n if (pid) {\n aborted = true\n treeKill(pid, (err) => {\n if (err) throw new Abort(`Failed to kill process ${pid}: ${err}`)\n })\n }\n })\n try {\n await commandProcess\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n // Windows will throw an error whenever the process is killed, no matter the reason.\n // The aborted flag tell use that we killed it, so we can ignore the error.\n if (aborted) return\n const abortError = new ExternalError(processError.message, command, args)\n abortError.stack = processError.stack\n throw abortError\n }\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise for a result with stdout and stderr properties.\n */\nfunction buildExec(command: string, args: string[], options?: ExecOptions): ExecaChildProcess<string> {\n const env = options?.env ?? process.env\n if (shouldDisplayColors()) {\n env.FORCE_COLOR = '1'\n }\n const commandProcess = execa(command, args, {\n env,\n cwd: options?.cwd,\n input: options?.input,\n stdio: options?.stdio,\n stdin: options?.stdin,\n stdout: options?.stdout === 'inherit' ? 'inherit' : undefined,\n stderr: options?.stderr === 'inherit' ? 'inherit' : undefined,\n // Setting this to false makes it possible to kill the main process\n // and all its sub-processes with Ctrl+C on Windows\n windowsHide: false,\n })\n debug(`\nRunning system process:\n · Command: ${command} ${args.join(' ')}\n · Working directory: ${options?.cwd ?? process.cwd()}\n`)\n return commandProcess\n}\n\n/**\n * Waits for a given number of seconds.\n *\n * @param seconds - Number of seconds to wait.\n */\nexport async function sleep(seconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, 1000 * seconds)\n })\n}\n"]}
|
package/dist/public/node/tcp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { sleep } from './system.js';
|
|
1
2
|
import { debug, content, token } from '../../output.js';
|
|
2
3
|
import { Abort } from '../../error.js';
|
|
3
|
-
import { sleep } from '../../system.js';
|
|
4
4
|
import * as port from 'get-port-please';
|
|
5
5
|
/**
|
|
6
6
|
* Returns an available port in the current environment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings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ent":["import {sleep} from './system.js'\nimport {debug, content, token} from '../../output.js'\nimport {Abort} from '../../error.js'\nimport * as port from 'get-port-please'\n\n/**\n * Returns an available port in the current environment.\n *\n * @returns A promise that resolves with an availabe port.\n * @example\n */\nexport async function getAvailableTCPPort(): Promise<number> {\n debug(content`Getting a random port...`)\n const randomPort = await retryOnError(() => port.getRandomPort())\n debug(content`Random port obtained: ${token.raw(`${randomPort}`)}`)\n return randomPort\n}\n\n/**\n * Given a function, it runs it and retries in case of failiure up to the provided number of times.\n *\n * @param execute - The function to execute.\n * @param maxTries - The maximum retries.\n * @param waitTimeInSeconds - The time to wait between retries.\n */\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n debug(content`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new Abort(error.message)\n }\n }\n }\n}\n"]}
|
package/dist/testing/ui.js
CHANGED
package/dist/testing/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/testing/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/testing/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,0CAA0C,CAAA;AAGjE,MAAM,UAAU,sBAAsB;IACpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;AAC3D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,gBAAmD;IACjG,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAA;QAEvC,IAAI,EAAE,CAAA;QAEN,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;YAChC,IAAI,gBAAgB,EAAE,KAAK,YAAY,EAAE;gBACvC,aAAa,CAAC,QAAQ,CAAC,CAAA;gBACvB,OAAO,EAAE,CAAA;aACV;QACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,cAAyC,EAAE,GAAG,MAAgB;IAC5F,MAAM,aAAa,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;AACnH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,cAAyC;IAChF,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,CAAA;AACxH,CAAC","sourcesContent":["import {isTruthy} from '../private/node/environment/utilities.js'\nimport {render} from 'ink-testing-library'\n\nexport function waitForInputsToBeReady() {\n return new Promise((resolve) => setTimeout(resolve, 100))\n}\n\nexport function waitForChange(func: () => void, getChangingValue: () => string | number | undefined) {\n return new Promise<void>((resolve) => {\n const initialValue = getChangingValue()\n\n func()\n\n const interval = setInterval(() => {\n if (getChangingValue() !== initialValue) {\n clearInterval(interval)\n resolve()\n }\n }, 10)\n })\n}\n\nexport async function sendInput(renderInstance: ReturnType<typeof render>, ...inputs: string[]) {\n await waitForChange(() => inputs.forEach((input) => renderInstance.stdin.write(input)), renderInstance.lastFrame)\n}\n\nexport function getLastFrameAfterUnmount(renderInstance: ReturnType<typeof render>) {\n return isTruthy(process.env.CI) ? renderInstance.frames[renderInstance.frames.length - 2] : renderInstance.lastFrame()\n}\n"]}
|