@shopify/cli-kit 3.31.1 → 3.32.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/README.md +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/index.d.ts +0 -3
- package/dist/index.js +0 -3
- 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/os.d.ts +4 -3
- package/dist/os.js +3 -4
- package/dist/os.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/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/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 +34 -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 +1 -1
- 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 +1 -1
- package/dist/public/common/object.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/archiver.js +1 -1
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js.map +1 -1
- 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/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/presets.d.ts +1 -1
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +2 -2
- package/dist/public/node/ruby.js +2 -2
- package/dist/public/node/ruby.js.map +1 -1
- 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/session/authorize.js +1 -1
- package/dist/session/authorize.js.map +1 -1
- package/dist/session/redirect-listener.js +6 -3
- package/dist/session/redirect-listener.js.map +1 -1
- package/dist/system.d.ts +2 -2
- 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.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 +29 -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/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/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/os.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"os.js","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAC,QAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"os.js","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAC,MAAM,IAAI,CAAA;AAEzD,MAAM,sBAAsB,GAAG,GAAG,EAAE;IAClC,MAAM,EAAC,GAAG,EAAC,GAAG,OAAO,CAAA;IAErB,OAAO,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAA;AAC7F,CAAC,CAAA;AAED,MAAM,yBAAyB,GAAG,GAAkB,EAAE;IACpD,IAAI;QACF,OAAO,UAAU,EAAE,CAAC,QAAQ,CAAA;QAC5B,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,E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B,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,IAAI,GAAG,OAAO,CAAA;KACf;IACD,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,IAAI,GAAG,KAAK,CAAA;KACb;IACD,IAAI,cAAc,GAAG,QAAkB,CAAA;IACvC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC5B,cAAc,GAAG,SAAS,CAAA;KAC3B;IACD,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAC,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import {debug, content} from './output.js'\nimport {execa} from 'execa'\nimport {userInfo as osUserInfo, arch as osArch} from 'os'\n\nconst getEnvironmentVariable = () => {\n const {env} = process\n\n return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME\n}\n\nconst getUsernameFromOsUserInfo = (): string | null => {\n try {\n return osUserInfo().username\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\nconst cleanWindowsCommand = (value: string) => value.replace(/^.*\\\\/, '')\n\nconst makeUsernameFromId = (userId: string) => `no-username-${userId}`\n\n// This code has been vendored from https://github.com/sindresorhus/username\n// because adding it as a transtive dependency causes conflicts with other\n// packages that haven't been yet migrated to the latest version.\nexport const username = async (platform: typeof process.platform = process.platform): Promise<string | null> => {\n debug(content`Obtaining user name...`)\n const environmentVariable = getEnvironmentVariable()\n if (environmentVariable) {\n return environmentVariable\n }\n\n const userInfoUsername = getUsernameFromOsUserInfo()\n if (userInfoUsername) {\n return userInfoUsername\n }\n\n /**\n\tFirst we try to get the ID of the user and then the actual username. We do this because in `docker run --user <uid>:<gid>` context, we don't have \"username\" available. Therefore, we have a fallback to `makeUsernameFromId` for such scenario. Applies also to the `sync()` method below.\n\t*/\n try {\n if (platform === 'win32') {\n const {stdout} = await execa('whoami')\n return cleanWindowsCommand(stdout)\n }\n\n const {stdout: userId} = await execa('id', ['-u'])\n try {\n const {stdout} = await execa('id', ['-un', userId])\n return stdout\n\n // eslint-disable-next-line no-catch-all/no-catch-all,no-empty\n } catch {}\n return makeUsernameFromId(userId)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\n/**\n * Returns the platform and architecture.\n * @returns Returns the current platform and architecture.\n */\nexport const platformAndArch = (\n platform: typeof process.platform = process.platform,\n): {platform: string; arch: string} => {\n let arch = osArch()\n if (arch === 'x64') {\n arch = 'amd64'\n }\n if (arch === 'ia32') {\n arch = '386'\n }\n let platformString = platform as string\n if (platform.match(/^win.+/)) {\n platformString = 'windows'\n }\n return {platform: platformString, arch}\n}\n"]}
|
package/dist/output.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PackageManager } from './public/node/node-package-manager.js';
|
|
3
3
|
import { ColorContentToken, CommandContentToken, ContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken } from './content-tokens.js';
|
|
4
|
-
import { AbortSignal } from 'abort
|
|
5
|
-
import { Writable } from '
|
|
4
|
+
import { AbortSignal } from '@shopify/cli-kit/node/abort';
|
|
5
|
+
import { Writable } from 'stream';
|
|
6
6
|
import type { Change } from 'diff';
|
|
7
7
|
export { default as logUpdate } from 'log-update';
|
|
8
8
|
export declare type Logger = Writable | ((message: string) => void);
|
package/dist/output.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isUnitTest, isVerbose } from './environment/local.js';
|
|
|
3
3
|
import colors from './public/node/colors.js';
|
|
4
4
|
import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from './content-tokens.js';
|
|
5
5
|
import stripAnsi from 'strip-ansi';
|
|
6
|
-
import { Writable } from '
|
|
6
|
+
import { Writable } from 'stream';
|
|
7
7
|
export { default as logUpdate } from 'log-update';
|
|
8
8
|
export class TokenizedString {
|
|
9
9
|
constructor(value) {
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAGpC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,YAAY,CAAA;AAI/C,MAAM,OAAO,eAAe;IAE1B,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAID,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,CAAC,KAAa,EAAE,EAAE;QACrB,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IACD,mBAAmB,EAAE,CAAC,KAAc,EAAE,EAAE;QACtC,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC;IACD,8DAA8D;IAC9D,IAAI,EAAE,CAAC,KAAU,EAAE,EAAE;QACnB,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,IAAI,EAAE,CAAC,KAAc,EAAE,EAAE;QACvB,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,IAAI,EAAE,CAAC,K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M;QACL,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;KACzB;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAsD,EACtD,OAAe;IAEf,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAChF,OAAO,OAAO,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\n },\n}\n\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport const collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,YAAY,CAAA;AAI/C,MAAM,OAAO,eAAe;IAE1B,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAID,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,CAAC,KAAa,EAAE,EAAE;QACrB,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IACD,mBAAmB,EAAE,CAAC,KAAc,EAAE,EAAE;QACtC,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC;IACD,8DAA8D;IAC9D,IAAI,EAAE,CAAC,KAAU,EAAE,EAAE;QACnB,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,IAAI,EA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B;KACF;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe;IACzC,IAAI,mBAAmB,EAAE,EAAE;QACzB,OAAO,OAAO,CAAA;KACf;SAAM;QACL,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;KACzB;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAsD,EACtD,OAAe;IAEf,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAChF,OAAO,OAAO,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport stripAnsi from 'strip-ansi'\nimport {AbortSignal} from '@shopify/cli-kit/node/abort'\nimport {Writable} from 'stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\n },\n}\n\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport const collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
package/dist/path.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { OverloadParameters } from './typing/overloaded-parameters.js';
|
|
2
3
|
import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse } from 'pathe';
|
|
3
4
|
import { findUp as internalFindUp } from 'find-up';
|
|
5
|
+
import type { URL } from 'url';
|
|
4
6
|
import type { Pattern, Options } from 'fast-glob';
|
|
5
7
|
export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse };
|
|
6
8
|
export declare function glob(pattern: Pattern | Pattern[], options?: Options): Promise<string[]>;
|
|
7
|
-
export { pathToFileURL } from '
|
|
9
|
+
export { pathToFileURL } from 'url';
|
|
8
10
|
export declare function findUp(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
|
|
9
11
|
/**
|
|
10
12
|
* Given an absolute filesystem path, it makes it relative to
|
package/dist/path.js
CHANGED
|
@@ -9,9 +9,9 @@ export async function glob(pattern, options) {
|
|
|
9
9
|
if (options?.dot == null) {
|
|
10
10
|
overridenOptions = { ...options, dot: true };
|
|
11
11
|
}
|
|
12
|
-
return fastGlob(pattern,
|
|
12
|
+
return fastGlob(pattern, overridenOptions);
|
|
13
13
|
}
|
|
14
|
-
export { pathToFileURL } from '
|
|
14
|
+
export { pathToFileURL } from 'url';
|
|
15
15
|
export async function findUp(matcher, options) {
|
|
16
16
|
// findUp has odd typing
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/dist/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,OAAO,CAAA;AACvG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,OAAO,CAAA;AACvG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAKjC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,CAAA;AAE1F,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAA4B,EAAE,OAAiB;IACxE,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAA;IACrD,IAAI,gBAAgB,GAAG,OAAO,CAAA;IAC9B,IAAI,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE;QACxB,gBAAgB,GAAG,EAAC,GAAG,OAAO,EAAE,GAAG,EAAE,IAAI,EAAC,CAAA;KAC3C;IACD,OAAO,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AAC5C,CAAC;AACD,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAEjC,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAqD,EACrD,OAAqD;IAErD,wBAAwB;IACxB,8DAA8D;IAC9D,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,OAAc,EAAE,OAAO,CAAC,CAAA;IACzD,OAAO,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;IAClD,MAAM,kBAAkB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,MAAM,CAAA;IACnG,IAAI,MAAM,KAAK,GAAG,IAAI,YAAY,KAAK,EAAE,IAAI,kBAAkB,GAAG,CAAC,EAAE;QACnE,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {OverloadParameters} from './typing/overloaded-parameters.js'\nimport commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse} from 'pathe'\nimport {findUp as internalFindUp} from 'find-up'\nimport {fileURLToPath} from 'url'\n// eslint-disable-next-line node/prefer-global/url\nimport type {URL} from 'url'\nimport type {Pattern, Options} from 'fast-glob'\n\nexport {join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse}\n\nexport async function glob(pattern: Pattern | Pattern[], options?: Options): Promise<string[]> {\n const {default: fastGlob} = await import('fast-glob')\n let overridenOptions = options\n if (options?.dot == null) {\n overridenOptions = {...options, dot: true}\n }\n return fastGlob(pattern, overridenOptions)\n}\nexport {pathToFileURL} from 'url'\n\nexport async function findUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalize(got) : undefined\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n * @param path - Path to relativize\n * @returns Relativized path.\n */\nexport function relativize(path: string): string {\n const result = commondir([path, process.cwd()])\n const relativePath = relative(process.cwd(), path)\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n"]}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonMap } from './json.js';
|
|
1
|
+
import { JsonMap } from './private/common/json.js';
|
|
2
2
|
import { PickByPrefix } from './typing/pick-by-prefix.js';
|
|
3
3
|
import { MonorailEventPublic, MonorailEventSensitive } from './monorail.js';
|
|
4
4
|
import { HookReturnPerTunnelPlugin } from './public/node/plugins/tunnel.js';
|
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,MAAM,0BAA0B,CAAA;AAC/F,OAAO,EAAC,GAAG,EAAS,MAAM,yBAAyB,CAAA;AAGnD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAyB,EACzB,KAAa,EACb,OAA4C,EAC5C,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACzD,8DAA8D;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAQ,CAAA;AAClG,CAAC;AA4CD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAA;IAC9D,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IACtF,IAAI,0BAA0B,CAAC,KAAK,CAAC;QAAE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,+BAA+B,EAAC,CAAA;IACtG,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,CAAA;AACzB,CAAC;AAQD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,IAAY,EACZ,QAAgB;IAEhB,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;IACzE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAC5C,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB,CACjG,CAAA;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CAAC,CAAA;IACxE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC,CAAA;IAE1F,OAAO,UAAU,CAAC,CAAC,CAAC;SACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAClB,KAAK,CAAC,IAAI,KAAK,SAAS;QACtB,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAC;QACrD,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CACtC,CAAA;AACL,CAAC","sourcesContent":["import {JsonMap} from './json.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\nimport {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\nimport {HookReturnPerTunnelPlugin} from './public/node/plugins/tunnel.js'\nimport {getArrayContainsDuplicates, getArrayRejectingUndefined} from './public/common/array.js'\nimport {err, Result} from './public/node/result.js'\nimport {Config, Interfaces} from '@oclif/core'\n\n/**\n * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.\n *\n * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.\n */\nexport async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(\n config: Interfaces.Config,\n event: TEvent,\n options: TPluginMap[typeof event]['options'],\n timeout?: number,\n): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>> {\n const res = await config.runHook(event, options, timeout)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any\n}\n\ntype AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &\n PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>\n\ntype AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>\n\nexport interface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n sensitive_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificSensitiveMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: unknown}\n }\n}\n\nexport type PluginReturnsForHook<\n TEvent extends keyof TPluginMap,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'],\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = TPluginMap[TEvent]['pluginReturns'][TPluginName]\n\nexport type FanoutHookFunction<\n TEvent extends keyof TPluginMap = string,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string,\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = (\n this: Interfaces.Hook.Context,\n options: TPluginMap[TEvent]['options'] & {config: Interfaces.Config},\n) => Promise<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>\n\n/**\n * Execute the 'tunnel_provider' hook, and return the list of available tunnel providers.\n * Fail if there are multiple plugins for the same provider\n *\n * @param config - oclif config used to execute hooks\n * @returns list of available tunnel plugins\n */\nexport async function getListOfTunnelPlugins(config: Config): Promise<{plugins: string[]; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_provider', {})\n const names = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.name))\n if (getArrayContainsDuplicates(names)) return {plugins: names, error: 'multiple-plugins-for-provider'}\n return {plugins: names}\n}\n\nexport interface TunnelPluginError {\n provider: string\n type: 'multiple-urls' | 'handled-error' | 'unknown' | 'no-provider'\n message?: string\n}\n\n/**\n * Execute the 'tunnel_start' hook for the given provider.\n * Fails if there aren't plugins for that provider or if there are more than one.\n *\n * @param config - oclif config used to execute hooks\n * @param port - port where the tunnel will be started\n * @param provider - selected provider, must be unique\n * @returns tunnel URL from the selected provider\n */\nexport async function runTunnelPlugin(\n config: Config,\n port: number,\n provider: string,\n): Promise<Result<string, TunnelPluginError>> {\n const hooks = await fanoutHooks(config, 'tunnel_start', {port, provider})\n const urlResults = Object.values(hooks).filter(\n (tunnelResponse) => !tunnelResponse?.isErr() || tunnelResponse.error.type !== 'invalid-provider',\n )\n if (urlResults.length > 1) return err({provider, type: 'multiple-urls'})\n if (urlResults.length === 0 || !urlResults[0]) return err({provider, type: 'no-provider'})\n\n return urlResults[0]\n .map((data) => data.url)\n .mapError((error) =>\n error.type === 'unknown'\n ? {provider, type: 'unknown', message: error.message}\n : {provider, type: 'handled-error'},\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,M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,CAAC,CAAC,MAAM,CAC5C,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB,CACjG,CAAA;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CAAC,CAAA;IACxE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC,CAAA;IAE1F,OAAO,UAAU,CAAC,CAAC,CAAC;SACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAClB,KAAK,CAAC,IAAI,KAAK,SAAS;QACtB,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAC;QACrD,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CACtC,CAAA;AACL,CAAC","sourcesContent":["import {JsonMap} from './private/common/json.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\nimport {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\nimport {HookReturnPerTunnelPlugin} from './public/node/plugins/tunnel.js'\nimport {getArrayContainsDuplicates, getArrayRejectingUndefined} from './public/common/array.js'\nimport {err, Result} from './public/node/result.js'\nimport {Config, Interfaces} from '@oclif/core'\n\n/**\n * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.\n *\n * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.\n */\nexport async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(\n config: Interfaces.Config,\n event: TEvent,\n options: TPluginMap[typeof event]['options'],\n timeout?: number,\n): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>> {\n const res = await config.runHook(event, options, timeout)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any\n}\n\ntype AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &\n PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>\n\ntype AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>\n\nexport interface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n sensitive_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificSensitiveMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: unknown}\n }\n}\n\nexport type PluginReturnsForHook<\n TEvent extends keyof TPluginMap,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'],\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = TPluginMap[TEvent]['pluginReturns'][TPluginName]\n\nexport type FanoutHookFunction<\n TEvent extends keyof TPluginMap = string,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string,\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = (\n this: Interfaces.Hook.Context,\n options: TPluginMap[TEvent]['options'] & {config: Interfaces.Config},\n) => Promise<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>\n\n/**\n * Execute the 'tunnel_provider' hook, and return the list of available tunnel providers.\n * Fail if there are multiple plugins for the same provider\n *\n * @param config - oclif config used to execute hooks\n * @returns list of available tunnel plugins\n */\nexport async function getListOfTunnelPlugins(config: Config): Promise<{plugins: string[]; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_provider', {})\n const names = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.name))\n if (getArrayContainsDuplicates(names)) return {plugins: names, error: 'multiple-plugins-for-provider'}\n return {plugins: names}\n}\n\nexport interface TunnelPluginError {\n provider: string\n type: 'multiple-urls' | 'handled-error' | 'unknown' | 'no-provider'\n message?: string\n}\n\n/**\n * Execute the 'tunnel_start' hook for the given provider.\n * Fails if there aren't plugins for that provider or if there are more than one.\n *\n * @param config - oclif config used to execute hooks\n * @param port - port where the tunnel will be started\n * @param provider - selected provider, must be unique\n * @returns tunnel URL from the selected provider\n */\nexport async function runTunnelPlugin(\n config: Config,\n port: number,\n provider: string,\n): Promise<Result<string, TunnelPluginError>> {\n const hooks = await fanoutHooks(config, 'tunnel_start', {port, provider})\n const urlResults = Object.values(hooks).filter(\n (tunnelResponse) => !tunnelResponse?.isErr() || tunnelResponse.error.type !== 'invalid-provider',\n )\n if (urlResults.length > 1) return err({provider, type: 'multiple-urls'})\n if (urlResults.length === 0 || !urlResults[0]) return err({provider, type: 'no-provider'})\n\n return urlResults[0]\n .map((data) => data.url)\n .mapError((error) =>\n error.type === 'unknown'\n ? {provider, type: 'unknown', message: error.message}\n : {provider, type: 'handled-error'},\n )\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/private/common/json.ts"],"names":[],"mappings":"","sourcesContent":["export interface JsonMap {\n [key: string]: AnyJson\n}\ntype JsonArray = undefined[] | null[] | boolean[] | number[] | string[] | JsonMap[] | Date[]\nexport type AnyJson = undefined | null | boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import BaseCommand from '../../public/node/base-command.js';
|
|
2
|
+
import { CommandContent } from '../../public/node/hooks/prerun.js';
|
|
3
|
+
import { Interfaces } from '@oclif/core';
|
|
4
|
+
interface StartOptions {
|
|
5
|
+
commandContent: CommandContent;
|
|
6
|
+
args: string[];
|
|
7
|
+
currentTime?: number;
|
|
8
|
+
commandClass?: Interfaces.Command.Class | typeof BaseCommand;
|
|
9
|
+
}
|
|
10
|
+
export declare function startAnalytics({ commandContent, args, currentTime, commandClass, }: StartOptions): Promise<void>;
|
|
11
|
+
interface EnvironmentData {
|
|
12
|
+
uname: string;
|
|
13
|
+
env_ci: boolean;
|
|
14
|
+
env_ci_platform?: string;
|
|
15
|
+
env_plugin_installed_any_custom: boolean;
|
|
16
|
+
env_plugin_installed_shopify: string;
|
|
17
|
+
env_shell: string;
|
|
18
|
+
env_web_ide: string | undefined;
|
|
19
|
+
env_device_id: string;
|
|
20
|
+
env_cloud: string;
|
|
21
|
+
env_package_manager: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData>;
|
|
24
|
+
export declare function getSensitiveEnvironmentData(config: Interfaces.Config): Promise<{
|
|
25
|
+
env_plugin_installed_all: string;
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getPackageManager, packageManagerUsedForCreating } from '../../public/node/node-package-manager.js';
|
|
2
|
+
import * as metadata from '../../metadata.js';
|
|
3
|
+
import { macAddress } from '../../environment/local.js';
|
|
4
|
+
import { platformAndArch } from '../../os.js';
|
|
5
|
+
import { hashString } from '../../string.js';
|
|
6
|
+
import * as environment from '../../environment.js';
|
|
7
|
+
export async function startAnalytics({ commandContent, args, currentTime = new Date().getTime(), commandClass, }) {
|
|
8
|
+
let startCommand = commandContent.command;
|
|
9
|
+
if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {
|
|
10
|
+
startCommand = commandClass.analyticsNameOverride() ?? commandContent.command;
|
|
11
|
+
}
|
|
12
|
+
await metadata.addSensitive(() => ({
|
|
13
|
+
commandStartOptions: {
|
|
14
|
+
startTime: currentTime,
|
|
15
|
+
startCommand,
|
|
16
|
+
startArgs: args,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
await metadata.addPublic(() => ({
|
|
20
|
+
cmd_all_launcher: packageManagerUsedForCreating(),
|
|
21
|
+
cmd_all_alias_used: commandContent.alias,
|
|
22
|
+
cmd_all_topic: commandContent.topic,
|
|
23
|
+
cmd_all_plugin: commandClass?.plugin?.name,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
export async function getEnvironmentData(config) {
|
|
27
|
+
const ciPlatform = environment.local.ciPlatform();
|
|
28
|
+
const pluginNames = getPluginNames(config);
|
|
29
|
+
const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'));
|
|
30
|
+
const { platform, arch } = platformAndArch();
|
|
31
|
+
return {
|
|
32
|
+
uname: `${platform} ${arch}`,
|
|
33
|
+
env_ci: ciPlatform.isCI,
|
|
34
|
+
env_ci_platform: ciPlatform.name,
|
|
35
|
+
env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,
|
|
36
|
+
env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),
|
|
37
|
+
env_shell: config.shell,
|
|
38
|
+
env_web_ide: environment.local.cloudEnvironment().editor
|
|
39
|
+
? environment.local.cloudEnvironment().platform
|
|
40
|
+
: undefined,
|
|
41
|
+
env_device_id: hashString(await macAddress()),
|
|
42
|
+
env_cloud: environment.local.cloudEnvironment().platform,
|
|
43
|
+
env_package_manager: await getPackageManager(process.cwd()),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export async function getSensitiveEnvironmentData(config) {
|
|
47
|
+
return {
|
|
48
|
+
env_plugin_installed_all: JSON.stringify(getPluginNames(config)),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function getPluginNames(config) {
|
|
52
|
+
return config.plugins
|
|
53
|
+
.map((plugin) => plugin.name)
|
|
54
|
+
.sort()
|
|
55
|
+
.filter((plugin) => !plugin.startsWith('@oclif/'));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/private/node/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,6BAA6B,EAAC,MAAM,2CAA2C,CAAA;AAG1G,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AAUnD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,cAAc,EACd,IAAI,EACJ,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAClC,YAAY,GACC;IACb,IAAI,YAAY,GAAW,cAAc,CAAC,OAAO,CAAA;IACjD,IAAI,YAAY,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,uBAAuB,CAAC,EAAE;QAC/F,YAAY,GAAI,YAAmC,CAAC,qBAAqB,EAAE,IAAI,cAAc,CAAC,OAAO,CAAA;KACtG;IAED,MAAM,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;QACjC,mBAAmB,EAAE;YACnB,SAAS,EAAE,WAAW;YACtB,YAAY;YACZ,SAAS,EAAE,IAAI;SAChB;KACF,CAAC,CAAC,CAAA;IAEH,MAAM,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9B,gBAAgB,EAAE,6BAA6B,EAAE;QACjD,kBAAkB,EAAE,cAAc,CAAC,KAAK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wBAAwB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;KACjE,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,MAAyB;IAC/C,OAAO,MAAM,CAAC,OAAO;SAClB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;SAC5B,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;AACtD,CAAC","sourcesContent":["import {getPackageManager, packageManagerUsedForCreating} from '../../public/node/node-package-manager.js'\nimport BaseCommand from '../../public/node/base-command.js'\nimport {CommandContent} from '../../public/node/hooks/prerun.js'\nimport * as metadata from '../../metadata.js'\nimport {macAddress} from '../../environment/local.js'\nimport {platformAndArch} from '../../os.js'\nimport {hashString} from '../../string.js'\nimport * as environment from '../../environment.js'\nimport {Interfaces} from '@oclif/core'\n\ninterface StartOptions {\n commandContent: CommandContent\n args: string[]\n currentTime?: number\n commandClass?: Interfaces.Command.Class | typeof BaseCommand\n}\n\nexport async function startAnalytics({\n commandContent,\n args,\n currentTime = new Date().getTime(),\n commandClass,\n}: StartOptions): Promise<void> {\n let startCommand: string = commandContent.command\n if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {\n startCommand = (commandClass as typeof BaseCommand).analyticsNameOverride() ?? commandContent.command\n }\n\n await metadata.addSensitive(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand,\n startArgs: args,\n },\n }))\n\n await metadata.addPublic(() => ({\n cmd_all_launcher: packageManagerUsedForCreating(),\n cmd_all_alias_used: commandContent.alias,\n cmd_all_topic: commandContent.topic,\n cmd_all_plugin: commandClass?.plugin?.name,\n }))\n}\n\ninterface EnvironmentData {\n uname: string\n env_ci: boolean\n env_ci_platform?: string\n env_plugin_installed_any_custom: boolean\n env_plugin_installed_shopify: string\n env_shell: string\n env_web_ide: string | undefined\n env_device_id: string\n env_cloud: string\n env_package_manager: string\n}\n\nexport async function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData> {\n const ciPlatform = environment.local.ciPlatform()\n\n const pluginNames = getPluginNames(config)\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciPlatform.isCI,\n env_ci_platform: ciPlatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: environment.local.cloudEnvironment().editor\n ? environment.local.cloudEnvironment().platform\n : undefined,\n env_device_id: hashString(await macAddress()),\n env_cloud: environment.local.cloudEnvironment().platform,\n env_package_manager: await getPackageManager(process.cwd()),\n }\n}\n\nexport async function getSensitiveEnvironmentData(config: Interfaces.Config) {\n return {\n env_plugin_installed_all: JSON.stringify(getPluginNames(config)),\n }\n}\n\nfunction getPluginNames(config: Interfaces.Config) {\n return config.plugins\n .map((plugin) => plugin.name)\n .sort()\n .filter((plugin) => !plugin.startsWith('@oclif/'))\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Alert } from './Alert.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { unstyled } from '../../../../output.js';
|
|
4
3
|
import { describe, expect, test } from 'vitest';
|
|
5
4
|
import React from 'react';
|
|
5
|
+
import { render } from 'ink-testing-library';
|
|
6
6
|
describe('Alert', async () => {
|
|
7
7
|
test('renders correctly with all the options', async () => {
|
|
8
8
|
const options = {
|
|
@@ -51,8 +51,8 @@ describe('Alert', async () => {
|
|
|
51
51
|
url: 'https://shopify.com',
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
const {
|
|
55
|
-
expect(unstyled(
|
|
54
|
+
const { lastFrame } = render(React.createElement(Alert, { type: "info", ...options }));
|
|
55
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
56
56
|
"
|
|
57
57
|
╭─ info ───────────────────────────────────────────────────────────────────────╮
|
|
58
58
|
│ │
|
|
@@ -80,8 +80,8 @@ describe('Alert', async () => {
|
|
|
80
80
|
const options = {
|
|
81
81
|
headline: 'Title',
|
|
82
82
|
};
|
|
83
|
-
const {
|
|
84
|
-
expect(unstyled(
|
|
83
|
+
const { lastFrame } = render(React.createElement(Alert, { type: "info", ...options }));
|
|
84
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
85
85
|
"
|
|
86
86
|
╭─ info ───────────────────────────────────────────────────────────────────────╮
|
|
87
87
|
│ │
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"Alert.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,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,OAAO,EAAE,KAAK,IAAI,EAAE;IAC3B,IAAI,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,iCAAiC,CAAC;YACpE,IAAI,EAAE,CAAC,sCAAsC,EAAE,EAAC,QAAQ,EAAE,MAAM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led} from '../../../../output.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('Alert', async () => {\n test('renders correctly with all the options', async () => {\n const options = {\n headline: [{userInput: 'my-app'}, 'initialized and ready to build.'],\n body: ['You can find the build files in the ', {filePath: 'dist'}, 'folder.'],\n nextSteps: [\n [\n 'Run',\n {\n command: 'cd santorini-goods',\n },\n ],\n [\n 'To preview your project, run',\n {\n command: 'npm app dev',\n },\n ],\n [\n 'To add extensions, run',\n {\n command: 'npm generate extension',\n },\n ],\n ],\n reference: [\n [\n 'Run',\n {\n command: 'npm shopify help',\n },\n ],\n [\n // testing link wrapping behavior\n \"Press 'return' to open the really amazing and clean\",\n {\n link: {\n label: 'dev docs',\n url: 'https://shopify.dev',\n },\n },\n ],\n ],\n link: {\n label: 'Link',\n url: 'https://shopify.com',\n },\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ my-app initialized and ready to build. │\n │ │\n │ You can find the build files in the \\\\\"dist\\\\\" folder. │\n │ │\n │ Next steps │\n │ • Run \\`cd santorini-goods\\` │\n │ • To preview your project, run \\`npm app dev\\` │\n │ • To add extensions, run \\`npm generate extension\\` │\n │ │\n │ Reference │\n │ • Run \\`npm shopify help\\` │\n │ • Press 'return' to open the really amazing and clean dev docs ( │\n │ https://shopify.dev ) │\n │ │\n │ Link ( https://shopify.com ) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with only required options', async () => {\n const options = {\n headline: 'Title',\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"\n ╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ Title │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n})\n"]}
|
|
@@ -11,23 +11,23 @@ function typeToColor(type) {
|
|
|
11
11
|
}[type];
|
|
12
12
|
}
|
|
13
13
|
const BoxWithBorder = ({ type, marginY, children }) => {
|
|
14
|
-
const {
|
|
15
|
-
return (React.createElement(Box, { width:
|
|
14
|
+
const { twoThirds } = useLayout();
|
|
15
|
+
return (React.createElement(Box, { width: twoThirds, paddingY: 1, paddingX: 2, marginY: marginY, borderStyle: "round", flexDirection: "column", borderColor: typeToColor(type) },
|
|
16
16
|
React.createElement(Box, { marginTop: -2, marginBottom: 1, marginLeft: -1 },
|
|
17
17
|
React.createElement(Text, null, ` ${type.replace(/_/g, ' ')} `)),
|
|
18
18
|
children));
|
|
19
19
|
};
|
|
20
20
|
const BoxWithTopBottomLines = ({ type, marginY, children }) => {
|
|
21
|
-
const {
|
|
21
|
+
const { twoThirds } = useLayout();
|
|
22
22
|
return (React.createElement(Box, { marginY: marginY, flexDirection: "column" },
|
|
23
23
|
React.createElement(Box, { marginBottom: 1 },
|
|
24
24
|
React.createElement(Text, null,
|
|
25
25
|
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(2)),
|
|
26
26
|
React.createElement(Text, null, ` ${type.replace(/_/g, ' ')} `),
|
|
27
|
-
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(
|
|
27
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(twoThirds - 2 - type.length - 2)))),
|
|
28
28
|
children,
|
|
29
29
|
React.createElement(Box, { marginTop: 1 },
|
|
30
|
-
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(
|
|
30
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(twoThirds)))));
|
|
31
31
|
};
|
|
32
32
|
const Banner = ({ children, ...props }) => {
|
|
33
33
|
if (props.type === 'external_error') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"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K,gBAAgB,EAAE;QACnC,OAAO,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KACnE;SAAM;QACL,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KAC3D;AACH,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import useLayout from '../hooks/use-layout.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error'\n\ninterface Props {\n type: BannerType\n marginY?: number\n}\n\nfunction typeToColor(type: Props['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n external_error: 'red',\n }[type]\n}\n\nconst BoxWithBorder: React.FC<Props> = ({type, marginY, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box\n width={twoThirds}\n paddingY={1}\n paddingX={2}\n marginY={marginY}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-2} marginBottom={1} marginLeft={-1}>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n </Box>\n {children}\n </Box>\n )\n}\n\nconst BoxWithTopBottomLines: React.FC<Props> = ({type, marginY, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box marginY={marginY} flexDirection=\"column\">\n <Box marginBottom={1}>\n <Text>\n <Text color={typeToColor(type)}>{'─'.repeat(2)}</Text>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n {/* 2 initial dashes + 2 spaces surrounding the type */}\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds - 2 - type.length - 2)}</Text>\n </Text>\n </Box>\n\n {children}\n\n <Box marginTop={1}>\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds)}</Text>\n </Box>\n </Box>\n )\n}\n\nconst Banner: React.FC<Props> = ({children, ...props}) => {\n if (props.type === 'external_error') {\n return React.createElement(BoxWithTopBottomLines, props, children)\n } else {\n return React.createElement(BoxWithBorder, props, children)\n }\n}\n\nexport {Banner}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Banner } from './Banner.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { describe, expect, test } from 'vitest';
|
|
4
3
|
import React from 'react';
|
|
4
|
+
import { render } from 'ink-testing-library';
|
|
5
5
|
describe('Banner', async () => {
|
|
6
6
|
test('renders with a border for success', async () => {
|
|
7
|
-
const {
|
|
8
|
-
expect(
|
|
7
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "success" }));
|
|
8
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
9
9
|
"[32m╭─[39m success [32m────────────────────────────────────────────────────────────────────╮[39m
|
|
10
10
|
[32m│[39m [32m│[39m
|
|
11
11
|
[32m│[39m [32m│[39m
|
|
@@ -13,8 +13,8 @@ describe('Banner', async () => {
|
|
|
13
13
|
`);
|
|
14
14
|
});
|
|
15
15
|
test('renders with a border for info', async () => {
|
|
16
|
-
const {
|
|
17
|
-
expect(
|
|
16
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "info" }));
|
|
17
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
18
18
|
"[2m╭─[22m info [2m───────────────────────────────────────────────────────────────────────╮[22m
|
|
19
19
|
[2m│[22m [2m│[22m
|
|
20
20
|
[2m│[22m [2m│[22m
|
|
@@ -22,8 +22,8 @@ describe('Banner', async () => {
|
|
|
22
22
|
`);
|
|
23
23
|
});
|
|
24
24
|
test('renders with a border for warning', async () => {
|
|
25
|
-
const {
|
|
26
|
-
expect(
|
|
25
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "warning" }));
|
|
26
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
27
27
|
"[33m╭─[39m warning [33m────────────────────────────────────────────────────────────────────╮[39m
|
|
28
28
|
[33m│[39m [33m│[39m
|
|
29
29
|
[33m│[39m [33m│[39m
|
|
@@ -31,8 +31,8 @@ describe('Banner', async () => {
|
|
|
31
31
|
`);
|
|
32
32
|
});
|
|
33
33
|
test('renders with a border for error', async () => {
|
|
34
|
-
const {
|
|
35
|
-
expect(
|
|
34
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "error" }));
|
|
35
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
36
36
|
"[31m╭─[39m error [31m──────────────────────────────────────────────────────────────────────╮[39m
|
|
37
37
|
[31m│[39m [31m│[39m
|
|
38
38
|
[31m│[39m [31m│[39m
|
|
@@ -40,8 +40,8 @@ describe('Banner', async () => {
|
|
|
40
40
|
`);
|
|
41
41
|
});
|
|
42
42
|
test('renders with a top and bottom lines only for external errors', async () => {
|
|
43
|
-
const {
|
|
44
|
-
expect(
|
|
43
|
+
const { lastFrame } = render(React.createElement(Banner, { type: "external_error" }));
|
|
44
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
45
45
|
"[31m──[39m external error [31m──────────────────────────────────────────────────────────────[39m
|
|
46
46
|
|
|
47
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"Banner.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,QAAQ,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;IAC5B,IAAI,CAAC,mCA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;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Banner} from './Banner.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('Banner', async () => {\n test('renders with a border for success', async () => {\n const {lastFrame} = render(<Banner type=\"success\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[32m╭─\u001b[39m success \u001b[32m────────────────────────────────────────────────────────────────────╮\u001b[39m\n \u001b[32m│\u001b[39m \u001b[32m│\u001b[39m\n \u001b[32m│\u001b[39m \u001b[32m│\u001b[39m\n \u001b[32m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[39m\"\n `)\n })\n\n test('renders with a border for info', async () => {\n const {lastFrame} = render(<Banner type=\"info\" />)\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[2m╭─\u001b[22m info \u001b[2m───────────────────────────────────────────────────────────────────────╮\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[22m\"\n `)\n })\n\n test('renders with a border for warning', async () => {\n const {lastFrame} = render(<Banner type=\"warning\" />)\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[33m╭─\u001b[39m warning \u001b[33m────────────────────────────────────────────────────────────────────╮\u001b[39m\n \u001b[33m│\u001b[39m \u001b[33m│\u001b[39m\n \u001b[33m│\u001b[39m \u001b[33m│\u001b[39m\n \u001b[33m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[39m\"\n `)\n })\n\n test('renders with a border for error', async () => {\n const {lastFrame} = render(<Banner type=\"error\" />)\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m╭─\u001b[39m error \u001b[31m──────────────────────────────────────────────────────────────────────╮\u001b[39m\n \u001b[31m│\u001b[39m \u001b[31m│\u001b[39m\n \u001b[31m│\u001b[39m \u001b[31m│\u001b[39m\n \u001b[31m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[39m\"\n `)\n })\n\n test('renders with a top and bottom lines only for external errors', async () => {\n const {lastFrame} = render(<Banner type=\"external_error\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m──\u001b[39m external error \u001b[31m──────────────────────────────────────────────────────────────\u001b[39m\n\n\n \u001b[31m────────────────────────────────────────────────────────────────────────────────\u001b[39m\"\n `)\n })\n})\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Command } from './Command.js';
|
|
2
|
-
import { renderString } from '../../ui.js';
|
|
3
2
|
import { describe, expect, test } from 'vitest';
|
|
4
3
|
import React from 'react';
|
|
4
|
+
import { render } from 'ink-testing-library';
|
|
5
5
|
describe('Command', async () => {
|
|
6
6
|
test('renders correctly', async () => {
|
|
7
|
-
const {
|
|
8
|
-
expect(
|
|
7
|
+
const { lastFrame } = render(React.createElement(Command, { command: "npm install" }));
|
|
8
|
+
expect(lastFrame()).toMatchInlineSnapshot('"`npm install`"');
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=Command.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"Command.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,QAAQ,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IAC7B,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,OAAO,EAAC,aAAa,GAAG,CAAC,CAAA;QAE7D,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Command} from './Command.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\ndescribe('Command', async () => {\n test('renders correctly', async () => {\n const {lastFrame} = render(<Command command=\"npm install\" />)\n\n expect(lastFrame()).toMatchInlineSnapshot('\"`npm install`\"')\n })\n})\n"]}
|