@shopify/cli-kit 3.46.0-pre.2 → 3.46.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/assets/cli-ruby/lib/graphql/get_variant_id.graphql +1 -1
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +6 -2
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/local_assets.rb +6 -6
- package/assets/cli-ruby/lib/shopify_cli/version.rb +1 -1
- package/dist/private/node/api.d.ts +1 -0
- package/dist/private/node/api.js +1 -0
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/constants.d.ts +1 -1
- package/dist/private/node/constants.js +1 -1
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/content-tokens.js +1 -1
- package/dist/private/node/content-tokens.js.map +1 -1
- package/dist/private/node/context/utilities.d.ts +14 -0
- package/dist/private/node/context/utilities.js +47 -0
- package/dist/private/node/context/utilities.js.map +1 -1
- package/dist/private/node/demo-recorder.d.ts +20 -0
- package/dist/private/node/demo-recorder.js +122 -0
- package/dist/private/node/demo-recorder.js.map +1 -0
- package/dist/private/node/session/schema.d.ts +203 -41
- package/dist/private/node/tree-kill.d.ts +1 -0
- package/dist/private/node/tree-kill.js +7 -0
- package/dist/private/node/tree-kill.js.map +1 -0
- package/dist/private/node/ui/alert.js +4 -0
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +2 -2
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +3 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +8 -4
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +33 -7
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js +23 -6
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +122 -8
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +5 -3
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +113 -0
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/List.d.ts +1 -1
- package/dist/private/node/ui/components/List.js +2 -1
- package/dist/private/node/ui/components/List.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js +19 -0
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.js +5 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js +5 -4
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.d.ts +3 -1
- package/dist/private/node/ui/components/SelectPrompt.js +4 -2
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +22 -0
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.d.ts +3 -1
- package/dist/private/node/ui/components/Tasks.js +7 -3
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +22 -1
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.d.ts +3 -0
- package/dist/private/node/ui/components/TextPrompt.js +7 -3
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +33 -0
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.d.ts +1 -1
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js +10 -0
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui/hooks/use-abort-signal.d.ts +4 -0
- package/dist/private/node/ui/hooks/use-abort-signal.js +14 -0
- package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -0
- package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +1 -1
- package/dist/private/node/ui/hooks/use-async-and-unmount.js +1 -1
- package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -1
- package/dist/private/node/ui.js +3 -3
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/cli.js +2 -0
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/colors.js.map +1 -0
- package/dist/public/node/context/local.d.ts +5 -1
- package/dist/public/node/context/local.js +8 -4
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/error-handler.js +7 -2
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.d.ts +8 -3
- package/dist/public/node/error.js +12 -5
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.d.ts +1 -0
- package/dist/public/node/hooks/prerun.js +2 -0
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/mimes.d.ts +15 -0
- package/dist/public/node/mimes.js +22 -0
- package/dist/public/node/mimes.js.map +1 -0
- package/dist/public/node/node-package-manager.d.ts +11 -0
- package/dist/public/node/node-package-manager.js +8 -6
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.d.ts +6 -1
- package/dist/public/node/output.js +6 -2
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/plugins/tunnel.d.ts +19 -4
- package/dist/public/node/plugins/tunnel.js +1 -1
- package/dist/public/node/plugins/tunnel.js.map +1 -1
- package/dist/public/node/plugins.d.ts +1 -12
- package/dist/public/node/plugins.js +0 -23
- package/dist/public/node/plugins.js.map +1 -1
- package/dist/public/node/ruby.js +2 -0
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/system.d.ts +8 -3
- package/dist/public/node/system.js +16 -7
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/ui.d.ts +18 -9
- package/dist/public/node/ui.js +83 -19
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -13
- package/dist/private/node/colors.js.map +0 -1
- /package/dist/{private → public}/node/colors.d.ts +0 -0
- /package/dist/{private → public}/node/colors.js +0 -0
|
@@ -10,7 +10,7 @@ module Extension
|
|
|
10
10
|
SUPPORTED_BUCKETS = %w(assets blocks snippets locales)
|
|
11
11
|
BUNDLE_SIZE_LIMIT = 10 * 1024 * 1024 # 10MB
|
|
12
12
|
LIQUID_SIZE_LIMIT = 100 * 1024 # 100kb
|
|
13
|
-
SUPPORTED_ASSET_EXTS = %w(.jpg .js .css .png .svg)
|
|
13
|
+
SUPPORTED_ASSET_EXTS = %w(.jpg .jpeg .js .css .png .svg)
|
|
14
14
|
SUPPORTED_LOCALE_EXTS = %w(.json)
|
|
15
15
|
|
|
16
16
|
def create(directory_name, context, getting_started: false)
|
|
@@ -21,8 +21,12 @@ module ShopifyCLI
|
|
|
21
21
|
|
|
22
22
|
# Proxy the request, and replace the URLs in the response
|
|
23
23
|
status, headers, body = @app.call(env)
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
content_type = headers["Content-Type"] || headers["content-type"]
|
|
25
|
+
if content_type.nil? || content_type == "" || content_type&.start_with?("text/")
|
|
26
|
+
[status, headers, replace_font_urls(body)]
|
|
27
|
+
else
|
|
28
|
+
[status, headers, body]
|
|
29
|
+
end
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
private
|
|
@@ -5,6 +5,7 @@ module ShopifyCLI
|
|
|
5
5
|
class DevServer
|
|
6
6
|
class LocalAssets
|
|
7
7
|
THEME_REGEX = %r{//cdn\.shopify\.com/s/.+?/(assets/.+?\.(?:css|js))}
|
|
8
|
+
VANITY_THEME_REGEX = %r{/cdn/shop/.+?/(assets/.+?\.(?:css|js))}
|
|
8
9
|
|
|
9
10
|
class FileBody
|
|
10
11
|
def initialize(path)
|
|
@@ -44,12 +45,11 @@ module ShopifyCLI
|
|
|
44
45
|
private
|
|
45
46
|
|
|
46
47
|
def replace_asset_urls(body)
|
|
47
|
-
replaced_body = body.join
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
match
|
|
48
|
+
replaced_body = body.join
|
|
49
|
+
[THEME_REGEX, VANITY_THEME_REGEX].each do |regex|
|
|
50
|
+
replaced_body = replaced_body.gsub(regex) do |match|
|
|
51
|
+
path = Regexp.last_match[1]
|
|
52
|
+
@target.static_asset_paths.include?(path) ? "/#{path}" : match
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
package/dist/private/node/api.js
CHANGED
|
@@ -10,6 +10,7 @@ export async function debugLogResponseInfo({ request, url }, errorHandler) {
|
|
|
10
10
|
let response = {};
|
|
11
11
|
try {
|
|
12
12
|
response = await request;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
14
|
response.headers.forEach((value, key) => {
|
|
14
15
|
if (interestingResponseHeaders.has(key))
|
|
15
16
|
responseHeaders[key] = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/private/node/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/private/node/api.ts"],"names":[],"mappings":"AAAA,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E;YAChB,MAAM,YAAY,CAAC,GAAG,CAAC,CAAA;SACxB;aAAM;YACL,MAAM,GAAG,CAAA;SACV;KACF;YAAS;QACR,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,WAAW,CAAC,cAAc,GAAG,iBAAiB,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;;EAEnE,sBAAsB,CAAC,eAAe,CAAC;KACpC,CAAC,CAAA;KACH;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {sanitizedHeadersOutput} from './api/headers.js'\nimport {outputDebug} from '@shopify/cli-kit/node/output'\nimport {Headers} from 'form-data'\nimport {ClientError} from 'graphql-request'\nimport {performance} from 'perf_hooks'\n\nexport type API = 'admin' | 'storefront-renderer' | 'partners'\n\nexport const allAPIs: API[] = ['admin', 'storefront-renderer', 'partners']\n\ninterface RequestOptions<T> {\n request: Promise<T>\n url: string\n}\n\nconst interestingResponseHeaders = new Set(['cache-control', 'content-type', 'etag', 'x-request-id'])\n\nexport async function debugLogResponseInfo<T extends {headers: Headers; status: number}>(\n {request, url}: RequestOptions<T>,\n errorHandler?: (error: unknown) => Error | unknown,\n): Promise<T> {\n const t0 = performance.now()\n const responseHeaders: {[key: string]: string} = {}\n let response: T = {} as T\n try {\n response = await request\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n response.headers.forEach((value: any, key: any) => {\n if (interestingResponseHeaders.has(key)) responseHeaders[key] = value\n })\n } catch (err) {\n if (err instanceof ClientError) {\n if (err.response?.headers) {\n for (const [key, value] of err.response?.headers as Iterable<[string, string]>) {\n if (interestingResponseHeaders.has(key)) responseHeaders[key] = value\n }\n }\n }\n if (errorHandler) {\n throw errorHandler(err)\n } else {\n throw err\n }\n } finally {\n const t1 = performance.now()\n outputDebug(`Request to ${url} completed in ${Math.round(t1 - t0)} ms\nWith response headers:\n${sanitizedHeadersOutput(responseHeaders)}\n `)\n }\n return response\n}\n"]}
|
|
@@ -21,7 +21,7 @@ export const environmentVariables = {
|
|
|
21
21
|
themeToken: 'SHOPIFY_CLI_THEME_TOKEN',
|
|
22
22
|
unitTest: 'SHOPIFY_UNIT_TEST',
|
|
23
23
|
verbose: 'SHOPIFY_FLAG_VERBOSE',
|
|
24
|
-
|
|
24
|
+
noThemeBundling: 'SHOPIFY_CLI_NO_THEME_BUNDLING',
|
|
25
25
|
// Variables to detect if the CLI is running in a cloud environment
|
|
26
26
|
codespaceName: 'CODESPACE_NAME',
|
|
27
27
|
codespaces: 'CODESPACES',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/private/node/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAA;AAClD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACjE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,kBAAkB,EAAE,kCAAkC;IACtD,UAAU,EAAE,yBAAyB;IACrC,iBAAiB,EAAE,iCAAiC;IACpD,GAAG,EAAE,iBAAiB;IACtB,aAAa,EAAE,oBAAoB;IACnC,WAAW,EAAE,0BAA0B;IACvC,aAAa,EAAE,4BAA4B;IAC3C,SAAS,EAAE,qBAAqB;IAChC,UAAU,EAAE,qBAAqB;IACjC,eAAe,EAAE,+BAA+B;IAChD,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,yBAAyB;IACrC,QAAQ,EAAE,mBAAmB;IAC7B,OAAO,EAAE,sBAAsB;IAC/B,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":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AE,kBAAkB;KACxB;IACD,WAAW,EAAE;QACX,KAAK,EAAE;YACL,IAAI,EAAE,GAAG,EAAE;gBACT,OAAO,WAAW,EAAE,CAAA;YACtB,CAAC;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,GAAG,EAAE;oBACT,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;gBAC1C,CAAC;gBACD,QAAQ,EAAE,GAAG,EAAE;oBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;gBACtD,CAAC;aACF;SACF;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,aAAa;CACvB,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,6BAA6B,EAAE,CAAC;CACjC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA","sourcesContent":["import {joinPath} from '../../public/node/path.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nexport const environmentVariables = {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinInstance: 'SPIN_INSTANCE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n noThemeBundling: 'SHOPIFY_CLI_NO_THEME_BUNDLING',\n // Variables to detect if the CLI is running in a cloud environment\n codespaceName: 'CODESPACE_NAME',\n codespaces: 'CODESPACES',\n gitpod: 'GITPOD_WORKSPACE_URL',\n cloudShell: 'CLOUD_SHELL',\n spin: 'SPIN',\n spinAppPort: 'SERVER_PORT',\n spinAppHost: 'SPIN_APP_HOST',\n organization: 'SHOPIFY_CLI_ORGANIZATION',\n identityToken: 'SHOPIFY_CLI_IDENTITY_TOKEN',\n refreshToken: 'SHOPIFY_CLI_REFRESH_TOKEN',\n}\n\nexport const systemEnvironmentVariables = {\n backendPort: 'BACKEND_PORT',\n}\n\nexport const pathConstants = {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return joinPath(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return joinPath(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n}\n\nexport const keychainConstants = {\n service: 'shopify-cli',\n}\n\nexport const sessionConstants = {\n expirationTimeMarginInMinutes: 4,\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../../../src/private/node/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../../../src/private/node/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAgB,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAA;AACxD,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,O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CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAA2B;IAC/D,MAAM;QACJ,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,YAA2B;IAClE,MAAM;QACJ,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAA2B;IACrE,MAAM;QACJ,OAAO,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAA2B;IACjE,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import colors from '../../public/node/colors.js'\nimport {OutputMessage, stringifyMessage} from '../../public/node/output.js'\nimport {relativizePath} from '../../public/node/path.js'\nimport terminalLink from 'terminal-link'\nimport cjs from 'color-json'\nimport type {Change} from 'diff'\n\nexport abstract class ContentToken<T> {\n value: T\n\n constructor(value: T) {\n this.value = value\n }\n\n abstract output(): string | string[]\n}\n\nexport class RawContentToken extends ContentToken<string> {\n output(): string {\n return this.value\n }\n}\n\nexport class LinkContentToken extends ContentToken<OutputMessage> {\n link: string\n\n constructor(value: OutputMessage, link: string) {\n super(value)\n this.link = link\n }\n\n output() {\n const text = colors.green(stringifyMessage(this.value))\n const url = this.link ?? ''\n return terminalLink(text, url, {fallback: () => `${text} ( ${url} )`})\n }\n}\n\nexport class CommandContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold(colors.yellow(stringifyMessage(this.value)))\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class JsonContentToken extends ContentToken<any> {\n output(): string {\n try {\n return cjs(stringifyMessage(this.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n return JSON.stringify(stringifyMessage(this.value) ?? {}, null, 2)\n }\n }\n}\n\nexport class LinesDiffContentToken extends ContentToken<Change[]> {\n output(): string[] {\n return this.value\n .map((part) => {\n if (part.added) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.green(`+ ${line}\\n`)\n })\n } else if (part.removed) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.magenta(`- ${line}\\n`)\n })\n } else {\n return part.value\n }\n })\n .flat()\n }\n}\n\nexport class ColorContentToken extends ContentToken<OutputMessage> {\n color: (text: string) => string\n\n constructor(value: OutputMessage, color: (text: string) => string) {\n super(value)\n this.color = color\n }\n\n output(): string {\n return this.color(stringifyMessage(this.value))\n }\n}\n\nexport class ErrorContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold.redBright(stringifyMessage(this.value))\n }\n}\n\nexport class PathContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return relativizePath(stringifyMessage(this.value))\n }\n}\n\nexport class HeadingContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold.underline(stringifyMessage(this.value))\n }\n}\n\nexport class SubHeadingContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.underline(stringifyMessage(this.value))\n }\n}\n\nexport class ItalicContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.italic(stringifyMessage(this.value))\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
1
2
|
/**
|
|
2
3
|
* Returns whether an environment variable value represents a truthy value.
|
|
3
4
|
*/
|
|
@@ -6,3 +7,16 @@ export declare function isTruthy(variable: string | undefined): boolean;
|
|
|
6
7
|
* Returns whether an environment variable has been set and is non-empty
|
|
7
8
|
*/
|
|
8
9
|
export declare function isSet(variable: string | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Returns an object with environment variables from the specified CI environment.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getCIMetadata(envName: string, envs: NodeJS.ProcessEnv): Metadata;
|
|
14
|
+
export interface Metadata {
|
|
15
|
+
actor?: string;
|
|
16
|
+
branch?: string;
|
|
17
|
+
build?: string;
|
|
18
|
+
commitMessage?: string;
|
|
19
|
+
commitSha?: string;
|
|
20
|
+
run?: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
}
|
|
@@ -16,4 +16,51 @@ export function isSet(variable) {
|
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns an object with environment variables from the specified CI environment.
|
|
21
|
+
*/
|
|
22
|
+
export function getCIMetadata(envName, envs) {
|
|
23
|
+
switch (envName) {
|
|
24
|
+
case 'bitbucket':
|
|
25
|
+
return {
|
|
26
|
+
actor: envs.BITBUCKET_COMMIT_AUTHOR,
|
|
27
|
+
branch: envs.BITBUCKET_BRANCH,
|
|
28
|
+
build: envs.BITBUCKET_BUILD_NUMBER,
|
|
29
|
+
commitSha: envs.BITBUCKET_COMMIT,
|
|
30
|
+
run: envs.BITBUCKET_BUILD_NUMBER,
|
|
31
|
+
url: envs.BITBUCKET_BUILD_URL,
|
|
32
|
+
};
|
|
33
|
+
case 'circleci':
|
|
34
|
+
return {
|
|
35
|
+
actor: envs.CIRCLE_USERNAME,
|
|
36
|
+
branch: envs.CIRCLE_BRANCH,
|
|
37
|
+
build: envs.CIRCLE_BUILD_NUM,
|
|
38
|
+
commitSha: envs.CIRCLE_SHA1,
|
|
39
|
+
run: envs.CIRCLE_WORKFLOW_ID,
|
|
40
|
+
url: envs.CIRCLE_BUILD_URL,
|
|
41
|
+
};
|
|
42
|
+
case 'github':
|
|
43
|
+
return {
|
|
44
|
+
actor: envs.GITHUB_ACTOR,
|
|
45
|
+
branch: envs.GITHUB_REF_NAME,
|
|
46
|
+
build: envs.GITHUB_RUN_ID,
|
|
47
|
+
commitMessage: envs.GITHUB_COMMIT_MESSAGE,
|
|
48
|
+
commitSha: envs.GITHUB_SHA,
|
|
49
|
+
run: envs.GITHUB_RUN_ID,
|
|
50
|
+
url: `${envs.GITHUB_SERVER_URL}${envs.GITHUB_REPOSITORY}/actions/runs/${envs.GITHUB_RUN_ID}`,
|
|
51
|
+
};
|
|
52
|
+
case 'gitlab':
|
|
53
|
+
return {
|
|
54
|
+
actor: envs.GITLAB_USER_LOGIN,
|
|
55
|
+
branch: envs.CI_COMMIT_REF_NAME,
|
|
56
|
+
build: envs.CI_PIPELINE_ID,
|
|
57
|
+
commitSha: envs.CI_COMMIT_SHA,
|
|
58
|
+
commitMessage: envs.CI_COMMIT_MESSAGE,
|
|
59
|
+
run: envs.CI_RUNNER_ID,
|
|
60
|
+
url: envs.CI_PROJECT_URL,
|
|
61
|
+
};
|
|
62
|
+
default:
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
19
66
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/private/node/context/utilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,QAA4B;IAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n\n/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/private/node/context/utilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,QAA4B;IAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,IAAuB;IACpE,QAAQ,OAAO,EAAE;QACf,KAAK,WAAW;YACd,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,uBAAuB;gBACnC,MAAM,EAAE,IAAI,CAAC,gBAAgB;gBAC7B,KAAK,EAAE,IAAI,CAAC,sBAAsB;gBAClC,SAAS,EAAE,IAAI,CAAC,gBAAgB;gBAChC,GAAG,EAAE,IAAI,CAAC,sBAAsB;gBAChC,GAAG,EAAE,IAAI,CAAC,mBAAmB;aAC9B,CAAA;QACH,KAAK,UAAU;YACb,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,eAAe;gBAC3B,MAAM,EAAE,IAAI,CAAC,aAAa;gBAC1B,KAAK,EAAE,IAAI,CAAC,gBAAgB;gBAC5B,SAAS,EAAE,IAAI,CAAC,WAAW;gBAC3B,GAAG,EAAE,IAAI,CAAC,kBAAkB;gBAC5B,GAAG,EAAE,IAAI,CAAC,gBAAgB;aAC3B,CAAA;QACH,KAAK,QAAQ;YACX,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,YAAY;gBACxB,MAAM,EAAE,IAAI,CAAC,eAAe;gBAC5B,KAAK,EAAE,IAAI,CAAC,aAAa;gBACzB,aAAa,EAAE,IAAI,CAAC,qBAAqB;gBACzC,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,GAAG,EAAE,IAAI,CAAC,aAAa;gBACvB,GAAG,EAAE,GAAG,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,iBAAiB,IAAI,CAAC,aAAa,EAAE;aAC7F,CAAA;QACH,KAAK,QAAQ;YACX,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,iBAAiB;gBAC7B,MAAM,EAAE,IAAI,CAAC,kBAAkB;gBAC/B,KAAK,EAAE,IAAI,CAAC,cAAc;gBAC1B,SAAS,EAAE,IAAI,CAAC,aAAa;gBAC7B,aAAa,EAAE,IAAI,CAAC,iBAAiB;gBACrC,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,GAAG,EAAE,IAAI,CAAC,cAAc;aACzB,CAAA;QACH;YACE,OAAO,EAAE,CAAA;KACZ;AACH,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n\n/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n\n/**\n * Returns an object with environment variables from the specified CI environment.\n */\nexport function getCIMetadata(envName: string, envs: NodeJS.ProcessEnv): Metadata {\n switch (envName) {\n case 'bitbucket':\n return {\n actor: envs.BITBUCKET_COMMIT_AUTHOR,\n branch: envs.BITBUCKET_BRANCH,\n build: envs.BITBUCKET_BUILD_NUMBER,\n commitSha: envs.BITBUCKET_COMMIT,\n run: envs.BITBUCKET_BUILD_NUMBER,\n url: envs.BITBUCKET_BUILD_URL,\n }\n case 'circleci':\n return {\n actor: envs.CIRCLE_USERNAME,\n branch: envs.CIRCLE_BRANCH,\n build: envs.CIRCLE_BUILD_NUM,\n commitSha: envs.CIRCLE_SHA1,\n run: envs.CIRCLE_WORKFLOW_ID,\n url: envs.CIRCLE_BUILD_URL,\n }\n case 'github':\n return {\n actor: envs.GITHUB_ACTOR,\n branch: envs.GITHUB_REF_NAME,\n build: envs.GITHUB_RUN_ID,\n commitMessage: envs.GITHUB_COMMIT_MESSAGE,\n commitSha: envs.GITHUB_SHA,\n run: envs.GITHUB_RUN_ID,\n url: `${envs.GITHUB_SERVER_URL}${envs.GITHUB_REPOSITORY}/actions/runs/${envs.GITHUB_RUN_ID}`,\n }\n case 'gitlab':\n return {\n actor: envs.GITLAB_USER_LOGIN,\n branch: envs.CI_COMMIT_REF_NAME,\n build: envs.CI_PIPELINE_ID,\n commitSha: envs.CI_COMMIT_SHA,\n commitMessage: envs.CI_COMMIT_MESSAGE,\n run: envs.CI_RUNNER_ID,\n url: envs.CI_PROJECT_URL,\n }\n default:\n return {}\n }\n}\n\nexport interface Metadata {\n actor?: string\n branch?: string\n build?: string\n commitMessage?: string\n commitSha?: string\n run?: string\n url?: string\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ConcurrentOutputProps } from './ui/components/ConcurrentOutput.js';
|
|
2
|
+
interface Event {
|
|
3
|
+
type: string;
|
|
4
|
+
properties: {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
concurrencyStart?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function initDemoRecorder(): void;
|
|
10
|
+
export declare function recordUIEvent(event: Event): void;
|
|
11
|
+
export declare function resetRecordedSleep(): void;
|
|
12
|
+
export declare function printEventsJson(): void;
|
|
13
|
+
export declare function addOrUpdateConcurrentUIEventOutput(data: {
|
|
14
|
+
prefix: string;
|
|
15
|
+
index: number;
|
|
16
|
+
output: string;
|
|
17
|
+
}, componentData: {
|
|
18
|
+
footer: ConcurrentOutputProps['footer'];
|
|
19
|
+
}): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isTruthy } from './context/utilities.js';
|
|
2
|
+
class DemoRecorder {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.recorded = [];
|
|
5
|
+
this.sleepStart = Date.now();
|
|
6
|
+
this.command = ['shopify', ...process.argv.slice(2)].join(' ');
|
|
7
|
+
}
|
|
8
|
+
addEvent({ type, properties }) {
|
|
9
|
+
if (type === 'taskbar') {
|
|
10
|
+
this.resetSleep();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.addSleep();
|
|
14
|
+
}
|
|
15
|
+
this.recorded.push({ type, properties: JSON.parse(JSON.stringify(properties)) });
|
|
16
|
+
this.sleepStart = Date.now();
|
|
17
|
+
}
|
|
18
|
+
recordedEventsJson() {
|
|
19
|
+
return JSON.stringify({
|
|
20
|
+
command: this.command,
|
|
21
|
+
steps: this.withFormattedConcurrent(this.recorded),
|
|
22
|
+
}, null, 2);
|
|
23
|
+
}
|
|
24
|
+
addSleep() {
|
|
25
|
+
const duration = (Date.now() - this.sleepStart) / 1000;
|
|
26
|
+
this.sleepStart = Date.now();
|
|
27
|
+
if (duration > 0.1) {
|
|
28
|
+
this.recorded.push({ type: 'sleep', properties: { duration } });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
resetSleep() {
|
|
32
|
+
this.sleepStart = Date.now();
|
|
33
|
+
}
|
|
34
|
+
addOrUpdateConcurrentOutput({ prefix, index, output, }, { footer }) {
|
|
35
|
+
let last = this.recorded[this.recorded.length - 1];
|
|
36
|
+
if (last?.type === 'concurrent') {
|
|
37
|
+
// Don't sleep between concurrent lines
|
|
38
|
+
this.resetSleep();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const eventProperties = {
|
|
42
|
+
type: 'concurrent',
|
|
43
|
+
properties: { processes: [], concurrencyStart: Date.now() },
|
|
44
|
+
};
|
|
45
|
+
if (footer)
|
|
46
|
+
eventProperties.properties.footer = footer;
|
|
47
|
+
this.addEvent(eventProperties);
|
|
48
|
+
last = this.recorded[this.recorded.length - 1];
|
|
49
|
+
}
|
|
50
|
+
const { processes } = last.properties;
|
|
51
|
+
while (processes.length <= index) {
|
|
52
|
+
processes.push({ prefix: '', steps: [] });
|
|
53
|
+
}
|
|
54
|
+
processes[index].prefix = prefix;
|
|
55
|
+
processes[index].steps.push({ timestamp: Date.now(), endMessage: output });
|
|
56
|
+
}
|
|
57
|
+
withFormattedConcurrent(recorded) {
|
|
58
|
+
return recorded.map((event) => {
|
|
59
|
+
if (event.type === 'concurrent') {
|
|
60
|
+
const { processes, footer, concurrencyStart } = event.properties;
|
|
61
|
+
const formatted = processes.map(({ prefix, steps }) => {
|
|
62
|
+
let mostRecentTimestamp = concurrencyStart;
|
|
63
|
+
const formattedSteps = steps.map(({ timestamp, endMessage }) => {
|
|
64
|
+
const duration = (timestamp - mostRecentTimestamp) / 1000;
|
|
65
|
+
mostRecentTimestamp = timestamp;
|
|
66
|
+
return { duration, endMessage };
|
|
67
|
+
});
|
|
68
|
+
return { prefix, steps: formattedSteps };
|
|
69
|
+
});
|
|
70
|
+
return { type: 'concurrent', properties: { footer, processes: formatted } };
|
|
71
|
+
}
|
|
72
|
+
return event;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class NoopDemoRecorder {
|
|
77
|
+
addEvent(_event) { }
|
|
78
|
+
recordedEventsJson() {
|
|
79
|
+
return JSON.stringify({ steps: [] }, null, 2);
|
|
80
|
+
}
|
|
81
|
+
addSleep() { }
|
|
82
|
+
resetSleep() { }
|
|
83
|
+
addOrUpdateConcurrentOutput(..._args) { }
|
|
84
|
+
}
|
|
85
|
+
let _instance;
|
|
86
|
+
function ensureInstance() {
|
|
87
|
+
if (!_instance) {
|
|
88
|
+
if (isRecording()) {
|
|
89
|
+
_instance = new DemoRecorder();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
_instance = new NoopDemoRecorder();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function initDemoRecorder() {
|
|
97
|
+
ensureInstance();
|
|
98
|
+
}
|
|
99
|
+
export function recordUIEvent(event) {
|
|
100
|
+
ensureInstance();
|
|
101
|
+
_instance.addEvent(event);
|
|
102
|
+
}
|
|
103
|
+
export function resetRecordedSleep() {
|
|
104
|
+
ensureInstance();
|
|
105
|
+
_instance.resetSleep();
|
|
106
|
+
}
|
|
107
|
+
export function printEventsJson() {
|
|
108
|
+
if (isRecording()) {
|
|
109
|
+
ensureInstance();
|
|
110
|
+
_instance.addSleep();
|
|
111
|
+
// eslint-disable-next-line no-console
|
|
112
|
+
console.log(_instance.recordedEventsJson());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export function addOrUpdateConcurrentUIEventOutput(data, componentData) {
|
|
116
|
+
ensureInstance();
|
|
117
|
+
_instance.addOrUpdateConcurrentOutput(data, componentData);
|
|
118
|
+
}
|
|
119
|
+
function isRecording() {
|
|
120
|
+
return isTruthy(process.env.RECORD_DEMO);
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=demo-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo-recorder.js","sourceRoot":"","sources":["../../../src/private/node/demo-recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAoB/C,MAAM,YAAY;IAKhB;QACE,IAAI,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AAW,EAAE,EAAE;YACjB,SAAS,GAAG,IAAI,YAAY,EAAE,CAAA;SAC/B;aAAM;YACL,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAA;SACnC;KACF;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,cAAc,EAAE,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,cAAc,EAAE,CAAA;IAChB,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,cAAc,EAAE,CAAA;IAChB,SAAS,CAAC,UAAU,EAAE,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,WAAW,EAAE,EAAE;QACjB,cAAc,EAAE,CAAA;QAChB,SAAS,CAAC,QAAQ,EAAE,CAAA;QACpB,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAA;KAC5C;AACH,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,IAIC,EACD,aAAwD;IAExD,cAAc,EAAE,CAAA;IAChB,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;AAC5D,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {isTruthy} from './context/utilities.js'\nimport {ConcurrentOutputProps} from './ui/components/ConcurrentOutput.js'\n\ninterface Event {\n type: string\n properties: {[key: string]: unknown}\n // Only used within this recorder for tracking concurrency timeline\n concurrencyStart?: number\n}\n\ninterface ConcurrencyStep {\n timestamp: number\n endMessage: string\n}\n\ninterface ConcurrencyProcess {\n prefix: string\n steps: ConcurrencyStep[]\n}\n\nclass DemoRecorder {\n recorded: Event[]\n sleepStart: number\n command: string\n\n constructor() {\n this.recorded = []\n this.sleepStart = Date.now()\n this.command = ['shopify', ...process.argv.slice(2)].join(' ')\n }\n\n addEvent({type, properties}: Event) {\n if (type === 'taskbar') {\n this.resetSleep()\n } else {\n this.addSleep()\n }\n this.recorded.push({type, properties: JSON.parse(JSON.stringify(properties))})\n this.sleepStart = Date.now()\n }\n\n recordedEventsJson() {\n return JSON.stringify(\n {\n command: this.command,\n steps: this.withFormattedConcurrent(this.recorded),\n },\n null,\n 2,\n )\n }\n\n addSleep() {\n const duration = (Date.now() - this.sleepStart) / 1000\n this.sleepStart = Date.now()\n if (duration > 0.1) {\n this.recorded.push({type: 'sleep', properties: {duration}})\n }\n }\n\n resetSleep() {\n this.sleepStart = Date.now()\n }\n\n addOrUpdateConcurrentOutput(\n {\n prefix,\n index,\n output,\n }: {\n prefix: string\n index: number\n output: string\n },\n {footer}: {footer: ConcurrentOutputProps['footer']},\n ) {\n let last = this.recorded[this.recorded.length - 1]\n if (last?.type === 'concurrent') {\n // Don't sleep between concurrent lines\n this.resetSleep()\n } else {\n const eventProperties: Event = {\n type: 'concurrent',\n properties: {processes: [], concurrencyStart: Date.now()},\n }\n if (footer) eventProperties.properties.footer = footer\n this.addEvent(eventProperties)\n last = this.recorded[this.recorded.length - 1]\n }\n const {processes} = last!.properties as {processes: ConcurrencyProcess[]}\n while (processes.length <= index) {\n processes.push({prefix: '', steps: []})\n }\n processes[index]!.prefix = prefix\n processes[index]!.steps.push({timestamp: Date.now(), endMessage: output})\n }\n\n withFormattedConcurrent(recorded: Event[]) {\n return recorded.map((event) => {\n if (event.type === 'concurrent') {\n const {processes, footer, concurrencyStart} = event.properties as {\n processes: ConcurrencyProcess[]\n footer?: string\n concurrencyStart: number\n }\n const formatted = processes.map(({prefix, steps}: {prefix: string; steps: ConcurrencyStep[]}) => {\n let mostRecentTimestamp = concurrencyStart\n const formattedSteps = steps.map(({timestamp, endMessage}) => {\n const duration = (timestamp - mostRecentTimestamp) / 1000\n mostRecentTimestamp = timestamp\n return {duration, endMessage}\n })\n return {prefix, steps: formattedSteps}\n })\n return {type: 'concurrent', properties: {footer, processes: formatted}}\n }\n return event\n })\n }\n}\n\nclass NoopDemoRecorder {\n addEvent(_event: Event) {}\n\n recordedEventsJson() {\n return JSON.stringify({steps: []}, null, 2)\n }\n\n addSleep() {}\n resetSleep() {}\n\n addOrUpdateConcurrentOutput(..._args: unknown[]) {}\n}\n\nlet _instance: {\n addEvent: (event: Event) => void\n recordedEventsJson: () => string\n resetSleep: () => void\n addSleep: () => void\n addOrUpdateConcurrentOutput: (\n {\n prefix,\n index,\n output,\n }: {\n prefix: string\n index: number\n output: string\n },\n {footer}: {footer: ConcurrentOutputProps['footer']},\n ) => void\n}\n\nfunction ensureInstance() {\n if (!_instance) {\n if (isRecording()) {\n _instance = new DemoRecorder()\n } else {\n _instance = new NoopDemoRecorder()\n }\n }\n}\n\nexport function initDemoRecorder() {\n ensureInstance()\n}\n\nexport function recordUIEvent(event: Event) {\n ensureInstance()\n _instance.addEvent(event)\n}\n\nexport function resetRecordedSleep() {\n ensureInstance()\n _instance.resetSleep()\n}\n\nexport function printEventsJson(): void {\n if (isRecording()) {\n ensureInstance()\n _instance.addSleep()\n // eslint-disable-next-line no-console\n console.log(_instance.recordedEventsJson())\n }\n}\n\nexport function addOrUpdateConcurrentUIEventOutput(\n data: {\n prefix: string\n index: number\n output: string\n },\n componentData: {footer: ConcurrentOutputProps['footer']},\n) {\n ensureInstance()\n _instance.addOrUpdateConcurrentOutput(data, componentData)\n}\n\nfunction isRecording() {\n return isTruthy(process.env.RECORD_DEMO)\n}\n"]}
|