@shopify/cli-kit 3.17.0 → 3.18.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/CHANGELOG.md +14 -0
- package/assets/success.html +1 -1
- package/dist/content-tokens.js.map +1 -1
- package/dist/environment/service.d.ts +1 -0
- package/dist/environment/service.js +3 -0
- package/dist/environment/service.js.map +1 -1
- package/dist/environment.d.ts +3 -1
- package/dist/environment.js +3 -1
- package/dist/environment.js.map +1 -1
- package/dist/error.js +3 -2
- package/dist/error.js.map +1 -1
- package/dist/git.js +4 -1
- package/dist/git.js.map +1 -1
- package/dist/node/cli.js +1 -1
- package/dist/node/cli.js.map +1 -1
- package/dist/node/colors.d.ts +2 -1
- package/dist/node/colors.js +2 -7
- package/dist/node/colors.js.map +1 -1
- package/dist/node/ruby.js +1 -1
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +10 -16
- package/dist/output.js +4 -122
- package/dist/output.js.map +1 -1
- package/dist/private/node/ui/alert.d.ts +2 -0
- package/dist/private/node/ui/alert.js +18 -0
- package/dist/private/node/ui/alert.js.map +1 -0
- package/dist/private/node/ui/components/Alert.d.ts +17 -0
- package/dist/private/node/ui/components/Alert.js +21 -0
- package/dist/private/node/ui/components/Alert.js.map +1 -0
- package/dist/private/node/ui/components/Banner.d.ts +7 -0
- package/dist/private/node/ui/components/Banner.js +35 -0
- package/dist/private/node/ui/components/Banner.js.map +1 -0
- package/dist/private/node/ui/components/Command.d.ts +9 -0
- package/dist/private/node/ui/components/Command.js +10 -0
- package/dist/private/node/ui/components/Command.js.map +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +48 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js +98 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -0
- package/dist/private/node/ui/components/Error.d.ts +8 -0
- package/dist/private/node/ui/components/Error.js +13 -0
- package/dist/private/node/ui/components/Error.js.map +1 -0
- package/dist/private/node/ui/components/FatalError.d.ts +7 -0
- package/dist/private/node/ui/components/FatalError.js +42 -0
- package/dist/private/node/ui/components/FatalError.js.map +1 -0
- package/dist/private/node/ui/components/FullScreen.d.ts +8 -0
- package/dist/private/node/ui/components/FullScreen.js +32 -0
- package/dist/private/node/ui/components/FullScreen.js.map +1 -0
- package/dist/private/node/ui/components/Link.d.ts +10 -0
- package/dist/private/node/ui/components/Link.js +14 -0
- package/dist/private/node/ui/components/Link.js.map +1 -0
- package/dist/private/node/ui/components/List.d.ts +13 -0
- package/dist/private/node/ui/components/List.js +19 -0
- package/dist/private/node/ui/components/List.js.map +1 -0
- package/dist/private/node/ui/components/TextAnimation.d.ts +11 -0
- package/dist/private/node/ui/components/TextAnimation.js +46 -0
- package/dist/private/node/ui/components/TextAnimation.js.map +1 -0
- package/dist/private/node/ui/components/TokenizedText.d.ts +21 -0
- package/dist/private/node/ui/components/TokenizedText.js +26 -0
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -0
- package/dist/private/node/ui/error.d.ts +4 -0
- package/dist/private/node/ui/error.js +12 -0
- package/dist/private/node/ui/error.js.map +1 -0
- package/dist/private/node/ui.d.ts +10 -0
- package/dist/private/node/ui.js +47 -0
- package/dist/private/node/ui.js.map +1 -0
- package/dist/public/node/ui.d.ts +155 -0
- package/dist/public/node/ui.js +163 -0
- package/dist/public/node/ui.js.map +1 -0
- package/dist/session.js +2 -2
- package/dist/session.js.map +1 -1
- package/dist/system.d.ts +2 -5
- package/dist/system.js +19 -19
- package/dist/system.js.map +1 -1
- package/dist/testing/fixtures/render-concurrent.d.ts +1 -0
- package/dist/testing/fixtures/render-concurrent.js +28 -0
- package/dist/testing/fixtures/render-concurrent.js.map +1 -0
- package/dist/testing/output.d.ts +1 -0
- package/dist/testing/output.js +1 -0
- package/dist/testing/output.js.map +1 -1
- package/dist/testing/ui.d.ts +8 -0
- package/dist/testing/ui.js +17 -0
- package/dist/testing/ui.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/input.d.ts +1 -1
- package/package.json +9 -2
package/dist/output.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import { Bug, cleanSingleStackTracePath } from './error.js';
|
|
3
2
|
import { isUnitTest, isVerbose } from './environment/local.js';
|
|
4
3
|
import { colors } from './node/colors.js';
|
|
5
4
|
import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from './content-tokens.js';
|
|
6
5
|
import { logToFile } from './log.js';
|
|
7
|
-
import StackTracey from 'stacktracey';
|
|
8
|
-
import { AbortController } from 'abort-controller';
|
|
9
6
|
import stripAnsi from 'strip-ansi';
|
|
10
|
-
import { Writable } from 'node:stream';
|
|
11
7
|
export { default as logUpdate } from 'log-update';
|
|
12
8
|
export class TokenizedString {
|
|
13
9
|
constructor(value) {
|
|
@@ -162,7 +158,7 @@ export let collectedLogs = {};
|
|
|
162
158
|
* @param key - The key of the log.
|
|
163
159
|
* @param content - The content of the log.
|
|
164
160
|
*/
|
|
165
|
-
const collectLog = (key, content) => {
|
|
161
|
+
export const collectLog = (key, content) => {
|
|
166
162
|
const output = collectedLogs.output ?? [];
|
|
167
163
|
const data = collectedLogs[key] ?? [];
|
|
168
164
|
data.push(stripAnsi(stringifyMessage(content) ?? ''));
|
|
@@ -244,62 +240,6 @@ export const warn = (content, logger = consoleWarn) => {
|
|
|
244
240
|
export const newline = () => {
|
|
245
241
|
console.log();
|
|
246
242
|
};
|
|
247
|
-
/**
|
|
248
|
-
* Formats and outputs a fatal error.
|
|
249
|
-
* Note: This API is not intended to be used internally. If you want to
|
|
250
|
-
* abort the execution due to an error, raise a fatal error and let the
|
|
251
|
-
* error handler handle and format it.
|
|
252
|
-
* @param content - The fatal error to be output.
|
|
253
|
-
*/
|
|
254
|
-
export const error = async (content) => {
|
|
255
|
-
if (!content.message) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
let outputString = '';
|
|
259
|
-
const message = content.message;
|
|
260
|
-
const padding = ' ';
|
|
261
|
-
const header = colors.redBright(`\n━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`);
|
|
262
|
-
const footer = colors.redBright('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
263
|
-
outputString += header;
|
|
264
|
-
const lines = message.split('\n');
|
|
265
|
-
for (const line of lines) {
|
|
266
|
-
outputString += `${padding}${line}\n`;
|
|
267
|
-
}
|
|
268
|
-
if (content.tryMessage) {
|
|
269
|
-
outputString += `\n${padding}${colors.bold('What to try:')}\n`;
|
|
270
|
-
const lines = content.tryMessage.split('\n');
|
|
271
|
-
for (const line of lines) {
|
|
272
|
-
outputString += `${padding}${line}\n`;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
let stack = new StackTracey(content);
|
|
276
|
-
stack.items.forEach((item) => {
|
|
277
|
-
item.file = cleanSingleStackTracePath(item.file);
|
|
278
|
-
});
|
|
279
|
-
stack = await stack.withSourcesAsync();
|
|
280
|
-
stack = stack
|
|
281
|
-
.filter((entry) => {
|
|
282
|
-
return !entry.file.includes('@oclif/core');
|
|
283
|
-
})
|
|
284
|
-
.map((item) => {
|
|
285
|
-
item.calleeShort = colors.yellow(item.calleeShort);
|
|
286
|
-
/** We make the paths relative to the packages/ directory */
|
|
287
|
-
const fileShortComponents = item.fileShort.split('packages/');
|
|
288
|
-
item.fileShort = fileShortComponents.length === 2 ? fileShortComponents[1] : fileShortComponents[0];
|
|
289
|
-
return item;
|
|
290
|
-
});
|
|
291
|
-
if (content instanceof Bug) {
|
|
292
|
-
if (stack.items.length !== 0) {
|
|
293
|
-
outputString += `\n${padding}${colors.bold('Stack trace:')}\n`;
|
|
294
|
-
const stackLines = stack.asTable({}).split('\n');
|
|
295
|
-
for (const stackLine of stackLines) {
|
|
296
|
-
outputString += `${padding}${stackLine}\n`;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
outputString += footer;
|
|
301
|
-
outputWhereAppropriate('error', consoleError, outputString);
|
|
302
|
-
};
|
|
303
243
|
export function stringifyMessage(message) {
|
|
304
244
|
if (message instanceof TokenizedString) {
|
|
305
245
|
return message.value;
|
|
@@ -312,53 +252,6 @@ const message = (content, level = 'info') => {
|
|
|
312
252
|
const stringifiedMessage = stringifyMessage(content);
|
|
313
253
|
outputWhereAppropriate(level, consoleLog, stringifiedMessage);
|
|
314
254
|
};
|
|
315
|
-
/**
|
|
316
|
-
* Use this function when you have multiple concurrent processes that send data events
|
|
317
|
-
* and we need to output them ensuring that they can visually differenciated by the user.
|
|
318
|
-
*
|
|
319
|
-
* @param processes - A list of processes to run concurrently.
|
|
320
|
-
*/
|
|
321
|
-
export async function concurrent(processes, callback = undefined) {
|
|
322
|
-
const abortController = new AbortController();
|
|
323
|
-
// eslint-disable-next-line node/callback-return
|
|
324
|
-
if (callback)
|
|
325
|
-
callback(abortController.signal);
|
|
326
|
-
const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green];
|
|
327
|
-
const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length));
|
|
328
|
-
function linePrefix(prefix, index) {
|
|
329
|
-
const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length;
|
|
330
|
-
const color = concurrentColors[colorIndex];
|
|
331
|
-
return color(`${prefix}${' '.repeat(prefixColumnSize - prefix.length)} ${colors.bold('|')} `);
|
|
332
|
-
}
|
|
333
|
-
try {
|
|
334
|
-
await Promise.all(processes.map(async (process, index) => {
|
|
335
|
-
const stdout = new Writable({
|
|
336
|
-
write(chunk, _encoding, next) {
|
|
337
|
-
const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\n/);
|
|
338
|
-
for (const line of lines) {
|
|
339
|
-
info(content `${linePrefix(process.prefix, index)}${line}`);
|
|
340
|
-
}
|
|
341
|
-
next();
|
|
342
|
-
},
|
|
343
|
-
});
|
|
344
|
-
const stderr = new Writable({
|
|
345
|
-
write(chunk, _encoding, next) {
|
|
346
|
-
const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\n/);
|
|
347
|
-
for (const line of lines) {
|
|
348
|
-
message(content `${linePrefix(process.prefix, index)}${colors.bold(line)}`, 'error');
|
|
349
|
-
}
|
|
350
|
-
next();
|
|
351
|
-
},
|
|
352
|
-
});
|
|
353
|
-
await process.action(stdout, stderr, abortController.signal);
|
|
354
|
-
}));
|
|
355
|
-
}
|
|
356
|
-
catch (_error) {
|
|
357
|
-
// We abort any running process
|
|
358
|
-
abortController.abort();
|
|
359
|
-
throw _error;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
255
|
/**
|
|
363
256
|
* This regex can be used to find the erase cursor Ansii characters
|
|
364
257
|
* to strip them from the string.
|
|
@@ -372,27 +265,16 @@ const eraseCursorAnsiRegex = [
|
|
|
372
265
|
]
|
|
373
266
|
.map((element) => `[\\u001B\\u009B][[\\]()#;?]*${element}`)
|
|
374
267
|
.join('|');
|
|
375
|
-
/**
|
|
376
|
-
* The data sent through the standard pipelines of the sub-processes that we execute
|
|
377
|
-
* might contain ansii escape characters to move the cursor. That causes any additional
|
|
378
|
-
* formatting to break. This function takes a string and strips escape characters that
|
|
379
|
-
* manage the cursor in the terminal.
|
|
380
|
-
* @param value - String whose erase cursor escape characters will be stripped.
|
|
381
|
-
* @returns Stripped string.
|
|
382
|
-
*/
|
|
383
|
-
function stripAnsiEraseCursorEscapeCharacters(value) {
|
|
384
|
-
return value.replace(/(\n)$/, '').replace(new RegExp(eraseCursorAnsiRegex, 'g'), '');
|
|
385
|
-
}
|
|
386
268
|
export function consoleLog(message) {
|
|
387
269
|
console.log(withOrWithoutStyle(message));
|
|
388
270
|
}
|
|
389
271
|
export function consoleError(message) {
|
|
390
272
|
console.error(withOrWithoutStyle(message));
|
|
391
273
|
}
|
|
392
|
-
function consoleWarn(message) {
|
|
274
|
+
export function consoleWarn(message) {
|
|
393
275
|
console.warn(withOrWithoutStyle(message));
|
|
394
276
|
}
|
|
395
|
-
function outputWhereAppropriate(logLevel, logger, message) {
|
|
277
|
+
export function outputWhereAppropriate(logLevel, logger, message) {
|
|
396
278
|
if (shouldOutput(logLevel)) {
|
|
397
279
|
logger(message);
|
|
398
280
|
}
|
|
@@ -407,7 +289,7 @@ function withOrWithoutStyle(message) {
|
|
|
407
289
|
}
|
|
408
290
|
}
|
|
409
291
|
export function unstyled(message) {
|
|
410
|
-
return
|
|
292
|
+
return stripAnsi(message);
|
|
411
293
|
}
|
|
412
294
|
export function shouldDisplayColors() {
|
|
413
295
|
return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR);
|
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,EAAQ,GAAG,EAAE,yBAAyB,EAAC,MAAM,YAAY,CAAA;AAChE,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,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,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAClC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,eAAe,EAAc,MAAM,kBAAkB,CAAA;AAC7D,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;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AAG,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 {Fatal, Bug, cleanSingleStackTracePath} from './error.js'\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './node/node-package-manager.js'\nimport {colors} from './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 {logToFile} from './log.js'\nimport StackTracey from 'stacktracey'\nimport {AbortController, 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 = (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\nfunction formatPackageManagerCommand(packageManager: PackageManager, scriptName: string, scriptArgs: string[]): 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 */\nconst 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, 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\n/**\n * Formats and outputs a fatal error.\n * Note: This API is not intended to be used internally. If you want to\n * abort the execution due to an error, raise a fatal error and let the\n * error handler handle and format it.\n * @param content - The fatal error to be output.\n */\nexport const error = async (content: Fatal) => {\n if (!content.message) {\n return\n }\n let outputString = ''\n const message = content.message\n const padding = ' '\n const header = colors.redBright(`\\n━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n`)\n const footer = colors.redBright('\\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n')\n outputString += header\n const lines = message.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n if (content.tryMessage) {\n outputString += `\\n${padding}${colors.bold('What to try:')}\\n`\n const lines = content.tryMessage.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n }\n\n let stack = new StackTracey(content)\n stack.items.forEach((item) => {\n item.file = cleanSingleStackTracePath(item.file)\n })\n\n stack = await stack.withSourcesAsync()\n stack = stack\n .filter((entry) => {\n return !entry.file.includes('@oclif/core')\n })\n .map((item) => {\n item.calleeShort = colors.yellow(item.calleeShort)\n /** We make the paths relative to the packages/ directory */\n const fileShortComponents = item.fileShort.split('packages/')\n item.fileShort = fileShortComponents.length === 2 ? fileShortComponents[1]! : fileShortComponents[0]!\n return item\n })\n if (content instanceof Bug) {\n if (stack.items.length !== 0) {\n outputString += `\\n${padding}${colors.bold('Stack trace:')}\\n`\n const stackLines = stack.asTable({}).split('\\n')\n for (const stackLine of stackLines) {\n outputString += `${padding}${stackLine}\\n`\n }\n }\n }\n outputString += footer\n outputWhereAppropriate('error', consoleError, outputString)\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\n/**\n * Use this function when you have multiple concurrent processes that send data events\n * and we need to output them ensuring that they can visually differenciated by the user.\n *\n * @param processes - A list of processes to run concurrently.\n */\nexport async function concurrent(\n processes: OutputProcess[],\n callback: ((signal: AbortSignal) => void) | undefined = undefined,\n) {\n const abortController = new AbortController()\n\n // eslint-disable-next-line node/callback-return\n if (callback) callback(abortController.signal)\n\n const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green]\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n\n function linePrefix(prefix: string, index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n const color = concurrentColors[colorIndex]!\n return color(`${prefix}${' '.repeat(prefixColumnSize - prefix.length)} ${colors.bold('|')} `)\n }\n\n try {\n await Promise.all(\n processes.map(async (process, index) => {\n const stdout = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n info(content`${linePrefix(process.prefix, index)}${line}`)\n }\n next()\n },\n })\n const stderr = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n message(content`${linePrefix(process.prefix, index)}${colors.bold(line)}`, 'error')\n }\n next()\n },\n })\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n } catch (_error) {\n // We abort any running process\n abortController.abort()\n throw _error\n }\n}\n\n/**\n * This regex can be used to find the erase cursor Ansii characters\n * to strip them from the string.\n * https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#erase-functions\n */\nconst eraseCursorAnsiRegex = [\n // Erase the entire line\n '2K',\n // Clear vertical tab stop at current line\n '1G',\n]\n .map((element) => `[\\\\u001B\\\\u009B][[\\\\]()#;?]*${element}`)\n .join('|')\n\n/**\n * The data sent through the standard pipelines of the sub-processes that we execute\n * might contain ansii escape characters to move the cursor. That causes any additional\n * formatting to break. This function takes a string and strips escape characters that\n * manage the cursor in the terminal.\n * @param value - String whose erase cursor escape characters will be stripped.\n * @returns Stripped string.\n */\nfunction stripAnsiEraseCursorEscapeCharacters(value: string): string {\n return value.replace(/(\\n)$/, '').replace(new RegExp(eraseCursorAnsiRegex, 'g'), '')\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\nfunction consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nfunction outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n logger(message)\n }\n logToFile(message, logLevel.toUpperCase())\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 colors.unstyle(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,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,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,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,OAAO,SAAS,MAAM,YAAY,CAAA;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AAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IACnF,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 './node/node-package-manager.js'\nimport {colors} from './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 {logToFile} from './log.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 = (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\nfunction formatPackageManagerCommand(packageManager: PackageManager, scriptName: string, scriptArgs: string[]): 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, 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\n/**\n * This regex can be used to find the erase cursor Ansii characters\n * to strip them from the string.\n * https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#erase-functions\n */\nconst eraseCursorAnsiRegex = [\n // Erase the entire line\n '2K',\n // Clear vertical tab stop at current line\n '1G',\n]\n .map((element) => `[\\\\u001B\\\\u009B][[\\\\]()#;?]*${element}`)\n .join('|')\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 logger(message)\n }\n logToFile(message, logLevel.toUpperCase())\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"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Alert } from './components/Alert.js';
|
|
2
|
+
import { renderOnce } from '../ui.js';
|
|
3
|
+
import { consoleLog, consoleWarn } from '../../../output.js';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
const typeToLogLevel = {
|
|
6
|
+
info: 'info',
|
|
7
|
+
warning: 'warn',
|
|
8
|
+
success: 'info',
|
|
9
|
+
};
|
|
10
|
+
const typeToLogger = {
|
|
11
|
+
info: consoleLog,
|
|
12
|
+
warning: consoleWarn,
|
|
13
|
+
success: consoleLog,
|
|
14
|
+
};
|
|
15
|
+
export function alert({ type, headline, body, nextSteps, reference, link, orderedNextSteps = false }) {
|
|
16
|
+
renderOnce(React.createElement(Alert, { type: type, headline: headline, body: body, nextSteps: nextSteps, reference: reference, link: link, orderedNextSteps: orderedNextSteps }), typeToLogLevel[type], typeToLogger[type]);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../../src/private/node/ui/alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAa,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,UAAU,EAAE,WAAW,EAAmB,MAAM,oBAAoB,CAAA;AAC5E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,cAAc,GAA4C;IAC9D,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;CAChB,CAAA;AAED,MAAM,YAAY,GAA0C;IAC1D,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,WAAW;IACpB,OAAO,EAAE,UAAU;CACpB,CAAA;AAED,MAAM,UAAU,KAAK,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,GAAG,KAAK,EAAa;IAC5G,UAAU,CACR,oBAAC,KAAK,IACJ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,gBAAgB,GAClC,EACF,cAAc,CAAC,IAAI,CAAC,EACpB,YAAY,CAAC,IAAI,CAAC,CACnB,CAAA;AACH,CAAC","sourcesContent":["import {Alert, AlertProps} from './components/Alert.js'\nimport {renderOnce} from '../ui.js'\nimport {consoleLog, consoleWarn, Logger, LogLevel} from '../../../output.js'\nimport React from 'react'\n\nconst typeToLogLevel: {[key in AlertProps['type']]: LogLevel} = {\n info: 'info',\n warning: 'warn',\n success: 'info',\n}\n\nconst typeToLogger: {[key in AlertProps['type']]: Logger} = {\n info: consoleLog,\n warning: consoleWarn,\n success: consoleLog,\n}\n\nexport function alert({type, headline, body, nextSteps, reference, link, orderedNextSteps = false}: AlertProps) {\n renderOnce(\n <Alert\n type={type}\n headline={headline}\n body={body}\n nextSteps={nextSteps}\n reference={reference}\n link={link}\n orderedNextSteps={orderedNextSteps}\n />,\n typeToLogLevel[type],\n typeToLogger[type],\n )\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BannerType } from './Banner.js';
|
|
2
|
+
import { TextTokenItem } from './TokenizedText.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface AlertProps {
|
|
5
|
+
type: Exclude<BannerType, 'error'>;
|
|
6
|
+
headline: string;
|
|
7
|
+
body?: TextTokenItem;
|
|
8
|
+
nextSteps?: TextTokenItem[];
|
|
9
|
+
reference?: TextTokenItem[];
|
|
10
|
+
link?: {
|
|
11
|
+
label: string;
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
orderedNextSteps?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const Alert: React.FC<AlertProps>;
|
|
17
|
+
export { Alert };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Banner } from './Banner.js';
|
|
2
|
+
import { Link } from './Link.js';
|
|
3
|
+
import { List } from './List.js';
|
|
4
|
+
import { TokenizedText } from './TokenizedText.js';
|
|
5
|
+
import { Box, Text } from 'ink';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
const Alert = ({ type, headline, body, nextSteps, reference, link, orderedNextSteps = false }) => {
|
|
8
|
+
return (React.createElement(Banner, { type: type },
|
|
9
|
+
React.createElement(Box, null,
|
|
10
|
+
React.createElement(Text, null, headline)),
|
|
11
|
+
body && (React.createElement(Box, { marginTop: 1 },
|
|
12
|
+
React.createElement(TokenizedText, { item: body }))),
|
|
13
|
+
nextSteps && (React.createElement(Box, { marginTop: 1 },
|
|
14
|
+
React.createElement(List, { title: "Next steps", items: nextSteps, ordered: orderedNextSteps }))),
|
|
15
|
+
reference && (React.createElement(Box, { marginTop: 1 },
|
|
16
|
+
React.createElement(List, { title: "Reference", items: reference }))),
|
|
17
|
+
link && (React.createElement(Box, { marginTop: 1 },
|
|
18
|
+
React.createElement(Link, { url: link.url, label: link.label })))));
|
|
19
|
+
};
|
|
20
|
+
export { Alert };
|
|
21
|
+
//# sourceMappingURL=Alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAa,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAgB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAezB,MAAM,KAAK,GAAyB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,GAAG,KAAK,EAAC,EAAE,EAAE;IACnH,OAAO,CACL,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI;QAChB,oBAAC,GAAG;YACF,oBAAC,IAAI,QAAE,QAAQ,CAAQ,CACnB;QAEL,IAAI,IAAI,CACP,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACzB,CACP;QAEA,SAAS,IAAI,CACZ,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAC,YAAY,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAI,CACpE,CACP;QAEA,SAAS,IAAI,CACZ,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAC,WAAW,EAAC,KAAK,EAAE,SAAS,GAAI,CACxC,CACP;QAEA,IAAI,IAAI,CACP,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,CACtC,CACP,CACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,KAAK,EAAC,CAAA","sourcesContent":["import {Banner, BannerType} from './Banner.js'\nimport {Link} from './Link.js'\nimport {List} from './List.js'\nimport {TextTokenItem, TokenizedText} from './TokenizedText.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport interface AlertProps {\n type: Exclude<BannerType, 'error'>\n headline: string\n body?: TextTokenItem\n nextSteps?: TextTokenItem[]\n reference?: TextTokenItem[]\n link?: {\n label: string\n url: string\n }\n orderedNextSteps?: boolean\n}\n\nconst Alert: React.FC<AlertProps> = ({type, headline, body, nextSteps, reference, link, orderedNextSteps = false}) => {\n return (\n <Banner type={type}>\n <Box>\n <Text>{headline}</Text>\n </Box>\n\n {body && (\n <Box marginTop={1}>\n <TokenizedText item={body} />\n </Box>\n )}\n\n {nextSteps && (\n <Box marginTop={1}>\n <List title=\"Next steps\" items={nextSteps} ordered={orderedNextSteps} />\n </Box>\n )}\n\n {reference && (\n <Box marginTop={1}>\n <List title=\"Reference\" items={reference} />\n </Box>\n )}\n\n {link && (\n <Box marginTop={1}>\n <Link url={link.url} label={link.label} />\n </Box>\n )}\n </Banner>\n )\n}\n\nexport {Alert}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Box, Text, useStdout } from 'ink';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
function typeToColor(type) {
|
|
4
|
+
return {
|
|
5
|
+
success: 'green',
|
|
6
|
+
error: 'red',
|
|
7
|
+
warning: 'yellow',
|
|
8
|
+
info: 'dim',
|
|
9
|
+
}[type];
|
|
10
|
+
}
|
|
11
|
+
const BANNER_MIN_WIDTH = 80;
|
|
12
|
+
function calculateWidth(stdout) {
|
|
13
|
+
const fullWidth = stdout?.columns ?? BANNER_MIN_WIDTH;
|
|
14
|
+
const twoThirdsOfWidth = Math.floor((fullWidth / 3) * 2);
|
|
15
|
+
let width;
|
|
16
|
+
if (fullWidth <= BANNER_MIN_WIDTH) {
|
|
17
|
+
width = fullWidth;
|
|
18
|
+
}
|
|
19
|
+
else if (twoThirdsOfWidth < BANNER_MIN_WIDTH) {
|
|
20
|
+
width = BANNER_MIN_WIDTH;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
width = twoThirdsOfWidth;
|
|
24
|
+
}
|
|
25
|
+
return width;
|
|
26
|
+
}
|
|
27
|
+
const Banner = ({ type, children }) => {
|
|
28
|
+
const { stdout } = useStdout();
|
|
29
|
+
return (React.createElement(Box, { width: calculateWidth(stdout), paddingY: 1, paddingX: 2, borderStyle: "round", flexDirection: "column", borderColor: typeToColor(type) },
|
|
30
|
+
React.createElement(Box, { marginTop: -2, marginBottom: 1, marginLeft: -1 },
|
|
31
|
+
React.createElement(Text, { dimColor: true, bold: true }, ` ${type} `)),
|
|
32
|
+
children));
|
|
33
|
+
};
|
|
34
|
+
export { Banner };
|
|
35
|
+
//# sourceMappingURL=Banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAC,MAAM,KAAK,CAAA;AACxC,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,SAAS,WAAW,CAAC,IAAmB;IACtC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,KAAK;KACZ,CAAC,IAAI,CAAC,CAAA;AACT,CAAC;AAED,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAE3B,SAAS,cAAc,CAAC,MAAsC;IAC5D,MAAM,SAAS,GAAG,MAAM,EAAE,OAAO,IAAI,gBAAgB,CAAA;IACrD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACxD,IAAI,KAAK,CAAA;IAET,IAAI,SAAS,IAAI,gBAAgB,EAAE;QACjC,KAAK,GAAG,SAAS,CAAA;KAClB;SAAM,IAAI,gBAAgB,GAAG,gBAAgB,EAAE;QAC9C,KAAK,GAAG,gBAAgB,CAAA;KACzB;SAAM;QACL,KAAK,GAAG,gBAAgB,CAAA;KACzB;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,MAAM,GAAoB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE;IACnD,MAAM,EAAC,MAAM,EAAC,GAAG,SAAS,EAAE,CAAA;IAE5B,OAAO,CACL,oBAAC,GAAG,IACF,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,EAC7B,QAAQ,EAAE,CAAC,EACX,QAAQ,EAAE,CAAC,EACX,WAAW,EAAC,OAAO,EACnB,aAAa,EAAC,QAAQ,EACtB,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC;QAE9B,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YACjD,oBAAC,IAAI,IAAC,QAAQ,QAAC,IAAI,UAAE,IAAI,IAAI,GAAG,CAAQ,CACpC;QACL,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import {Box, Text, useStdout} from 'ink'\nimport React from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info'\n\ninterface Props {\n type: BannerType\n}\n\nfunction typeToColor(type: Props['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n }[type]\n}\n\nconst BANNER_MIN_WIDTH = 80\n\nfunction calculateWidth(stdout: NodeJS.WriteStream | undefined) {\n const fullWidth = stdout?.columns ?? BANNER_MIN_WIDTH\n const twoThirdsOfWidth = Math.floor((fullWidth / 3) * 2)\n let width\n\n if (fullWidth <= BANNER_MIN_WIDTH) {\n width = fullWidth\n } else if (twoThirdsOfWidth < BANNER_MIN_WIDTH) {\n width = BANNER_MIN_WIDTH\n } else {\n width = twoThirdsOfWidth\n }\n\n return width\n}\n\nconst Banner: React.FC<Props> = ({type, children}) => {\n const {stdout} = useStdout()\n\n return (\n <Box\n width={calculateWidth(stdout)}\n paddingY={1}\n paddingX={2}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-2} marginBottom={1} marginLeft={-1}>\n <Text dimColor bold>{` ${type} `}</Text>\n </Box>\n {children}\n </Box>\n )\n}\n\nexport {Banner}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Text } from 'ink';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* `Command` displays a command as non-dimmed text.
|
|
5
|
+
*/
|
|
6
|
+
const Command = ({ command }) => {
|
|
7
|
+
return React.createElement(Text, null, command);
|
|
8
|
+
};
|
|
9
|
+
export { Command };
|
|
10
|
+
//# sourceMappingURL=Command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;GAEG;AACH,MAAM,OAAO,GAAoB,CAAC,EAAC,OAAO,EAAiC,EAAe,EAAE;IAC1F,OAAO,oBAAC,IAAI,QAAE,OAAO,CAAQ,CAAA;AAC/B,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n command: string\n}\n\n/**\n * `Command` displays a command as non-dimmed text.\n */\nconst Command: React.FC<Props> = ({command}: React.PropsWithChildren<Props>): JSX.Element => {\n return <Text>{command}</Text>\n}\n\nexport {Command}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { OutputProcess } from '../../../../output.js';
|
|
3
|
+
import { FunctionComponent } from 'react';
|
|
4
|
+
import AbortController from 'abort-controller';
|
|
5
|
+
import { Writable } from 'node:stream';
|
|
6
|
+
export declare type WritableStream = (process: OutputProcess, index: number) => Writable;
|
|
7
|
+
export declare type RunProcesses = (writableStream: WritableStream, unmountInk: (error?: Error | undefined) => void) => Promise<void>;
|
|
8
|
+
interface Props {
|
|
9
|
+
processes: OutputProcess[];
|
|
10
|
+
abortController: AbortController;
|
|
11
|
+
showTimestamps?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Renders output from concurrent processes to the terminal.
|
|
15
|
+
* Output will be divided in a three column layout
|
|
16
|
+
* with the left column containing the timestamp,
|
|
17
|
+
* the right column containing the output,
|
|
18
|
+
* and the middle column containing the process prefix.
|
|
19
|
+
* Every process will be rendered with a different color, up to 4 colors.
|
|
20
|
+
*
|
|
21
|
+
* For example running `shopify app dev`:
|
|
22
|
+
*
|
|
23
|
+
* ```shell
|
|
24
|
+
* 2022-10-10 13:11:03 | backend | npm
|
|
25
|
+
* 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...
|
|
26
|
+
* 2022-10-10 13:11:03 | backend |
|
|
27
|
+
* 2022-10-10 13:11:03 | backend |
|
|
28
|
+
* 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev
|
|
29
|
+
* 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend
|
|
30
|
+
* 2022-10-10 13:11:03 | backend |
|
|
31
|
+
* 2022-10-10 13:11:03 | backend |
|
|
32
|
+
* 2022-10-10 13:11:03 | frontend |
|
|
33
|
+
* 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev
|
|
34
|
+
* 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js
|
|
35
|
+
* 2022-10-10 13:11:03 | frontend |
|
|
36
|
+
* 2022-10-10 13:11:03 | frontend |
|
|
37
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] 2.0.19
|
|
38
|
+
* 2022-10-10 13:11:03 | backend |
|
|
39
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`
|
|
40
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/
|
|
41
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json
|
|
42
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`
|
|
43
|
+
* 2022-10-10 13:11:03 | backend |
|
|
44
|
+
*
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare const ConcurrentOutput: FunctionComponent<Props>;
|
|
48
|
+
export default ConcurrentOutput;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Box, Static, Text, useApp } from 'ink';
|
|
3
|
+
import stripAnsi from 'strip-ansi';
|
|
4
|
+
import { Writable } from 'node:stream';
|
|
5
|
+
const OUTPUT_MIN_WIDTH = 80;
|
|
6
|
+
/**
|
|
7
|
+
* Renders output from concurrent processes to the terminal.
|
|
8
|
+
* Output will be divided in a three column layout
|
|
9
|
+
* with the left column containing the timestamp,
|
|
10
|
+
* the right column containing the output,
|
|
11
|
+
* and the middle column containing the process prefix.
|
|
12
|
+
* Every process will be rendered with a different color, up to 4 colors.
|
|
13
|
+
*
|
|
14
|
+
* For example running `shopify app dev`:
|
|
15
|
+
*
|
|
16
|
+
* ```shell
|
|
17
|
+
* 2022-10-10 13:11:03 | backend | npm
|
|
18
|
+
* 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...
|
|
19
|
+
* 2022-10-10 13:11:03 | backend |
|
|
20
|
+
* 2022-10-10 13:11:03 | backend |
|
|
21
|
+
* 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev
|
|
22
|
+
* 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend
|
|
23
|
+
* 2022-10-10 13:11:03 | backend |
|
|
24
|
+
* 2022-10-10 13:11:03 | backend |
|
|
25
|
+
* 2022-10-10 13:11:03 | frontend |
|
|
26
|
+
* 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev
|
|
27
|
+
* 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js
|
|
28
|
+
* 2022-10-10 13:11:03 | frontend |
|
|
29
|
+
* 2022-10-10 13:11:03 | frontend |
|
|
30
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] 2.0.19
|
|
31
|
+
* 2022-10-10 13:11:03 | backend |
|
|
32
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`
|
|
33
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/
|
|
34
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json
|
|
35
|
+
* 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`
|
|
36
|
+
* 2022-10-10 13:11:03 | backend |
|
|
37
|
+
*
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
const ConcurrentOutput = ({ processes, abortController, showTimestamps = true }) => {
|
|
41
|
+
const [processOutput, setProcessOutput] = useState([]);
|
|
42
|
+
const concurrentColors = ['yellow', 'cyan', 'magenta', 'green', 'blue'];
|
|
43
|
+
const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length));
|
|
44
|
+
const { exit: unmountInk } = useApp();
|
|
45
|
+
function lineColor(index) {
|
|
46
|
+
const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length;
|
|
47
|
+
return concurrentColors[colorIndex];
|
|
48
|
+
}
|
|
49
|
+
const writableStream = (process, index) => {
|
|
50
|
+
return new Writable({
|
|
51
|
+
write(chunk, _encoding, next) {
|
|
52
|
+
const lines = stripAnsi(chunk.toString('ascii')).split(/\n/);
|
|
53
|
+
setProcessOutput((previousProcessOutput) => [
|
|
54
|
+
...previousProcessOutput,
|
|
55
|
+
{
|
|
56
|
+
color: lineColor(index),
|
|
57
|
+
prefix: process.prefix,
|
|
58
|
+
lines,
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
next();
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const runProcesses = async () => {
|
|
66
|
+
try {
|
|
67
|
+
await Promise.all(processes.map(async (process, index) => {
|
|
68
|
+
const stdout = writableStream(process, index);
|
|
69
|
+
const stderr = writableStream(process, index);
|
|
70
|
+
await process.action(stdout, stderr, abortController.signal);
|
|
71
|
+
}));
|
|
72
|
+
unmountInk();
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
abortController.abort();
|
|
76
|
+
unmountInk();
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
82
|
+
runProcesses();
|
|
83
|
+
}, []);
|
|
84
|
+
return (React.createElement(Static, { items: processOutput }, (chunk, index) => {
|
|
85
|
+
return (React.createElement(Box, { flexDirection: "column", key: index }, chunk.lines.map((line, index) => (React.createElement(Box, { key: index, flexDirection: "row" },
|
|
86
|
+
showTimestamps && (React.createElement(Box, null,
|
|
87
|
+
React.createElement(Box, { marginRight: 1 },
|
|
88
|
+
React.createElement(Text, { color: chunk.color }, new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''))),
|
|
89
|
+
React.createElement(Text, { bold: true, color: chunk.color }, "|"))),
|
|
90
|
+
React.createElement(Box, { width: prefixColumnSize, marginX: 1 },
|
|
91
|
+
React.createElement(Text, { color: chunk.color }, chunk.prefix)),
|
|
92
|
+
React.createElement(Text, { bold: true, color: chunk.color }, "|"),
|
|
93
|
+
React.createElement(Box, { flexGrow: 1, paddingLeft: 1 },
|
|
94
|
+
React.createElement(Text, { color: chunk.color }, line)))))));
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
export default ConcurrentOutput;
|
|
98
|
+
//# sourceMappingURL=ConcurrentOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAoB,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AACnE,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,KAAK,CAAA;AAC7C,OAAO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,GAAG;gBACF,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC;oBACjB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAQ,CAC7F;gBAEN,oBAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,KAAK,CAAC,KAAK,QAEtB,CACH,CACP;YAED,oBAAC,GAAG,IAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC;gBACtC,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAG,KAAK,CAAC,MAAM,CAAQ,CAC3C;YAEN,oBAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,KAAK,CAAC,KAAK,QAEtB;YAEP,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;gBAC9B,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAG,IAAI,CAAQ,CACnC,CACF,CACP,CAAC,CACE,CACP,CAAA;IACH,CAAC,CACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA","sourcesContent":["import {OutputProcess} from '../../../../output.js'\nimport React, {FunctionComponent, useEffect, useState} from 'react'\nimport {Box, Static, Text, useApp} from 'ink'\nimport stripAnsi from 'strip-ansi'\nimport AbortController from 'abort-controller'\nimport {Writable} from 'node:stream'\n\nexport type WritableStream = (process: OutputProcess, index: number) => Writable\nexport type RunProcesses = (\n writableStream: WritableStream,\n unmountInk: (error?: Error | undefined) => void,\n) => Promise<void>\n\ninterface Props {\n processes: OutputProcess[]\n abortController: AbortController\n showTimestamps?: boolean\n}\ninterface Chunk {\n color: string\n prefix: string\n lines: string[]\n}\n\nconst OUTPUT_MIN_WIDTH = 80\n\n/**\n * Renders output from concurrent processes to the terminal.\n * Output will be divided in a three column layout\n * with the left column containing the timestamp,\n * the right column containing the output,\n * and the middle column containing the process prefix.\n * Every process will be rendered with a different color, up to 4 colors.\n *\n * For example running `shopify app dev`:\n *\n * ```shell\n * 2022-10-10 13:11:03 | backend | npm\n * 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev\n * 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev\n * 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | backend | [nodemon] 2.0.19\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`\n * 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/\n * 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json\n * 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`\n * 2022-10-10 13:11:03 | backend |\n *\n * ```\n */\nconst ConcurrentOutput: FunctionComponent<Props> = ({processes, abortController, showTimestamps = true}) => {\n const [processOutput, setProcessOutput] = useState<Chunk[]>([])\n const concurrentColors = ['yellow', 'cyan', 'magenta', 'green', 'blue']\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n const {exit: unmountInk} = useApp()\n\n function lineColor(index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n return concurrentColors[colorIndex]!\n }\n\n const writableStream = (process: OutputProcess, index: number) => {\n return new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsi(chunk.toString('ascii')).split(/\\n/)\n\n setProcessOutput((previousProcessOutput) => [\n ...previousProcessOutput,\n {\n color: lineColor(index),\n prefix: process.prefix,\n lines,\n },\n ])\n\n next()\n },\n })\n }\n\n const runProcesses = async () => {\n try {\n await Promise.all(\n processes.map(async (process, index) => {\n const stdout = writableStream(process, index)\n const stderr = writableStream(process, index)\n\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n\n unmountInk()\n } catch (error) {\n abortController.abort()\n unmountInk()\n throw error\n }\n }\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n runProcesses()\n }, [])\n\n return (\n <Static items={processOutput}>\n {(chunk, index) => {\n return (\n <Box flexDirection=\"column\" key={index}>\n {chunk.lines.map((line, index) => (\n <Box key={index} flexDirection=\"row\">\n {showTimestamps && (\n <Box>\n <Box marginRight={1}>\n <Text color={chunk.color}>{new Date().toISOString().replace(/T/, ' ').replace(/\\..+/, '')}</Text>\n </Box>\n\n <Text bold color={chunk.color}>\n |\n </Text>\n </Box>\n )}\n\n <Box width={prefixColumnSize} marginX={1}>\n <Text color={chunk.color}>{chunk.prefix}</Text>\n </Box>\n\n <Text bold color={chunk.color}>\n |\n </Text>\n\n <Box flexGrow={1} paddingLeft={1}>\n <Text color={chunk.color}>{line}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )\n }}\n </Static>\n )\n}\n\nexport default ConcurrentOutput\n"]}
|