@shopify/cli-kit 3.36.2 → 3.38.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.
Files changed (139) hide show
  1. package/dist/index.d.ts +0 -2
  2. package/dist/index.js +0 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/private/node/api/graphql.js +7 -7
  5. package/dist/private/node/api/graphql.js.map +1 -1
  6. package/dist/{network → private/node}/api.d.ts +0 -0
  7. package/dist/{network → private/node}/api.js +0 -0
  8. package/dist/private/node/api.js.map +1 -0
  9. package/dist/private/node/conf-store.d.ts +21 -0
  10. package/dist/private/node/conf-store.js +41 -0
  11. package/dist/private/node/conf-store.js.map +1 -0
  12. package/dist/{content-tokens.d.ts → private/node/content-tokens.d.ts} +11 -11
  13. package/dist/{content-tokens.js → private/node/content-tokens.js} +3 -3
  14. package/dist/private/node/content-tokens.js.map +1 -0
  15. package/dist/private/node/secure-store.js +4 -4
  16. package/dist/private/node/secure-store.js.map +1 -1
  17. package/dist/private/node/session/authorize.js +3 -3
  18. package/dist/private/node/session/authorize.js.map +1 -1
  19. package/dist/private/node/session/device-authorization.js +6 -6
  20. package/dist/private/node/session/device-authorization.js.map +1 -1
  21. package/dist/private/node/session/exchange.js.map +1 -1
  22. package/dist/private/node/session/identity-token-validation.js +5 -5
  23. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  24. package/dist/private/node/session/identity.d.ts +1 -1
  25. package/dist/private/node/session/identity.js.map +1 -1
  26. package/dist/private/node/session/redirect-listener.js +2 -2
  27. package/dist/private/node/session/redirect-listener.js.map +1 -1
  28. package/dist/private/node/session/scopes.d.ts +1 -1
  29. package/dist/private/node/session/scopes.js +1 -1
  30. package/dist/private/node/session/scopes.js.map +1 -1
  31. package/dist/private/node/session/store.js +5 -6
  32. package/dist/private/node/session/store.js.map +1 -1
  33. package/dist/private/node/session/validate.js +2 -2
  34. package/dist/private/node/session/validate.js.map +1 -1
  35. package/dist/private/node/session.js +19 -19
  36. package/dist/private/node/session.js.map +1 -1
  37. package/dist/private/node/ui/alert.js +1 -1
  38. package/dist/private/node/ui/alert.js.map +1 -1
  39. package/dist/private/node/ui/components/Alert.test.js +1 -1
  40. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  41. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -1
  42. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  43. package/dist/private/node/ui/components/ConcurrentOutput.test.js +1 -1
  44. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  45. package/dist/private/node/ui/components/FatalError.test.js +1 -1
  46. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  47. package/dist/private/node/ui/components/List.test.js +1 -1
  48. package/dist/private/node/ui/components/List.test.js.map +1 -1
  49. package/dist/private/node/ui/components/SelectPrompt.test.js +1 -1
  50. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  51. package/dist/private/node/ui/components/Tasks.test.js +1 -1
  52. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  53. package/dist/private/node/ui/components/TextPrompt.test.js +1 -1
  54. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  55. package/dist/private/node/ui/components/TokenizedText.test.js +1 -1
  56. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  57. package/dist/private/node/ui.d.ts +1 -1
  58. package/dist/private/node/ui.js +1 -1
  59. package/dist/private/node/ui.js.map +1 -1
  60. package/dist/public/common/string.js +1 -1
  61. package/dist/public/common/string.js.map +1 -1
  62. package/dist/public/common/version.d.ts +1 -1
  63. package/dist/public/common/version.js +1 -1
  64. package/dist/public/common/version.js.map +1 -1
  65. package/dist/public/node/analytics.js +5 -5
  66. package/dist/public/node/analytics.js.map +1 -1
  67. package/dist/public/node/api/admin.js +2 -2
  68. package/dist/public/node/api/admin.js.map +1 -1
  69. package/dist/public/node/archiver.js +2 -2
  70. package/dist/public/node/archiver.js.map +1 -1
  71. package/dist/public/node/base-command.js +4 -4
  72. package/dist/public/node/base-command.js.map +1 -1
  73. package/dist/public/node/conf.d.ts +2 -0
  74. package/dist/public/node/conf.js +3 -0
  75. package/dist/public/node/conf.js.map +1 -0
  76. package/dist/public/node/dot-env.js +2 -2
  77. package/dist/public/node/dot-env.js.map +1 -1
  78. package/dist/public/node/environment/spin.js +2 -2
  79. package/dist/public/node/environment/spin.js.map +1 -1
  80. package/dist/public/node/error-handler.js +3 -3
  81. package/dist/public/node/error-handler.js.map +1 -1
  82. package/dist/public/node/error.d.ts +5 -5
  83. package/dist/public/node/error.js +1 -1
  84. package/dist/public/node/error.js.map +1 -1
  85. package/dist/public/node/fs.js +19 -19
  86. package/dist/public/node/fs.js.map +1 -1
  87. package/dist/public/node/git.js +8 -8
  88. package/dist/public/node/git.js.map +1 -1
  89. package/dist/public/node/github.js +2 -2
  90. package/dist/public/node/github.js.map +1 -1
  91. package/dist/public/node/hooks/postrun.js +2 -2
  92. package/dist/public/node/hooks/postrun.js.map +1 -1
  93. package/dist/public/node/hooks/prerun.js +2 -2
  94. package/dist/public/node/hooks/prerun.js.map +1 -1
  95. package/dist/public/node/http.js +3 -3
  96. package/dist/public/node/http.js.map +1 -1
  97. package/dist/public/node/liquid.js +2 -2
  98. package/dist/public/node/liquid.js.map +1 -1
  99. package/dist/public/node/monorail.js +4 -4
  100. package/dist/public/node/monorail.js.map +1 -1
  101. package/dist/public/node/node-package-manager.js +9 -9
  102. package/dist/public/node/node-package-manager.js.map +1 -1
  103. package/dist/public/node/os.js +2 -2
  104. package/dist/public/node/os.js.map +1 -1
  105. package/dist/{output.d.ts → public/node/output.d.ts} +100 -41
  106. package/dist/{output.js → public/node/output.js} +129 -50
  107. package/dist/public/node/output.js.map +1 -0
  108. package/dist/public/node/ruby.d.ts +1 -0
  109. package/dist/public/node/ruby.js +23 -28
  110. package/dist/public/node/ruby.js.map +1 -1
  111. package/dist/public/node/session.js +9 -9
  112. package/dist/public/node/session.js.map +1 -1
  113. package/dist/public/node/system.js +2 -2
  114. package/dist/public/node/system.js.map +1 -1
  115. package/dist/public/node/tcp.js +4 -4
  116. package/dist/public/node/tcp.js.map +1 -1
  117. package/dist/public/node/testing/output.js +10 -9
  118. package/dist/public/node/testing/output.js.map +1 -1
  119. package/dist/public/node/ui.d.ts +1 -1
  120. package/dist/public/node/ui.js +1 -1
  121. package/dist/public/node/ui.js.map +1 -1
  122. package/dist/public/node/vscode.js +4 -4
  123. package/dist/public/node/vscode.js.map +1 -1
  124. package/dist/tsconfig.tsbuildinfo +1 -1
  125. package/dist/ui.js +9 -9
  126. package/dist/ui.js.map +1 -1
  127. package/package.json +1 -1
  128. package/dist/content-tokens.js.map +0 -1
  129. package/dist/git.d.ts +0 -36
  130. package/dist/git.js +0 -130
  131. package/dist/git.js.map +0 -1
  132. package/dist/network/api.js.map +0 -1
  133. package/dist/output.js.map +0 -1
  134. package/dist/private/node/testing/store.d.ts +0 -7
  135. package/dist/private/node/testing/store.js +0 -26
  136. package/dist/private/node/testing/store.js.map +0 -1
  137. package/dist/store.d.ts +0 -53
  138. package/dist/store.js +0 -133
  139. package/dist/store.js.map +0 -1
package/dist/ui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CancelExecution, AbortError, AbortSilentError } from './public/node/error.js';
2
2
  import { removeFile, fileExists } from './public/node/fs.js';
3
- import { info, completed, content, token, logUpdate, stringifyMessage, debug } from './output.js';
3
+ import { outputInfo, outputCompleted, outputContent, outputToken, logUpdate, stringifyMessage, outputDebug, } from './public/node/output.js';
4
4
  import colors from './public/node/colors.js';
5
5
  import { relativizePath } from './public/node/path.js';
6
6
  import { isTerminalInteractive } from './public/node/environment/local.js';
@@ -13,11 +13,11 @@ export function newListr(tasks, options) {
13
13
  }
14
14
  const started = (content, logger) => {
15
15
  const message = `${colors.yellow('❯')} ${stringifyMessage(content)}`;
16
- info(message, logger);
16
+ outputInfo(message, logger);
17
17
  };
18
18
  const failed = (content, logger) => {
19
19
  const message = `${colors.red('✖')} ${stringifyMessage(content)}`;
20
- info(message, logger);
20
+ outputInfo(message, logger);
21
21
  };
22
22
  export const task = async ({ title, task }) => {
23
23
  let success;
@@ -31,20 +31,20 @@ export const task = async ({ title, task }) => {
31
31
  logUpdate.done();
32
32
  throw err;
33
33
  }
34
- completed(success, logUpdate);
34
+ outputCompleted(success, logUpdate);
35
35
  logUpdate.done();
36
36
  };
37
37
  export const prompt = async (questions) => {
38
38
  if (!isTerminalInteractive() && questions.length !== 0) {
39
- throw new AbortError(content `
39
+ throw new AbortError(outputContent `
40
40
  The CLI prompted in a non-interactive terminal with the following questions:
41
- ${token.json(questions)}
41
+ ${outputToken.json(questions)}
42
42
  `);
43
43
  }
44
44
  const value = {};
45
45
  for (const question of questions) {
46
46
  if (question.preface) {
47
- info(question.preface);
47
+ outputInfo(question.preface);
48
48
  }
49
49
  // eslint-disable-next-line no-await-in-loop
50
50
  value[question.name] = (await executorUI(question));
@@ -75,7 +75,7 @@ export async function terminateBlockingPortProcessPrompt(port, stepDescription)
75
75
  const stepDescriptionContent = stepDescription ?? 'current step';
76
76
  const processInfo = await findProcess('port', port);
77
77
  const formattedProcessName = processInfo && processInfo.length > 0 && processInfo[0]?.name
78
- ? ` ${content `${token.italic(`(${processInfo[0].name})`)}`.value}`
78
+ ? ` ${outputContent `${outputToken.italic(`(${processInfo[0].name})`)}`.value}`
79
79
  : '';
80
80
  const options = [
81
81
  { name: 'Yes, terminate process in order to log in now', value: 'finish' },
@@ -98,7 +98,7 @@ export const keypress = async () => {
98
98
  process.stdin.pause();
99
99
  const bytes = Array.from(buffer);
100
100
  if (bytes.length && bytes[0] === 3) {
101
- debug('Canceled keypress, User pressed CTRL+C');
101
+ outputDebug('Canceled keypress, User pressed CTRL+C');
102
102
  reject(new AbortSilentError());
103
103
  }
104
104
  process.nextTick(resolve);
package/dist/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAA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AAE,OAAO;YACb,OAAO,EAAE,GAAG,sBAAsB,oBAAoB,IAAI,2DAA2D,oBAAoB,4BAA4B;YACrK,OAAO,EAAE,OAAO;SACjB;KACF,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAA;AAClC,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;IACjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YAErB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;gBAClC,KAAK,CAAC,wCAAwC,CAAC,CAAA;gBAC/C,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAA;aAC/B;YACD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;QACtB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {CancelExecution, AbortError, AbortSilentError} from './public/node/error.js'\nimport {removeFile, fileExists} from './public/node/fs.js'\nimport {info, completed, content, token, logUpdate, Message, Logger, stringifyMessage, debug} from './output.js'\nimport colors from './public/node/colors.js'\nimport {relativizePath} from './public/node/path.js'\nimport {isTerminalInteractive} from './public/node/environment/local.js'\nimport {run as executorUI} from './ui/executor.js'\nimport {Listr as OriginalListr, ListrTask, ListrBaseClassOptions} from 'listr2'\nimport findProcess from 'find-process'\n\nexport function newListr(tasks: ListrTask[], options?: object | ListrBaseClassOptions) {\n const listr = new OriginalListr(tasks, options)\n return listr\n}\n\nexport type ListrTasks = ConstructorParameters<typeof OriginalListr>[0]\nexport type {ListrTaskWrapper, ListrDefaultRenderer, ListrTask} from 'listr2'\n\nexport interface PromptAnswer {\n name: string\n value: string\n}\nexport type FilterFunction = (answers: PromptAnswer[], input: string) => Promise<PromptAnswer[]>\n\ninterface BaseQuestion<TName extends string> {\n name: TName\n message: string\n preface?: string\n validate?: (value: string) => string | true\n default?: string\n result?: (value: string) => string | boolean\n choices?: QuestionChoiceType[]\n source?: (filter: FilterFunction) => FilterFunction\n}\n\ntype TextQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'input'\n // a default is required, otherwise we'd show a prompt like 'undefined'\n default: string\n}\n\ntype PasswordQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'password'\n}\n\ntype SelectableQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'select' | 'autocomplete'\n choices: QuestionChoiceType[]\n}\n\nexport type Question<TName extends string = string> =\n | TextQuestion<TName>\n | SelectableQuestion<TName>\n | PasswordQuestion<TName>\n\nexport interface QuestionChoiceType {\n name: string\n value: string\n group?: {name: string; order: number}\n}\n\nconst started = (content: Message, logger: Logger) => {\n const message = `${colors.yellow('❯')} ${stringifyMessage(content)}`\n info(message, logger)\n}\n\nconst failed = (content: Message, logger: Logger) => {\n const message = `${colors.red('✖')} ${stringifyMessage(content)}`\n info(message, logger)\n}\n\n/**\n * Performs a task with the title kept up to date and stdout available to the\n * task while it runs (there is no re-writing stdout while the task runs).\n */\nexport interface TaskOptions {\n title: string\n task: () => Promise<void | {successMessage: string}>\n}\nexport const task = async ({title, task}: TaskOptions) => {\n let success\n started(title, logUpdate)\n try {\n const result = await task()\n success = result?.successMessage || title\n } catch (err) {\n failed(title, logUpdate)\n logUpdate.done()\n throw err\n }\n completed(success, logUpdate)\n logUpdate.done()\n}\nexport const prompt = async <\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(\n questions: ReadonlyArray<Question<TName>>,\n): Promise<TAnswers> => {\n if (!isTerminalInteractive() && questions.length !== 0) {\n throw new AbortError(content`\nThe CLI prompted in a non-interactive terminal with the following questions:\n${token.json(questions)}\n `)\n }\n\n const value = {} as TAnswers\n for (const question of questions) {\n if (question.preface) {\n info(question.preface)\n }\n\n // eslint-disable-next-line no-await-in-loop\n value[question.name] = (await executorUI(question)) as TAnswers[TName]\n }\n return value\n}\n\nexport async function nonEmptyDirectoryPrompt(directory: string) {\n if (await fileExists(directory)) {\n const options = [\n {name: 'No, don’t delete the files', value: 'abort'},\n {name: 'Yes, delete the files', value: 'overwrite'},\n ]\n\n const relativeDirectory = relativizePath(directory)\n\n const questions: Question<'value'> = {\n type: 'select',\n name: 'value',\n message: `${relativeDirectory} is not an empty directory. Do you want to delete the existing files and continue?`,\n choices: options,\n }\n\n const choice = await prompt([questions])\n\n if (choice.value === 'abort') {\n throw new CancelExecution()\n }\n\n await removeFile(directory)\n }\n}\n\nexport async function terminateBlockingPortProcessPrompt(port: number, stepDescription?: string): Promise<boolean> {\n const stepDescriptionContent = stepDescription ?? 'current step'\n\n const processInfo = await findProcess('port', port)\n const formattedProcessName =\n processInfo && processInfo.length > 0 && processInfo[0]?.name\n ? ` ${content`${token.italic(`(${processInfo[0].name})`)}`.value}`\n : ''\n\n const options = [\n {name: 'Yes, terminate process in order to log in now', value: 'finish'},\n {name: `No, cancel command and try later`, value: 'cancel'},\n ]\n\n const choice = await prompt([\n {\n type: 'select',\n name: 'value',\n message: `${stepDescriptionContent} requires a port ${port} that's unavailable because it's running another process${formattedProcessName}. Terminate that process? `,\n choices: options,\n },\n ])\n return choice.value === 'finish'\n}\n\nexport const keypress = async () => {\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n debug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,wBAAwB,CAAA;AACpF,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,SAAS,EAGT,gBAAgB,EAChB,WAAW,GACZ,MAAM,yBAAyB,CAAA;AAChC,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAC,GAAG,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,KAAK,IAAI,aAAa,EAAmC,MAAM,QAAQ,CAAA;AAC/E,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,MAAM,UAAU,QAAQ,CAAC,KAAkB,EAAE,OAAwC;IACnF,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,KAAK,CAAA;AACd,CAAC;AAgDD,MAAM,OAAO,GAAG,CAAC,OAAsB,EAAE,MAAc,EAAE,EAAE;IACzD,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAA;IACpE,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAC7B,CAA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M,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {CancelExecution, AbortError, AbortSilentError} from './public/node/error.js'\nimport {removeFile, fileExists} from './public/node/fs.js'\nimport {\n outputInfo,\n outputCompleted,\n outputContent,\n outputToken,\n logUpdate,\n OutputMessage,\n Logger,\n stringifyMessage,\n outputDebug,\n} from './public/node/output.js'\nimport colors from './public/node/colors.js'\nimport {relativizePath} from './public/node/path.js'\nimport {isTerminalInteractive} from './public/node/environment/local.js'\nimport {run as executorUI} from './ui/executor.js'\nimport {Listr as OriginalListr, ListrTask, ListrBaseClassOptions} from 'listr2'\nimport findProcess from 'find-process'\n\nexport function newListr(tasks: ListrTask[], options?: object | ListrBaseClassOptions) {\n const listr = new OriginalListr(tasks, options)\n return listr\n}\n\nexport type ListrTasks = ConstructorParameters<typeof OriginalListr>[0]\nexport type {ListrTaskWrapper, ListrDefaultRenderer, ListrTask} from 'listr2'\n\nexport interface PromptAnswer {\n name: string\n value: string\n}\nexport type FilterFunction = (answers: PromptAnswer[], input: string) => Promise<PromptAnswer[]>\n\ninterface BaseQuestion<TName extends string> {\n name: TName\n message: string\n preface?: string\n validate?: (value: string) => string | true\n default?: string\n result?: (value: string) => string | boolean\n choices?: QuestionChoiceType[]\n source?: (filter: FilterFunction) => FilterFunction\n}\n\ntype TextQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'input'\n // a default is required, otherwise we'd show a prompt like 'undefined'\n default: string\n}\n\ntype PasswordQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'password'\n}\n\ntype SelectableQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'select' | 'autocomplete'\n choices: QuestionChoiceType[]\n}\n\nexport type Question<TName extends string = string> =\n | TextQuestion<TName>\n | SelectableQuestion<TName>\n | PasswordQuestion<TName>\n\nexport interface QuestionChoiceType {\n name: string\n value: string\n group?: {name: string; order: number}\n}\n\nconst started = (content: OutputMessage, logger: Logger) => {\n const message = `${colors.yellow('❯')} ${stringifyMessage(content)}`\n outputInfo(message, logger)\n}\n\nconst failed = (content: OutputMessage, logger: Logger) => {\n const message = `${colors.red('✖')} ${stringifyMessage(content)}`\n outputInfo(message, logger)\n}\n\n/**\n * Performs a task with the title kept up to date and stdout available to the\n * task while it runs (there is no re-writing stdout while the task runs).\n */\nexport interface TaskOptions {\n title: string\n task: () => Promise<void | {successMessage: string}>\n}\nexport const task = async ({title, task}: TaskOptions) => {\n let success\n started(title, logUpdate)\n try {\n const result = await task()\n success = result?.successMessage || title\n } catch (err) {\n failed(title, logUpdate)\n logUpdate.done()\n throw err\n }\n outputCompleted(success, logUpdate)\n logUpdate.done()\n}\nexport const prompt = async <\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(\n questions: ReadonlyArray<Question<TName>>,\n): Promise<TAnswers> => {\n if (!isTerminalInteractive() && questions.length !== 0) {\n throw new AbortError(outputContent`\nThe CLI prompted in a non-interactive terminal with the following questions:\n${outputToken.json(questions)}\n `)\n }\n\n const value = {} as TAnswers\n for (const question of questions) {\n if (question.preface) {\n outputInfo(question.preface)\n }\n\n // eslint-disable-next-line no-await-in-loop\n value[question.name] = (await executorUI(question)) as TAnswers[TName]\n }\n return value\n}\n\nexport async function nonEmptyDirectoryPrompt(directory: string) {\n if (await fileExists(directory)) {\n const options = [\n {name: 'No, don’t delete the files', value: 'abort'},\n {name: 'Yes, delete the files', value: 'overwrite'},\n ]\n\n const relativeDirectory = relativizePath(directory)\n\n const questions: Question<'value'> = {\n type: 'select',\n name: 'value',\n message: `${relativeDirectory} is not an empty directory. Do you want to delete the existing files and continue?`,\n choices: options,\n }\n\n const choice = await prompt([questions])\n\n if (choice.value === 'abort') {\n throw new CancelExecution()\n }\n\n await removeFile(directory)\n }\n}\n\nexport async function terminateBlockingPortProcessPrompt(port: number, stepDescription?: string): Promise<boolean> {\n const stepDescriptionContent = stepDescription ?? 'current step'\n\n const processInfo = await findProcess('port', port)\n const formattedProcessName =\n processInfo && processInfo.length > 0 && processInfo[0]?.name\n ? ` ${outputContent`${outputToken.italic(`(${processInfo[0].name})`)}`.value}`\n : ''\n\n const options = [\n {name: 'Yes, terminate process in order to log in now', value: 'finish'},\n {name: `No, cancel command and try later`, value: 'cancel'},\n ]\n\n const choice = await prompt([\n {\n type: 'select',\n name: 'value',\n message: `${stepDescriptionContent} requires a port ${port} that's unavailable because it's running another process${formattedProcessName}. Terminate that process? `,\n choices: options,\n },\n ])\n return choice.value === 'finish'\n}\n\nexport const keypress = async () => {\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/cli-kit",
3
- "version": "3.36.2",
3
+ "version": "3.38.0",
4
4
  "private": false,
5
5
  "description": "A set of utilities, interfaces, and models that are common across all the platform features",
6
6
  "keywords": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../src/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAA;AACpD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EAAU,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,GAAG,MAAM,YAAY,CAAA;AAG5B,MAAM,OAAgB,YAAY;IAGhC,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CAGF;AAED,MAAM,OAAO,eAAgB,SAAQ,YAAoB;IACvD,M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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,YAAqB;IAC5D,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,YAAqB;IAC/D,MAAM;QACJ,OAAO,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAAqB;IAC3D,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import {relativizePath} from './public/node/path.js'\nimport colors from './public/node/colors.js'\nimport {Message, stringifyMessage} from './output.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<Message> {\n link: string\n\n constructor(value: Message, 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<Message> {\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<Message> {\n color: (text: string) => string\n\n constructor(value: Message, 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<Message> {\n output(): string {\n return colors.bold.redBright(stringifyMessage(this.value))\n }\n}\n\nexport class PathContentToken extends ContentToken<Message> {\n output(): string {\n return relativizePath(stringifyMessage(this.value))\n }\n}\n\nexport class HeadingContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold.underline(stringifyMessage(this.value))\n }\n}\n\nexport class SubHeadingContentToken extends ContentToken<Message> {\n output(): string {\n return colors.underline(stringifyMessage(this.value))\n }\n}\n\nexport class ItalicContentToken extends ContentToken<Message> {\n output(): string {\n return colors.italic(stringifyMessage(this.value))\n }\n}\n"]}
package/dist/git.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import { AbortError } from './public/node/error.js';
2
- import { DefaultLogFields, ListLogLine } from 'simple-git';
3
- export declare const factory: import("simple-git").SimpleGitFactory;
4
- export declare const GitNotPresentError: () => AbortError;
5
- export declare const OutsideGitDirectoryError: (directory: string) => AbortError;
6
- export declare const NoCommitError: () => AbortError;
7
- export declare const DetachedHeadError: () => AbortError;
8
- export declare function initializeRepository(directory: string, initialBranch?: string): Promise<void>;
9
- export interface GitIgnoreTemplate {
10
- [section: string]: string[];
11
- }
12
- export declare function createGitIgnore(directory: string, template: GitIgnoreTemplate): void;
13
- export declare function downloadRepository({ repoUrl, destination, progressUpdater, shallow, latestTag, }: {
14
- repoUrl: string;
15
- destination: string;
16
- progressUpdater?: (statusString: string) => void;
17
- shallow?: boolean;
18
- latestTag?: boolean;
19
- }): Promise<void>;
20
- export declare function getLatestCommit(directory?: string): Promise<DefaultLogFields & ListLogLine>;
21
- export declare function addAll(directory?: string): Promise<void>;
22
- export declare function commit(message: string, options?: {
23
- directory?: string;
24
- author?: string;
25
- }): Promise<string>;
26
- export declare function getHeadSymbolicRef(directory?: string): Promise<string>;
27
- /**
28
- * If "git" is not present in the environment it throws
29
- * an abort error.
30
- */
31
- export declare function ensurePresentOrAbort(): Promise<void>;
32
- /**
33
- * If command run from outside a .git directory tree
34
- * it throws an abort error.
35
- */
36
- export declare function ensureInsideGitDirectory(directory?: string): Promise<void>;
package/dist/git.js DELETED
@@ -1,130 +0,0 @@
1
- import { AbortError } from './public/node/error.js';
2
- import { hasGit, isTerminalInteractive } from './public/node/environment/local.js';
3
- import { content, token, debug } from './output.js';
4
- import { appendFileSync } from './public/node/fs.js';
5
- import { cwd } from './public/node/path.js';
6
- import git from 'simple-git';
7
- export const factory = git;
8
- export const GitNotPresentError = () => {
9
- return new AbortError(`Git is necessary in the environment to continue`, content `Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`);
10
- };
11
- export const OutsideGitDirectoryError = (directory) => {
12
- return new AbortError(`${token.path(directory)} is not a Git directory`);
13
- };
14
- export const NoCommitError = () => {
15
- return new AbortError('Must have at least one commit to run command', content `Run ${token.genericShellCommand("git commit -m 'Initial commit'")} to create your first commit.`);
16
- };
17
- export const DetachedHeadError = () => {
18
- return new AbortError("Git HEAD can't be detached to run command", content `Run ${token.genericShellCommand('git checkout [branchName]')} to reattach HEAD or see git ${token.link('documentation', 'https://git-scm.com/book/en/v2/Git-Internals-Git-References')} for more details`);
19
- };
20
- export async function initializeRepository(directory, initialBranch = 'main') {
21
- debug(content `Initializing git repository at ${token.path(directory)}...`);
22
- await ensurePresentOrAbort();
23
- // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+
24
- const repo = git(directory);
25
- await repo.init();
26
- await repo.checkoutLocalBranch(initialBranch);
27
- }
28
- export function createGitIgnore(directory, template) {
29
- debug(content `Creating .gitignore at ${token.path(directory)}...`);
30
- const filePath = `${directory}/.gitignore`;
31
- let fileContent = '';
32
- for (const [section, lines] of Object.entries(template)) {
33
- fileContent += `# ${section}\n`;
34
- fileContent += `${lines.join('\n')}\n\n`;
35
- }
36
- appendFileSync(filePath, fileContent);
37
- }
38
- export async function downloadRepository({ repoUrl, destination, progressUpdater, shallow, latestTag, }) {
39
- debug(content `Git-cloning repository ${repoUrl} into ${token.path(destination)}...`);
40
- await ensurePresentOrAbort();
41
- const [repository, branch] = repoUrl.split('#');
42
- const options = { '--recurse-submodules': null };
43
- if (branch && latestTag) {
44
- throw new AbortError("Error cloning the repository. Git can't clone the latest release with a 'branch'.");
45
- }
46
- if (branch) {
47
- options['--branch'] = branch;
48
- }
49
- if (shallow && latestTag) {
50
- throw new AbortError("Error cloning the repository. Git can't clone the latest release with the 'shallow' property.");
51
- }
52
- if (shallow) {
53
- options['--depth'] = 1;
54
- }
55
- const progress = ({ stage, progress, processed, total }) => {
56
- const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`;
57
- if (progressUpdater)
58
- progressUpdater(updateString);
59
- };
60
- const simpleGitOptions = {
61
- progress,
62
- ...(!isTerminalInteractive() && { config: ['core.askpass=true'] }),
63
- };
64
- try {
65
- await git(simpleGitOptions).clone(repository, destination, options);
66
- if (latestTag) {
67
- const localGitRepository = git(destination);
68
- const latestTag = await getLocalLatestTag(localGitRepository, repoUrl);
69
- await localGitRepository.checkout(latestTag);
70
- }
71
- }
72
- catch (err) {
73
- if (err instanceof Error) {
74
- const abortError = new AbortError(err.message);
75
- abortError.stack = err.stack;
76
- throw abortError;
77
- }
78
- throw err;
79
- }
80
- }
81
- async function getLocalLatestTag(repository, repoUrl) {
82
- const latest = (await repository.tags()).latest;
83
- if (!latest) {
84
- throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`);
85
- }
86
- return latest;
87
- }
88
- export async function getLatestCommit(directory) {
89
- const logs = await git({ baseDir: directory }).log({
90
- maxCount: 1,
91
- });
92
- if (!logs.latest)
93
- throw NoCommitError();
94
- return logs.latest;
95
- }
96
- export async function addAll(directory) {
97
- const simpleGit = git({ baseDir: directory });
98
- await simpleGit.raw('add', '--all');
99
- }
100
- export async function commit(message, options) {
101
- const simpleGit = git({ baseDir: options?.directory });
102
- const commitOptions = options?.author ? { '--author': options.author } : undefined;
103
- const result = await simpleGit.commit(message, commitOptions);
104
- return result.commit;
105
- }
106
- export async function getHeadSymbolicRef(directory) {
107
- const ref = await git({ baseDir: directory }).raw('symbolic-ref', '-q', 'HEAD');
108
- if (!ref)
109
- throw DetachedHeadError();
110
- return ref.trim();
111
- }
112
- /**
113
- * If "git" is not present in the environment it throws
114
- * an abort error.
115
- */
116
- export async function ensurePresentOrAbort() {
117
- if (!(await hasGit())) {
118
- throw GitNotPresentError();
119
- }
120
- }
121
- /**
122
- * If command run from outside a .git directory tree
123
- * it throws an abort error.
124
- */
125
- export async function ensureInsideGitDirectory(directory) {
126
- if (!(await git({ baseDir: directory }).checkIsRepo())) {
127
- throw OutsideGitDirectoryError(directory || cwd());
128
- }
129
- }
130
- //# sourceMappingURL=git.js.map
package/dist/git.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,oCAAoC,CAAA;AAChF,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAC,GAAG,EAAC,MAAM,uBAA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IAAI,CAAC,GAAG;QAAE,MAAM,iBAAiB,EAAE,CAAA;IACnC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,EAAE;QACrB,MAAM,kBAAkB,EAAE,CAAA;KAC3B;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAkB;IAC/D,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE;QACpD,MAAM,wBAAwB,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,CAAA;KACnD;AACH,CAAC","sourcesContent":["import {AbortError} from './public/node/error.js'\nimport {hasGit, isTerminalInteractive} from './public/node/environment/local.js'\nimport {content, token, debug} from './output.js'\nimport {appendFileSync} from './public/node/fs.js'\nimport {cwd} from './public/node/path.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\n\nexport const factory = git\n\nexport const GitNotPresentError = () => {\n return new AbortError(\n `Git is necessary in the environment to continue`,\n content`Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`,\n )\n}\n\nexport const OutsideGitDirectoryError = (directory: string) => {\n return new AbortError(`${token.path(directory)} is not a Git directory`)\n}\n\nexport const NoCommitError = () => {\n return new AbortError(\n 'Must have at least one commit to run command',\n content`Run ${token.genericShellCommand(\"git commit -m 'Initial commit'\")} to create your first commit.`,\n )\n}\n\nexport const DetachedHeadError = () => {\n return new AbortError(\n \"Git HEAD can't be detached to run command\",\n content`Run ${token.genericShellCommand('git checkout [branchName]')} to reattach HEAD or see git ${token.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n}\n\nexport async function initializeRepository(directory: string, initialBranch = 'main') {\n debug(content`Initializing git repository at ${token.path(directory)}...`)\n await ensurePresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n const repo = git(directory)\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n debug(content`Creating .gitignore at ${token.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\nexport async function downloadRepository({\n repoUrl,\n destination,\n progressUpdater,\n shallow,\n latestTag,\n}: {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}) {\n debug(content`Git-cloning repository ${repoUrl} into ${token.path(destination)}...`)\n await ensurePresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n const localGitRepository = git(destination)\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string) {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\nexport async function getLatestCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) throw NoCommitError()\n return logs.latest\n}\n\nexport async function addAll(directory?: string): Promise<void> {\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport async function commit(message: string, options?: {directory?: string; author?: string}): Promise<string> {\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) throw DetachedHeadError()\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensurePresentOrAbort() {\n if (!(await hasGit())) {\n throw GitNotPresentError()\n }\n}\n\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n */\nexport async function ensureInsideGitDirectory(directory?: string) {\n if (!(await git({baseDir: directory}).checkIsRepo())) {\n throw OutsideGitDirectoryError(directory || cwd())\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/network/api.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,CAAC,CAAA","sourcesContent":["export type API = 'admin' | 'storefront-renderer' | 'partners'\n\nexport const allAPIs: API[] = ['admin', 'storefront-renderer', 'partners']\n"]}
@@ -1 +0,0 @@
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B,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 './public/node/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 'pnpm':\n case 'yarn': {\n const pieces = [packageManager, scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'npm': {\n const pieces = ['npm', '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\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,7 +0,0 @@
1
- import { CLIKitStore } from '../../../store.js';
2
- /**
3
- * Creates a temporary configuration store and ties its lifecycle to the callback.
4
- * @param callback - Callback to execute. When the callback exits, the local config is destroyed.
5
- * @returns Promise that resolves with the value returned by the callback.
6
- */
7
- export declare function temporaryTestStore<T>(callback: (store: CLIKitStore) => Promise<T>): Promise<T>;
@@ -1,26 +0,0 @@
1
- import { CLIKitStore } from '../../../store.js';
2
- import { removeFile } from '../../../public/node/fs.js';
3
- import uniqueString from 'unique-string';
4
- /**
5
- * Creates a temporary configuration store and ties its lifecycle to the callback.
6
- * @param callback - Callback to execute. When the callback exits, the local config is destroyed.
7
- * @returns Promise that resolves with the value returned by the callback.
8
- */
9
- export async function temporaryTestStore(callback) {
10
- let localConf;
11
- try {
12
- const name = `shopify-cli-test-${uniqueString()}`;
13
- localConf = new CLIKitStore({ projectName: name });
14
- // eslint-disable-next-line node/callback-return
15
- const result = callback(localConf);
16
- return result;
17
- }
18
- finally {
19
- if (localConf) {
20
- await removeFile(localConf.path);
21
- const configFolder = localConf.path.replace(/\/config.json$/, '');
22
- await removeFile(configFolder);
23
- }
24
- }
25
- }
26
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/private/node/testing/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAI,QAA4C;IACtF,IAAI,SAAkC,CAAA;IACtC,IAAI;QACF,MAAM,IAAI,GAAG,oBAAoB,YAAY,EAAE,EAAE,CAAA;QACjD,SAAS,GAAG,IAAI,WAAW,CAAC,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,CAAA;QAChD,gDAAgD;QAChD,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAA;QAClC,OAAO,MAAM,CAAA;KACd;YAAS;QACR,IAAI,SAAS,EAAE;YACb,MAAM,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YAChC,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;YACjE,MAAM,UAAU,CAAC,YAAY,CAAC,CAAA;SAC/B;KACF;AACH,CAAC","sourcesContent":["import {CLIKitStore} from '../../../store.js'\nimport {removeFile} from '../../../public/node/fs.js'\nimport uniqueString from 'unique-string'\n\n/**\n * Creates a temporary configuration store and ties its lifecycle to the callback.\n * @param callback - Callback to execute. When the callback exits, the local config is destroyed.\n * @returns Promise that resolves with the value returned by the callback.\n */\nexport async function temporaryTestStore<T>(callback: (store: CLIKitStore) => Promise<T>): Promise<T> {\n let localConf: CLIKitStore | undefined\n try {\n const name = `shopify-cli-test-${uniqueString()}`\n localConf = new CLIKitStore({projectName: name})\n // eslint-disable-next-line node/callback-return\n const result = callback(localConf)\n return result\n } finally {\n if (localConf) {\n await removeFile(localConf.path)\n const configFolder = localConf.path.replace(/\\/config.json$/, '')\n await removeFile(configFolder)\n }\n }\n}\n"]}
package/dist/store.d.ts DELETED
@@ -1,53 +0,0 @@
1
- import Conf from 'conf';
2
- export interface CachedAppInfo {
3
- directory: string;
4
- appId?: string;
5
- title?: string;
6
- orgId?: string;
7
- storeFqdn?: string;
8
- updateURLs?: boolean;
9
- tunnelPlugin?: string;
10
- }
11
- interface ConfSchema {
12
- appInfo: CachedAppInfo[];
13
- themeStore: string;
14
- session: string;
15
- }
16
- export declare function cliKitStore(): CLIKitStore;
17
- export declare function getAppInfo(directory: string): CachedAppInfo | undefined;
18
- export declare function setAppInfo(options: {
19
- directory: string;
20
- appId?: string;
21
- title?: string;
22
- storeFqdn?: string;
23
- orgId?: string;
24
- updateURLs?: boolean;
25
- tunnelPlugin?: string;
26
- }): void;
27
- export declare function clearAppInfo(directory: string): void;
28
- export declare function getThemeStore(): string | undefined;
29
- export declare function setThemeStore(themeStore: string): void;
30
- export declare function getSession(): string | undefined;
31
- export declare function setSession(session: string): void;
32
- export declare function removeSession(): void;
33
- export declare function clearAllAppInfo(): void;
34
- export declare class CLIKitStore extends Conf<ConfSchema> {
35
- getAppInfo(directory: string): CachedAppInfo | undefined;
36
- setAppInfo(options: {
37
- directory: string;
38
- appId?: string;
39
- title?: string;
40
- storeFqdn?: string;
41
- orgId?: string;
42
- updateURLs?: boolean;
43
- tunnelPlugin?: string;
44
- }): void;
45
- clearAppInfo(directory: string): void;
46
- clearAllAppInfo(): void;
47
- getThemeStore(): string | undefined;
48
- setThemeStore(themeStore: string): void;
49
- getSession(): string | undefined;
50
- setSession(session: string): void;
51
- removeSession(): void;
52
- }
53
- export {};
package/dist/store.js DELETED
@@ -1,133 +0,0 @@
1
- import { content, token, debug } from './output.js';
2
- import { CLI_KIT_VERSION } from './public/common/version.js';
3
- import Conf from 'conf';
4
- const migrations = {};
5
- const schema = {
6
- appInfo: {
7
- type: 'array',
8
- items: {
9
- type: 'object',
10
- properties: {
11
- appId: {
12
- type: 'string',
13
- },
14
- orgId: {
15
- type: 'string',
16
- },
17
- storeFqdn: {
18
- type: 'string',
19
- },
20
- },
21
- },
22
- },
23
- };
24
- let _instance;
25
- export function cliKitStore() {
26
- if (!_instance) {
27
- _instance = new CLIKitStore({
28
- schema,
29
- migrations,
30
- projectName: 'shopify-cli-kit',
31
- projectVersion: CLI_KIT_VERSION,
32
- });
33
- }
34
- return _instance;
35
- }
36
- export function getAppInfo(directory) {
37
- const store = cliKitStore();
38
- return store.getAppInfo(directory);
39
- }
40
- export function setAppInfo(options) {
41
- const store = cliKitStore();
42
- store.setAppInfo(options);
43
- }
44
- export function clearAppInfo(directory) {
45
- const store = cliKitStore();
46
- store.clearAppInfo(directory);
47
- }
48
- export function getThemeStore() {
49
- const store = cliKitStore();
50
- return store.getThemeStore();
51
- }
52
- export function setThemeStore(themeStore) {
53
- const store = cliKitStore();
54
- store.setThemeStore(themeStore);
55
- }
56
- export function getSession() {
57
- const store = cliKitStore();
58
- return store.getSession();
59
- }
60
- export function setSession(session) {
61
- const store = cliKitStore();
62
- store.setSession(session);
63
- }
64
- export function removeSession() {
65
- const store = cliKitStore();
66
- store.removeSession();
67
- }
68
- export function clearAllAppInfo() {
69
- const store = cliKitStore();
70
- store.clearAllAppInfo();
71
- }
72
- export class CLIKitStore extends Conf {
73
- getAppInfo(directory) {
74
- debug(content `Reading cached app information for directory ${token.path(directory)}...`);
75
- const apps = this.get('appInfo') ?? [];
76
- return apps.find((app) => app.directory === directory);
77
- }
78
- setAppInfo(options) {
79
- debug(content `Storing app information for directory ${token.path(options.directory)}:${token.json(options)}`);
80
- const apps = this.get('appInfo') ?? [];
81
- const index = apps.findIndex((saved) => saved.directory === options.directory);
82
- if (index === -1) {
83
- apps.push(options);
84
- }
85
- else {
86
- const app = apps[index];
87
- apps[index] = {
88
- directory: options.directory,
89
- appId: options.appId ?? app.appId,
90
- title: options.title ?? app.title,
91
- storeFqdn: options.storeFqdn ?? app.storeFqdn,
92
- orgId: options.orgId ?? app.orgId,
93
- updateURLs: options.updateURLs ?? app.updateURLs,
94
- tunnelPlugin: options.tunnelPlugin ?? app.tunnelPlugin,
95
- };
96
- }
97
- this.set('appInfo', apps);
98
- }
99
- clearAppInfo(directory) {
100
- debug(content `Clearing app information for directory ${token.path(directory)}...`);
101
- const apps = this.get('appInfo') ?? [];
102
- const index = apps.findIndex((saved) => saved.directory === directory);
103
- if (index !== -1) {
104
- apps.splice(index, 1);
105
- }
106
- this.set('appInfo', apps);
107
- }
108
- clearAllAppInfo() {
109
- debug(content `Clearing all app information...`);
110
- this.set('appInfo', []);
111
- }
112
- getThemeStore() {
113
- debug(content `Getting theme store...`);
114
- return this.get('themeStore');
115
- }
116
- setThemeStore(themeStore) {
117
- debug(content `Setting theme store...`);
118
- this.set('themeStore', themeStore);
119
- }
120
- getSession() {
121
- debug(content `Getting session store...`);
122
- return this.get('sessionStore');
123
- }
124
- setSession(session) {
125
- debug(content `Setting session store...`);
126
- this.set('sessionStore', session);
127
- }
128
- removeSession() {
129
- debug(content `Removing session store...`);
130
- this.set('sessionStore', '');
131
- }
132
- }
133
- //# sourceMappingURL=store.js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CAAC,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA;QACrF,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;SACtB;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,eAAe;QACb,KAAK,CAAC,OAAO,CAAA,iCAAiC,CAAC,CAAA;QAC/C,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IACzB,CAAC;IAED,aAAa;QACX,KAAK,CAAC,OAAO,CAAA,wBAAwB,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC/B,CAAC;IAED,aAAa,CAAC,UAAkB;QAC9B,KAAK,CAAC,OAAO,CAAA,wBAAwB,CAAC,CAAA;QACtC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACpC,CAAC;IAED,UAAU;QACR,KAAK,CAAC,OAAO,CAAA,0BAA0B,CAAC,CAAA;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IACjC,CAAC;IAED,UAAU,CAAC,OAAe;QACxB,KAAK,CAAC,OAAO,CAAA,0BAA0B,CAAC,CAAA;QACxC,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;IACnC,CAAC;IAED,aAAa;QACX,KAAK,CAAC,OAAO,CAAA,2BAA2B,CAAC,CAAA;QACzC,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import {content, token, debug} from './output.js'\nimport {CLI_KIT_VERSION} from './public/common/version.js'\nimport Conf, {Schema} from 'conf'\n\nconst migrations = {}\n\nexport interface CachedAppInfo {\n directory: string\n appId?: string\n title?: string\n orgId?: string\n storeFqdn?: string\n updateURLs?: boolean\n tunnelPlugin?: string\n}\n\ninterface ConfSchema {\n appInfo: CachedAppInfo[]\n themeStore: string\n session: string\n}\n\nconst schema = {\n appInfo: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n appId: {\n type: 'string',\n },\n orgId: {\n type: 'string',\n },\n storeFqdn: {\n type: 'string',\n },\n },\n },\n },\n} as unknown as Schema<ConfSchema>\n\nlet _instance: CLIKitStore | undefined\n\nexport function cliKitStore() {\n if (!_instance) {\n _instance = new CLIKitStore({\n schema,\n migrations,\n projectName: 'shopify-cli-kit',\n projectVersion: CLI_KIT_VERSION,\n })\n }\n return _instance\n}\n\nexport function getAppInfo(directory: string): CachedAppInfo | undefined {\n const store = cliKitStore()\n return store.getAppInfo(directory)\n}\n\nexport function setAppInfo(options: {\n directory: string\n appId?: string\n title?: string\n storeFqdn?: string\n orgId?: string\n updateURLs?: boolean\n tunnelPlugin?: string\n}): void {\n const store = cliKitStore()\n store.setAppInfo(options)\n}\n\nexport function clearAppInfo(directory: string): void {\n const store = cliKitStore()\n store.clearAppInfo(directory)\n}\n\nexport function getThemeStore(): string | undefined {\n const store = cliKitStore()\n return store.getThemeStore()\n}\n\nexport function setThemeStore(themeStore: string): void {\n const store = cliKitStore()\n store.setThemeStore(themeStore)\n}\n\nexport function getSession(): string | undefined {\n const store = cliKitStore()\n return store.getSession()\n}\n\nexport function setSession(session: string): void {\n const store = cliKitStore()\n store.setSession(session)\n}\n\nexport function removeSession(): void {\n const store = cliKitStore()\n store.removeSession()\n}\n\nexport function clearAllAppInfo(): void {\n const store = cliKitStore()\n store.clearAllAppInfo()\n}\n\nexport class CLIKitStore extends Conf<ConfSchema> {\n getAppInfo(directory: string): CachedAppInfo | undefined {\n debug(content`Reading cached app information for directory ${token.path(directory)}...`)\n const apps = this.get('appInfo') ?? []\n return apps.find((app: CachedAppInfo) => app.directory === directory)\n }\n\n setAppInfo(options: {\n directory: string\n appId?: string\n title?: string\n storeFqdn?: string\n orgId?: string\n updateURLs?: boolean\n tunnelPlugin?: string\n }): void {\n debug(content`Storing app information for directory ${token.path(options.directory)}:${token.json(options)}`)\n const apps = this.get('appInfo') ?? []\n const index = apps.findIndex((saved: CachedAppInfo) => saved.directory === options.directory)\n if (index === -1) {\n apps.push(options)\n } else {\n const app: CachedAppInfo = apps[index]!\n apps[index] = {\n directory: options.directory,\n appId: options.appId ?? app.appId,\n title: options.title ?? app.title,\n storeFqdn: options.storeFqdn ?? app.storeFqdn,\n orgId: options.orgId ?? app.orgId,\n updateURLs: options.updateURLs ?? app.updateURLs,\n tunnelPlugin: options.tunnelPlugin ?? app.tunnelPlugin,\n }\n }\n this.set('appInfo', apps)\n }\n\n clearAppInfo(directory: string): void {\n debug(content`Clearing app information for directory ${token.path(directory)}...`)\n const apps = this.get('appInfo') ?? []\n const index = apps.findIndex((saved: CachedAppInfo) => saved.directory === directory)\n if (index !== -1) {\n apps.splice(index, 1)\n }\n this.set('appInfo', apps)\n }\n\n clearAllAppInfo(): void {\n debug(content`Clearing all app information...`)\n this.set('appInfo', [])\n }\n\n getThemeStore(): string | undefined {\n debug(content`Getting theme store...`)\n return this.get('themeStore')\n }\n\n setThemeStore(themeStore: string): void {\n debug(content`Setting theme store...`)\n this.set('themeStore', themeStore)\n }\n\n getSession(): string | undefined {\n debug(content`Getting session store...`)\n return this.get('sessionStore')\n }\n\n setSession(session: string): void {\n debug(content`Setting session store...`)\n this.set('sessionStore', session)\n }\n\n removeSession(): void {\n debug(content`Removing session store...`)\n this.set('sessionStore', '')\n }\n}\n"]}