@gadgetinc/ggt 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/add-4ME2KTJQ.js +84 -0
- package/dist/add-4ME2KTJQ.js.map +7 -0
- package/dist/build-4BGA4IZE.js +3 -0
- package/dist/build-4BGA4IZE.js.map +7 -0
- package/dist/chunk-57XALM2W.js +2 -0
- package/dist/chunk-57XALM2W.js.map +7 -0
- package/dist/chunk-5DLLJX5F.js +11 -0
- package/dist/chunk-5DLLJX5F.js.map +7 -0
- package/dist/chunk-5WC5D4WL.js +2 -0
- package/dist/chunk-5WC5D4WL.js.map +7 -0
- package/dist/chunk-BSCZOMV4.js +2 -0
- package/dist/chunk-BSCZOMV4.js.map +7 -0
- package/dist/chunk-BZY2AIPV.js +57 -0
- package/dist/chunk-BZY2AIPV.js.map +7 -0
- package/dist/chunk-D2K5XPNJ.js +2 -0
- package/dist/chunk-D2K5XPNJ.js.map +7 -0
- package/dist/chunk-F3EZ4KS3.js +2 -0
- package/dist/chunk-F3EZ4KS3.js.map +7 -0
- package/dist/chunk-G3VNV5Z6.js +33 -0
- package/dist/chunk-G3VNV5Z6.js.map +7 -0
- package/dist/chunk-GA7AL463.js +24 -0
- package/dist/chunk-GA7AL463.js.map +7 -0
- package/dist/chunk-GOBNB5VT.js +2 -0
- package/dist/chunk-GOBNB5VT.js.map +7 -0
- package/dist/chunk-HKBXEZNF.js +2 -0
- package/dist/chunk-HKBXEZNF.js.map +7 -0
- package/{lib/commands/push.js → dist/chunk-IKJVXTZK.js} +7 -48
- package/dist/chunk-IKJVXTZK.js.map +7 -0
- package/dist/chunk-KGSSHEEC.js +17 -0
- package/dist/chunk-KGSSHEEC.js.map +7 -0
- package/dist/chunk-KXK37C5D.js +183 -0
- package/dist/chunk-KXK37C5D.js.map +7 -0
- package/dist/chunk-NJIDVM2C.js +27 -0
- package/dist/chunk-NJIDVM2C.js.map +7 -0
- package/dist/chunk-Q5N5L6H3.js +6 -0
- package/dist/chunk-Q5N5L6H3.js.map +7 -0
- package/dist/chunk-QEVWPU3D.js +8 -0
- package/dist/chunk-QEVWPU3D.js.map +7 -0
- package/dist/chunk-X36GM74C.js +2 -0
- package/dist/chunk-X36GM74C.js.map +7 -0
- package/dist/chunk-YRP2UZ2I.js +126 -0
- package/dist/chunk-YRP2UZ2I.js.map +7 -0
- package/dist/deploy-6HOBYPE6.js +30 -0
- package/dist/deploy-6HOBYPE6.js.map +7 -0
- package/dist/dev-M3WDGK4D.js +57 -0
- package/dist/dev-M3WDGK4D.js.map +7 -0
- package/dist/esm-BL3OM5UJ.js +33 -0
- package/dist/esm-BL3OM5UJ.js.map +7 -0
- package/dist/list-725RHWD5.js +11 -0
- package/dist/list-725RHWD5.js.map +7 -0
- package/dist/login-I4RGMDLE.js +2 -0
- package/dist/login-I4RGMDLE.js.map +7 -0
- package/dist/logout-UZBACOIX.js +7 -0
- package/dist/logout-UZBACOIX.js.map +7 -0
- package/dist/main.js +45 -0
- package/dist/main.js.map +7 -0
- package/dist/open-GWKGQQG3.js +74 -0
- package/dist/open-GWKGQQG3.js.map +7 -0
- package/{lib/commands/pull.js → dist/pull-7C5A65KB.js} +7 -48
- package/dist/pull-7C5A65KB.js.map +7 -0
- package/dist/push-LPUIR4EO.js +2 -0
- package/dist/push-LPUIR4EO.js.map +7 -0
- package/dist/status-DFKKSRVB.js +14 -0
- package/dist/status-DFKKSRVB.js.map +7 -0
- package/dist/version-JD42JXWY.js +11 -0
- package/dist/version-JD42JXWY.js.map +7 -0
- package/dist/whoami-I23R6HOG.js +7 -0
- package/dist/whoami-I23R6HOG.js.map +7 -0
- package/package.json +73 -75
- package/lib/__generated__/graphql.js +0 -78
- package/lib/__generated__/graphql.js.map +0 -1
- package/lib/commands/add.js +0 -385
- package/lib/commands/add.js.map +0 -1
- package/lib/commands/deploy.js +0 -287
- package/lib/commands/deploy.js.map +0 -1
- package/lib/commands/dev.js +0 -374
- package/lib/commands/dev.js.map +0 -1
- package/lib/commands/list.js +0 -47
- package/lib/commands/list.js.map +0 -1
- package/lib/commands/login.js +0 -93
- package/lib/commands/login.js.map +0 -1
- package/lib/commands/logout.js +0 -20
- package/lib/commands/logout.js.map +0 -1
- package/lib/commands/open.js +0 -159
- package/lib/commands/open.js.map +0 -1
- package/lib/commands/pull.js.map +0 -1
- package/lib/commands/push.js.map +0 -1
- package/lib/commands/root.js +0 -110
- package/lib/commands/root.js.map +0 -1
- package/lib/commands/status.js +0 -56
- package/lib/commands/status.js.map +0 -1
- package/lib/commands/version.js +0 -18
- package/lib/commands/version.js.map +0 -1
- package/lib/commands/whoami.js +0 -23
- package/lib/commands/whoami.js.map +0 -1
- package/lib/ggt.js +0 -65
- package/lib/ggt.js.map +0 -1
- package/lib/main.js +0 -5
- package/lib/main.js.map +0 -1
- package/lib/services/app/api/api.js +0 -191
- package/lib/services/app/api/api.js.map +0 -1
- package/lib/services/app/api/operation.js +0 -23
- package/lib/services/app/api/operation.js.map +0 -1
- package/lib/services/app/app.js +0 -95
- package/lib/services/app/app.js.map +0 -1
- package/lib/services/app/arg.js +0 -28
- package/lib/services/app/arg.js.map +0 -1
- package/lib/services/app/client.js +0 -182
- package/lib/services/app/client.js.map +0 -1
- package/lib/services/app/edit/edit.js +0 -191
- package/lib/services/app/edit/edit.js.map +0 -1
- package/lib/services/app/edit/operation.js +0 -155
- package/lib/services/app/edit/operation.js.map +0 -1
- package/lib/services/app/error.js +0 -65
- package/lib/services/app/error.js.map +0 -1
- package/lib/services/command/arg.js +0 -55
- package/lib/services/command/arg.js.map +0 -1
- package/lib/services/command/command.js +0 -47
- package/lib/services/command/command.js.map +0 -1
- package/lib/services/command/context.js +0 -209
- package/lib/services/command/context.js.map +0 -1
- package/lib/services/config/config.js +0 -133
- package/lib/services/config/config.js.map +0 -1
- package/lib/services/config/env.js +0 -22
- package/lib/services/config/env.js.map +0 -1
- package/lib/services/config/package-json.js +0 -9
- package/lib/services/config/package-json.js.map +0 -1
- package/lib/services/filesync/changes.js +0 -134
- package/lib/services/filesync/changes.js.map +0 -1
- package/lib/services/filesync/conflicts.js +0 -140
- package/lib/services/filesync/conflicts.js.map +0 -1
- package/lib/services/filesync/directory.js +0 -269
- package/lib/services/filesync/directory.js.map +0 -1
- package/lib/services/filesync/error.js +0 -137
- package/lib/services/filesync/error.js.map +0 -1
- package/lib/services/filesync/file.js +0 -3
- package/lib/services/filesync/file.js.map +0 -1
- package/lib/services/filesync/filesync.js +0 -791
- package/lib/services/filesync/filesync.js.map +0 -1
- package/lib/services/filesync/hashes.js +0 -172
- package/lib/services/filesync/hashes.js.map +0 -1
- package/lib/services/filesync/strategy.js +0 -59
- package/lib/services/filesync/strategy.js.map +0 -1
- package/lib/services/filesync/sync-json.js +0 -475
- package/lib/services/filesync/sync-json.js.map +0 -1
- package/lib/services/http/auth.js +0 -70
- package/lib/services/http/auth.js.map +0 -1
- package/lib/services/http/http.js +0 -136
- package/lib/services/http/http.js.map +0 -1
- package/lib/services/output/confirm.js +0 -149
- package/lib/services/output/confirm.js.map +0 -1
- package/lib/services/output/footer.js +0 -22
- package/lib/services/output/footer.js.map +0 -1
- package/lib/services/output/log/field.js +0 -3
- package/lib/services/output/log/field.js.map +0 -1
- package/lib/services/output/log/format/format.js +0 -8
- package/lib/services/output/log/format/format.js.map +0 -1
- package/lib/services/output/log/format/json.js +0 -37
- package/lib/services/output/log/format/json.js.map +0 -1
- package/lib/services/output/log/format/pretty.js +0 -158
- package/lib/services/output/log/format/pretty.js.map +0 -1
- package/lib/services/output/log/level.js +0 -41
- package/lib/services/output/log/level.js.map +0 -1
- package/lib/services/output/log/logger.js +0 -53
- package/lib/services/output/log/logger.js.map +0 -1
- package/lib/services/output/log/structured.js +0 -52
- package/lib/services/output/log/structured.js.map +0 -1
- package/lib/services/output/notify.js +0 -27
- package/lib/services/output/notify.js.map +0 -1
- package/lib/services/output/output.js +0 -197
- package/lib/services/output/output.js.map +0 -1
- package/lib/services/output/print.js +0 -31
- package/lib/services/output/print.js.map +0 -1
- package/lib/services/output/problems.js +0 -84
- package/lib/services/output/problems.js.map +0 -1
- package/lib/services/output/prompt.js +0 -185
- package/lib/services/output/prompt.js.map +0 -1
- package/lib/services/output/report.js +0 -190
- package/lib/services/output/report.js.map +0 -1
- package/lib/services/output/select.js +0 -198
- package/lib/services/output/select.js.map +0 -1
- package/lib/services/output/spinner.js +0 -141
- package/lib/services/output/spinner.js.map +0 -1
- package/lib/services/output/sprint.js +0 -44
- package/lib/services/output/sprint.js.map +0 -1
- package/lib/services/output/symbols.js +0 -23
- package/lib/services/output/symbols.js.map +0 -1
- package/lib/services/output/table.js +0 -98
- package/lib/services/output/table.js.map +0 -1
- package/lib/services/output/timestamp.js +0 -12
- package/lib/services/output/timestamp.js.map +0 -1
- package/lib/services/output/update.js +0 -99
- package/lib/services/output/update.js.map +0 -1
- package/lib/services/user/session.js +0 -54
- package/lib/services/user/session.js.map +0 -1
- package/lib/services/user/user.js +0 -76
- package/lib/services/user/user.js.map +0 -1
- package/lib/services/util/assert.js +0 -11
- package/lib/services/util/assert.js.map +0 -1
- package/lib/services/util/boolean.js +0 -15
- package/lib/services/util/boolean.js.map +0 -1
- package/lib/services/util/collection.js +0 -38
- package/lib/services/util/collection.js.map +0 -1
- package/lib/services/util/function.js +0 -153
- package/lib/services/util/function.js.map +0 -1
- package/lib/services/util/is.js +0 -97
- package/lib/services/util/is.js.map +0 -1
- package/lib/services/util/json.js +0 -33
- package/lib/services/util/json.js.map +0 -1
- package/lib/services/util/number.js +0 -27
- package/lib/services/util/number.js.map +0 -1
- package/lib/services/util/object.js +0 -104
- package/lib/services/util/object.js.map +0 -1
- package/lib/services/util/paths.js +0 -36
- package/lib/services/util/paths.js.map +0 -1
- package/lib/services/util/promise.js +0 -74
- package/lib/services/util/promise.js.map +0 -1
- package/lib/services/util/types.js +0 -5
- package/lib/services/util/types.js.map +0 -1
- package/npm-shrinkwrap.json +0 -29512
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { unthunk } from "../../util/function.js";
|
|
2
|
-
import { createStructuredLogger } from "./structured.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a {@linkcode Logger} with the given name and fields.
|
|
5
|
-
*
|
|
6
|
-
* Use the {@linkcode Printer} methods to print messages to stdout for
|
|
7
|
-
* end users to read.
|
|
8
|
-
*
|
|
9
|
-
* Use the {@linkcode StructuredLogger} methods to print structured
|
|
10
|
-
* messages to stderr for developers to read. These messages are only
|
|
11
|
-
* printed when the `GGT_LOG_LEVEL` is greater than or equal to the
|
|
12
|
-
* level of the message.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const logger = createLogger({ name: "my-logger" });
|
|
16
|
-
* logger.info("printing hello world", { foo: "bar" });
|
|
17
|
-
* // stderr
|
|
18
|
-
* // 12:00:00 INFO my-logger: printing hello world
|
|
19
|
-
* // foo: "bar"
|
|
20
|
-
* //
|
|
21
|
-
* // stderr w/ --json
|
|
22
|
-
* // {"level":3,"name":"my-logger","msg":"printing hello world","fields":{"foo":"bar"}}
|
|
23
|
-
*
|
|
24
|
-
* logger.println("Hello, world!");
|
|
25
|
-
* // stdout
|
|
26
|
-
* // Hello, world!
|
|
27
|
-
* //
|
|
28
|
-
* // stdout w/ --json
|
|
29
|
-
* // {"level":6,"name":"my-logger","msg":"Hello, world!"}
|
|
30
|
-
*/ export const createLogger = ({ name, fields: loggerFields, devFields: loggerDevFields })=>{
|
|
31
|
-
return {
|
|
32
|
-
...createStructuredLogger({
|
|
33
|
-
name,
|
|
34
|
-
fields: loggerFields,
|
|
35
|
-
devFields: loggerDevFields
|
|
36
|
-
}),
|
|
37
|
-
child: ({ name: childName, fields: childFields, devFields: childDevFields })=>{
|
|
38
|
-
return createLogger({
|
|
39
|
-
name: childName || name,
|
|
40
|
-
fields: ()=>({
|
|
41
|
-
...unthunk(loggerFields),
|
|
42
|
-
...unthunk(childFields)
|
|
43
|
-
}),
|
|
44
|
-
devFields: {
|
|
45
|
-
...unthunk(loggerDevFields),
|
|
46
|
-
...unthunk(childDevFields)
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/output/log/logger.ts"],"sourcesContent":["import { unthunk } from \"../../util/function.js\";\nimport { createStructuredLogger, type StructuredLogger, type StructuredLoggerOptions } from \"./structured.js\";\n\nexport type Logger = StructuredLogger & {\n /**\n * Creates a child logger with the given options. The child logger\n * inherits the name and fields of the parent logger.\n *\n * @param options\n */\n child(options: Partial<StructuredLoggerOptions>): Logger;\n};\n\n/**\n * Creates a {@linkcode Logger} with the given name and fields.\n *\n * Use the {@linkcode Printer} methods to print messages to stdout for\n * end users to read.\n *\n * Use the {@linkcode StructuredLogger} methods to print structured\n * messages to stderr for developers to read. These messages are only\n * printed when the `GGT_LOG_LEVEL` is greater than or equal to the\n * level of the message.\n *\n * @example\n * const logger = createLogger({ name: \"my-logger\" });\n * logger.info(\"printing hello world\", { foo: \"bar\" });\n * // stderr\n * // 12:00:00 INFO my-logger: printing hello world\n * // foo: \"bar\"\n * //\n * // stderr w/ --json\n * // {\"level\":3,\"name\":\"my-logger\",\"msg\":\"printing hello world\",\"fields\":{\"foo\":\"bar\"}}\n *\n * logger.println(\"Hello, world!\");\n * // stdout\n * // Hello, world!\n * //\n * // stdout w/ --json\n * // {\"level\":6,\"name\":\"my-logger\",\"msg\":\"Hello, world!\"}\n */\nexport const createLogger = ({ name, fields: loggerFields, devFields: loggerDevFields }: StructuredLoggerOptions): Logger => {\n return {\n ...createStructuredLogger({ name, fields: loggerFields, devFields: loggerDevFields }),\n child: ({ name: childName, fields: childFields, devFields: childDevFields }) => {\n return createLogger({\n name: childName || name,\n fields: () => ({ ...unthunk(loggerFields), ...unthunk(childFields) }),\n devFields: { ...unthunk(loggerDevFields), ...unthunk(childDevFields) },\n });\n },\n };\n};\n"],"names":["unthunk","createStructuredLogger","createLogger","name","fields","loggerFields","devFields","loggerDevFields","child","childName","childFields","childDevFields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,yBAAyB;AACjD,SAASC,sBAAsB,QAA6D,kBAAkB;AAY9G;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,MAAMC,eAAe,CAAC,EAAEC,IAAI,EAAEC,QAAQC,YAAY,EAAEC,WAAWC,eAAe,EAA2B;IAC9G,OAAO;QACL,GAAGN,uBAAuB;YAAEE;YAAMC,QAAQC;YAAcC,WAAWC;QAAgB,EAAE;QACrFC,OAAO,CAAC,EAAEL,MAAMM,SAAS,EAAEL,QAAQM,WAAW,EAAEJ,WAAWK,cAAc,EAAE;YACzE,OAAOT,aAAa;gBAClBC,MAAMM,aAAaN;gBACnBC,QAAQ,IAAO,CAAA;wBAAE,GAAGJ,QAAQK,aAAa;wBAAE,GAAGL,QAAQU,YAAY;oBAAC,CAAA;gBACnEJ,WAAW;oBAAE,GAAGN,QAAQO,gBAAgB;oBAAE,GAAGP,QAAQW,eAAe;gBAAC;YACvE;QACF;IACF;AACF,EAAE"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { addBreadcrumb as addSentryBreadcrumb } from "@sentry/node";
|
|
2
|
-
import { config } from "../../config/config.js";
|
|
3
|
-
import { env } from "../../config/env.js";
|
|
4
|
-
import { unthunk } from "../../util/function.js";
|
|
5
|
-
import { serializeError } from "../../util/object.js";
|
|
6
|
-
import { output } from "../output.js";
|
|
7
|
-
import { formatters } from "./format/format.js";
|
|
8
|
-
import { Level } from "./level.js";
|
|
9
|
-
export const createStructuredLogger = ({ name, fields: loggerFields = {}, devFields: devLoggerFields = {} })=>{
|
|
10
|
-
const createStructuredLog = (level)=>{
|
|
11
|
-
return (msg, messageFields, devMessageFields)=>{
|
|
12
|
-
const shouldLog = level >= config.logLevel;
|
|
13
|
-
const shouldSendToSentry = level >= Level.INFO;
|
|
14
|
-
if (!shouldLog && !shouldSendToSentry) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const fields = {
|
|
18
|
-
...unthunk(loggerFields),
|
|
19
|
-
...messageFields
|
|
20
|
-
};
|
|
21
|
-
if (env.developmentOrTestLike) {
|
|
22
|
-
Object.assign(fields, unthunk(devLoggerFields), devMessageFields);
|
|
23
|
-
}
|
|
24
|
-
if ("error" in fields) {
|
|
25
|
-
fields.error = serializeError(fields.error);
|
|
26
|
-
}
|
|
27
|
-
if ("reason" in fields) {
|
|
28
|
-
fields.reason = serializeError(fields.reason);
|
|
29
|
-
}
|
|
30
|
-
if (shouldLog) {
|
|
31
|
-
const format = formatters[config.logFormat];
|
|
32
|
-
output.writeStderr(format(level, name, msg, fields));
|
|
33
|
-
}
|
|
34
|
-
if (shouldSendToSentry) {
|
|
35
|
-
addSentryBreadcrumb({
|
|
36
|
-
level: "log",
|
|
37
|
-
message: msg,
|
|
38
|
-
data: fields
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
trace: createStructuredLog(Level.TRACE),
|
|
45
|
-
debug: createStructuredLog(Level.DEBUG),
|
|
46
|
-
info: createStructuredLog(Level.INFO),
|
|
47
|
-
warn: createStructuredLog(Level.WARN),
|
|
48
|
-
error: createStructuredLog(Level.ERROR)
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=structured.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/output/log/structured.ts"],"sourcesContent":["import { addBreadcrumb as addSentryBreadcrumb } from \"@sentry/node\";\nimport { config } from \"../../config/config.js\";\nimport { env } from \"../../config/env.js\";\nimport { unthunk, type Thunk } from \"../../util/function.js\";\nimport { serializeError } from \"../../util/object.js\";\nimport { output } from \"../output.js\";\nimport type { Fields } from \"./field.js\";\nimport { formatters } from \"./format/format.js\";\nimport { Level } from \"./level.js\";\n\ntype StructuredLog = (msg: Lowercase<string>, fields?: Fields, devFields?: Fields) => void;\n\nexport type StructuredLogger = {\n trace: StructuredLog;\n debug: StructuredLog;\n info: StructuredLog;\n warn: StructuredLog;\n error: StructuredLog;\n};\n\nexport type StructuredLoggerOptions = {\n /**\n * The name of logger.\n */\n name: string;\n\n /**\n * Fields to add to every message logged by the logger.\n */\n fields?: Thunk<Fields>;\n\n /**\n * Fields to add to every message logged by the logger only in\n * development or test environments.\n */\n devFields?: Thunk<Fields>;\n};\n\nexport const createStructuredLogger = ({\n name,\n fields: loggerFields = {},\n devFields: devLoggerFields = {},\n}: StructuredLoggerOptions): StructuredLogger => {\n const createStructuredLog = (level: Level): StructuredLog => {\n return (msg, messageFields, devMessageFields) => {\n const shouldLog = level >= config.logLevel;\n const shouldSendToSentry = level >= Level.INFO;\n if (!shouldLog && !shouldSendToSentry) {\n return;\n }\n\n const fields = { ...unthunk(loggerFields), ...messageFields };\n if (env.developmentOrTestLike) {\n Object.assign(fields, unthunk(devLoggerFields), devMessageFields);\n }\n\n if (\"error\" in fields) {\n fields.error = serializeError(fields.error);\n }\n\n if (\"reason\" in fields) {\n fields.reason = serializeError(fields.reason);\n }\n\n if (shouldLog) {\n const format = formatters[config.logFormat];\n output.writeStderr(format(level, name, msg, fields));\n }\n\n if (shouldSendToSentry) {\n addSentryBreadcrumb({ level: \"log\", message: msg, data: fields });\n }\n };\n };\n\n return {\n trace: createStructuredLog(Level.TRACE),\n debug: createStructuredLog(Level.DEBUG),\n info: createStructuredLog(Level.INFO),\n warn: createStructuredLog(Level.WARN),\n error: createStructuredLog(Level.ERROR),\n };\n};\n"],"names":["addBreadcrumb","addSentryBreadcrumb","config","env","unthunk","serializeError","output","formatters","Level","createStructuredLogger","name","fields","loggerFields","devFields","devLoggerFields","createStructuredLog","level","msg","messageFields","devMessageFields","shouldLog","logLevel","shouldSendToSentry","INFO","developmentOrTestLike","Object","assign","error","reason","format","logFormat","writeStderr","message","data","trace","TRACE","debug","DEBUG","info","warn","WARN","ERROR"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,iBAAiBC,mBAAmB,QAAQ,eAAe;AACpE,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SAASC,GAAG,QAAQ,sBAAsB;AAC1C,SAASC,OAAO,QAAoB,yBAAyB;AAC7D,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,MAAM,QAAQ,eAAe;AAEtC,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,KAAK,QAAQ,aAAa;AA8BnC,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,IAAI,EACJC,QAAQC,eAAe,CAAC,CAAC,EACzBC,WAAWC,kBAAkB,CAAC,CAAC,EACP;IACxB,MAAMC,sBAAsB,CAACC;QAC3B,OAAO,CAACC,KAAKC,eAAeC;YAC1B,MAAMC,YAAYJ,SAASd,OAAOmB,QAAQ;YAC1C,MAAMC,qBAAqBN,SAASR,MAAMe,IAAI;YAC9C,IAAI,CAACH,aAAa,CAACE,oBAAoB;gBACrC;YACF;YAEA,MAAMX,SAAS;gBAAE,GAAGP,QAAQQ,aAAa;gBAAE,GAAGM,aAAa;YAAC;YAC5D,IAAIf,IAAIqB,qBAAqB,EAAE;gBAC7BC,OAAOC,MAAM,CAACf,QAAQP,QAAQU,kBAAkBK;YAClD;YAEA,IAAI,WAAWR,QAAQ;gBACrBA,OAAOgB,KAAK,GAAGtB,eAAeM,OAAOgB,KAAK;YAC5C;YAEA,IAAI,YAAYhB,QAAQ;gBACtBA,OAAOiB,MAAM,GAAGvB,eAAeM,OAAOiB,MAAM;YAC9C;YAEA,IAAIR,WAAW;gBACb,MAAMS,SAAStB,UAAU,CAACL,OAAO4B,SAAS,CAAC;gBAC3CxB,OAAOyB,WAAW,CAACF,OAAOb,OAAON,MAAMO,KAAKN;YAC9C;YAEA,IAAIW,oBAAoB;gBACtBrB,oBAAoB;oBAAEe,OAAO;oBAAOgB,SAASf;oBAAKgB,MAAMtB;gBAAO;YACjE;QACF;IACF;IAEA,OAAO;QACLuB,OAAOnB,oBAAoBP,MAAM2B,KAAK;QACtCC,OAAOrB,oBAAoBP,MAAM6B,KAAK;QACtCC,MAAMvB,oBAAoBP,MAAMe,IAAI;QACpCgB,MAAMxB,oBAAoBP,MAAMgC,IAAI;QACpCb,OAAOZ,oBAAoBP,MAAMiC,KAAK;IACxC;AACF,EAAE"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import notifier from "node-notifier";
|
|
2
|
-
import { assetsPath } from "../util/paths.js";
|
|
3
|
-
/**
|
|
4
|
-
* Sends a native OS notification to the user.
|
|
5
|
-
*
|
|
6
|
-
* @see {@link https://www.npmjs.com/package/node-notifier node-notifier}
|
|
7
|
-
*/ export const notify = (ctx, notification)=>{
|
|
8
|
-
ctx.log.info("notifying user", {
|
|
9
|
-
notification: notification
|
|
10
|
-
});
|
|
11
|
-
notifier.notify({
|
|
12
|
-
title: "Gadget",
|
|
13
|
-
contentImage: assetsPath("favicon-128@4x.png"),
|
|
14
|
-
icon: assetsPath("favicon-128@4x.png"),
|
|
15
|
-
sound: true,
|
|
16
|
-
timeout: false,
|
|
17
|
-
...notification
|
|
18
|
-
}, (error)=>{
|
|
19
|
-
if (error) {
|
|
20
|
-
ctx.log.warn("error notifying user", {
|
|
21
|
-
notification: notification
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=notify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/output/notify.ts"],"sourcesContent":["import notifier, { type Notification } from \"node-notifier\";\nimport type WindowsBalloon from \"node-notifier/notifiers/balloon.js\";\nimport type Growl from \"node-notifier/notifiers/growl.js\";\nimport type NotificationCenter from \"node-notifier/notifiers/notificationcenter.js\";\nimport type NotifySend from \"node-notifier/notifiers/notifysend.js\";\nimport type WindowsToaster from \"node-notifier/notifiers/toaster.js\";\nimport type { Context } from \"../command/context.js\";\nimport { assetsPath } from \"../util/paths.js\";\nimport type { Field } from \"./log/field.js\";\n\n/**\n * Sends a native OS notification to the user.\n *\n * @see {@link https://www.npmjs.com/package/node-notifier node-notifier}\n */\nexport const notify = (\n ctx: Context,\n notification:\n | Notification\n | NotificationCenter.Notification\n | NotifySend.Notification\n | WindowsToaster.Notification\n | WindowsBalloon.Notification\n | Growl.Notification,\n): void => {\n ctx.log.info(\"notifying user\", { notification: notification as Field });\n\n notifier.notify(\n {\n title: \"Gadget\",\n contentImage: assetsPath(\"favicon-128@4x.png\"),\n icon: assetsPath(\"favicon-128@4x.png\"),\n sound: true,\n timeout: false,\n ...notification,\n },\n (error) => {\n if (error) {\n ctx.log.warn(\"error notifying user\", { notification: notification as Field });\n }\n },\n );\n};\n"],"names":["notifier","assetsPath","notify","ctx","notification","log","info","title","contentImage","icon","sound","timeout","error","warn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,cAAqC,gBAAgB;AAO5D,SAASC,UAAU,QAAQ,mBAAmB;AAG9C;;;;CAIC,GACD,OAAO,MAAMC,SAAS,CACpBC,KACAC;IAQAD,IAAIE,GAAG,CAACC,IAAI,CAAC,kBAAkB;QAAEF,cAAcA;IAAsB;IAErEJ,SAASE,MAAM,CACb;QACEK,OAAO;QACPC,cAAcP,WAAW;QACzBQ,MAAMR,WAAW;QACjBS,OAAO;QACPC,SAAS;QACT,GAAGP,YAAY;IACjB,GACA,CAACQ;QACC,IAAIA,OAAO;YACTT,IAAIE,GAAG,CAACQ,IAAI,CAAC,wBAAwB;gBAAET,cAAcA;YAAsB;QAC7E;IACF;AAEJ,EAAE"}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import cliCursor from "cli-cursor";
|
|
3
|
-
import isInteractive from "is-interactive";
|
|
4
|
-
import assert from "node:assert";
|
|
5
|
-
import process from "node:process";
|
|
6
|
-
import stdinDiscarder from "stdin-discarder";
|
|
7
|
-
import stringWidth from "string-width";
|
|
8
|
-
import stripAnsi from "strip-ansi";
|
|
9
|
-
import { env } from "../config/env.js";
|
|
10
|
-
import { unthunk } from "../util/function.js";
|
|
11
|
-
import { isObject } from "../util/is.js";
|
|
12
|
-
let cursorIsHidden = false;
|
|
13
|
-
/**
|
|
14
|
-
* Stderr
|
|
15
|
-
* Prompt
|
|
16
|
-
* Spinner
|
|
17
|
-
* Footer
|
|
18
|
-
*/ export class Output {
|
|
19
|
-
get isInteractive() {
|
|
20
|
-
return !env.testLike && isInteractive({
|
|
21
|
-
stream: process.stdout
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
writeStdout(text) {
|
|
25
|
-
this._clearStickyText();
|
|
26
|
-
text = this._stripUnnecessaryNewLines(text, this.lastPrintedLineWasEmpty);
|
|
27
|
-
this._writeStdout(text);
|
|
28
|
-
this.lastPrintedLineWasEmpty = text === "\n" || text.endsWith("\n\n");
|
|
29
|
-
this.lastStickyLineWasEmpty = this.lastPrintedLineWasEmpty;
|
|
30
|
-
this._writeStickyText();
|
|
31
|
-
}
|
|
32
|
-
writeStderr(text) {
|
|
33
|
-
this._clearStickyText();
|
|
34
|
-
text = this._stripUnnecessaryNewLines(text, this.lastPrintedLineWasEmpty);
|
|
35
|
-
this._writeStderr(text);
|
|
36
|
-
this.lastPrintedLineWasEmpty = text === "\n" || text.endsWith("\n\n");
|
|
37
|
-
this.lastStickyLineWasEmpty = this.lastPrintedLineWasEmpty;
|
|
38
|
-
this._writeStickyText();
|
|
39
|
-
}
|
|
40
|
-
updatePrompt(promptTextThunk) {
|
|
41
|
-
assert(this.isInteractive, "cannot update prompt in non-interactive mode");
|
|
42
|
-
this._promptText = unthunk(promptTextThunk, this._promptText);
|
|
43
|
-
this._writeStickyText();
|
|
44
|
-
}
|
|
45
|
-
persistPrompt(finalPromptText = this._promptText) {
|
|
46
|
-
this._promptText = "";
|
|
47
|
-
this.writeStdout(finalPromptText);
|
|
48
|
-
}
|
|
49
|
-
updateSpinner(spinnerTextThunk) {
|
|
50
|
-
assert(this.isInteractive, "cannot update spinner in non-interactive mode");
|
|
51
|
-
this._spinnerText = unthunk(spinnerTextThunk, this._spinnerText);
|
|
52
|
-
this._writeStickyText();
|
|
53
|
-
}
|
|
54
|
-
persistSpinner(finalSpinnerText = this._spinnerText) {
|
|
55
|
-
this._spinnerText = "";
|
|
56
|
-
this.writeStdout(finalSpinnerText);
|
|
57
|
-
}
|
|
58
|
-
updateFooter(footerTextThunk) {
|
|
59
|
-
assert(this.isInteractive, "cannot update footer in non-interactive mode");
|
|
60
|
-
this._footerText = unthunk(footerTextThunk, this._footerText);
|
|
61
|
-
this._writeStickyText();
|
|
62
|
-
}
|
|
63
|
-
persistFooter(finalFooterText = this._footerText) {
|
|
64
|
-
this._footerText = "";
|
|
65
|
-
this.writeStdout(finalFooterText);
|
|
66
|
-
}
|
|
67
|
-
_writeStdout(text) {
|
|
68
|
-
if (text === "") {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (!env.testLike) {
|
|
72
|
-
process.stdout.write(text);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// we use console.log/error in tests since vitest doesn't display
|
|
76
|
-
// process.stdout/stderr correctly, so we need to remove the
|
|
77
|
-
// trailing newline because console.log/error adds one
|
|
78
|
-
if (text.endsWith("\n")) {
|
|
79
|
-
text = text.slice(0, -1);
|
|
80
|
-
}
|
|
81
|
-
console.log(text);
|
|
82
|
-
}
|
|
83
|
-
_writeStderr(text) {
|
|
84
|
-
if (text === "") {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (!env.testLike) {
|
|
88
|
-
process.stderr.write(text);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// we use console.log/error in tests since vitest doesn't display
|
|
92
|
-
// process.stdout/stderr correctly, so we need to remove the
|
|
93
|
-
// trailing newline because console.log/error adds one
|
|
94
|
-
if (text.endsWith("\n")) {
|
|
95
|
-
text = text.slice(0, -1);
|
|
96
|
-
}
|
|
97
|
-
console.error(text);
|
|
98
|
-
}
|
|
99
|
-
_clearStickyText() {
|
|
100
|
-
this.lastStickyLineWasEmpty = this.lastPrintedLineWasEmpty;
|
|
101
|
-
if (this._stickyTextLinesToClear === 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
process.stderr.cursorTo(0);
|
|
105
|
-
for(let i = 0; i < this._stickyTextLinesToClear; i++){
|
|
106
|
-
if (i > 0) {
|
|
107
|
-
process.stderr.moveCursor(0, -1);
|
|
108
|
-
}
|
|
109
|
-
process.stderr.clearLine(1);
|
|
110
|
-
}
|
|
111
|
-
this._stickyTextLinesToClear = 0;
|
|
112
|
-
}
|
|
113
|
-
_writeStickyText() {
|
|
114
|
-
if (!this.isInteractive) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
this._clearStickyText();
|
|
118
|
-
let formattedStickyText = "";
|
|
119
|
-
if (this._promptText) {
|
|
120
|
-
formattedStickyText += this._stripUnnecessaryNewLines(this._promptText, this.lastStickyLineWasEmpty);
|
|
121
|
-
this.lastStickyLineWasEmpty = formattedStickyText === "\n" || formattedStickyText.endsWith("\n\n");
|
|
122
|
-
}
|
|
123
|
-
if (this._spinnerText) {
|
|
124
|
-
formattedStickyText += this._stripUnnecessaryNewLines(this._spinnerText, this.lastStickyLineWasEmpty);
|
|
125
|
-
this.lastStickyLineWasEmpty = formattedStickyText === "\n" || formattedStickyText.endsWith("\n\n");
|
|
126
|
-
}
|
|
127
|
-
if (this._footerText) {
|
|
128
|
-
formattedStickyText += this._stripUnnecessaryNewLines(this._footerText, this.lastStickyLineWasEmpty);
|
|
129
|
-
this.lastStickyLineWasEmpty = formattedStickyText === "\n" || formattedStickyText.endsWith("\n\n");
|
|
130
|
-
}
|
|
131
|
-
this._writeStderr(formattedStickyText);
|
|
132
|
-
this._updateStickyTextLinesToClear(formattedStickyText);
|
|
133
|
-
if (cursorIsHidden && !formattedStickyText) {
|
|
134
|
-
cliCursor.show(process.stderr);
|
|
135
|
-
stdinDiscarder.stop();
|
|
136
|
-
cursorIsHidden = false;
|
|
137
|
-
} else if (!cursorIsHidden && formattedStickyText) {
|
|
138
|
-
cliCursor.hide(process.stderr);
|
|
139
|
-
stdinDiscarder.start();
|
|
140
|
-
cursorIsHidden = true;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
_updateStickyTextLinesToClear(lastWrittenStickyText) {
|
|
144
|
-
for (const line of stripAnsi(lastWrittenStickyText).split(/\r?\n/)){
|
|
145
|
-
const numCharacters = stringWidth(line, {
|
|
146
|
-
countAnsiEscapeCodes: true
|
|
147
|
-
});
|
|
148
|
-
const numLines = Math.ceil(numCharacters / process.stderr.columns);
|
|
149
|
-
this._stickyTextLinesToClear += Math.max(1, numLines);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
_stripUnnecessaryNewLines(text, lastLineWasEmpty) {
|
|
153
|
-
// remove duplicate empty lines
|
|
154
|
-
let index = -1;
|
|
155
|
-
while((index = text.indexOf("\n\n\n")) !== -1){
|
|
156
|
-
text = text.slice(0, index) + text.slice(index + 1);
|
|
157
|
-
}
|
|
158
|
-
if (lastLineWasEmpty) {
|
|
159
|
-
// we just printed an empty line, so don't print another one
|
|
160
|
-
while(text.startsWith("\n")){
|
|
161
|
-
text = text.slice(1);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return text;
|
|
165
|
-
}
|
|
166
|
-
constructor(){
|
|
167
|
-
/**
|
|
168
|
-
* Indicates whether the last line that was written to the stream was
|
|
169
|
-
* empty (i.e. "\n"). This is useful for preventing duplicate empty
|
|
170
|
-
* lines from being printed.
|
|
171
|
-
*
|
|
172
|
-
* This is automatically calculated by the {@linkcode writeStdout}
|
|
173
|
-
* method, so you only need to set this property manually when you
|
|
174
|
-
* know something else wrote to the stream directly.
|
|
175
|
-
*/ _define_property(this, "lastPrintedLineWasEmpty", true);
|
|
176
|
-
_define_property(this, "lastStickyLineWasEmpty", true);
|
|
177
|
-
_define_property(this, "_promptText", "");
|
|
178
|
-
_define_property(this, "_spinnerText", "");
|
|
179
|
-
_define_property(this, "_footerText", "");
|
|
180
|
-
_define_property(this, "_stickyTextLinesToClear", 0);
|
|
181
|
-
process.stdout.on("error", (err)=>{
|
|
182
|
-
if (isObject(err) && "code" in err && err.code === "EPIPE") {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
throw err;
|
|
186
|
-
});
|
|
187
|
-
process.stderr.on("error", (err)=>{
|
|
188
|
-
if (isObject(err) && "code" in err && err.code === "EPIPE") {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
throw err;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export const output = new Output();
|
|
196
|
-
|
|
197
|
-
//# sourceMappingURL=output.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/output/output.ts"],"sourcesContent":["import cliCursor from \"cli-cursor\";\nimport isInteractive from \"is-interactive\";\nimport assert from \"node:assert\";\nimport process from \"node:process\";\nimport stdinDiscarder from \"stdin-discarder\";\nimport stringWidth from \"string-width\";\nimport stripAnsi from \"strip-ansi\";\nimport { env } from \"../config/env.js\";\nimport { unthunk } from \"../util/function.js\";\nimport { isObject } from \"../util/is.js\";\n\nlet cursorIsHidden = false;\n\n/**\n * Stderr\n * Prompt\n * Spinner\n * Footer\n */\nexport class Output {\n /**\n * Indicates whether the last line that was written to the stream was\n * empty (i.e. \"\\n\"). This is useful for preventing duplicate empty\n * lines from being printed.\n *\n * This is automatically calculated by the {@linkcode writeStdout}\n * method, so you only need to set this property manually when you\n * know something else wrote to the stream directly.\n */\n lastPrintedLineWasEmpty = true;\n\n lastStickyLineWasEmpty = true;\n\n private _promptText = \"\";\n\n private _spinnerText = \"\";\n\n private _footerText = \"\";\n\n private _stickyTextLinesToClear = 0;\n\n constructor() {\n process.stdout.on(\"error\", (err: unknown) => {\n if (isObject(err) && \"code\" in err && err.code === \"EPIPE\") {\n return;\n }\n throw err;\n });\n\n process.stderr.on(\"error\", (err: unknown) => {\n if (isObject(err) && \"code\" in err && err.code === \"EPIPE\") {\n return;\n }\n throw err;\n });\n }\n\n get isInteractive(): boolean {\n return !env.testLike && isInteractive({ stream: process.stdout });\n }\n\n writeStdout(text: string): void {\n this._clearStickyText();\n\n text = this._stripUnnecessaryNewLines(text, this.lastPrintedLineWasEmpty);\n this._writeStdout(text);\n this.lastPrintedLineWasEmpty = text === \"\\n\" || text.endsWith(\"\\n\\n\");\n this.lastStickyLineWasEmpty = this.lastPrintedLineWasEmpty;\n\n this._writeStickyText();\n }\n\n writeStderr(text: string): void {\n this._clearStickyText();\n\n text = this._stripUnnecessaryNewLines(text, this.lastPrintedLineWasEmpty);\n this._writeStderr(text);\n this.lastPrintedLineWasEmpty = text === \"\\n\" || text.endsWith(\"\\n\\n\");\n this.lastStickyLineWasEmpty = this.lastPrintedLineWasEmpty;\n\n this._writeStickyText();\n }\n\n updatePrompt(promptTextThunk: string | ((currentPromptText: string) => string)): void {\n assert(this.isInteractive, \"cannot update prompt in non-interactive mode\");\n this._promptText = unthunk(promptTextThunk, this._promptText);\n this._writeStickyText();\n }\n\n persistPrompt(finalPromptText = this._promptText): void {\n this._promptText = \"\";\n this.writeStdout(finalPromptText);\n }\n\n updateSpinner(spinnerTextThunk: string | ((currentSpinnerText: string) => string)): void {\n assert(this.isInteractive, \"cannot update spinner in non-interactive mode\");\n this._spinnerText = unthunk(spinnerTextThunk, this._spinnerText);\n this._writeStickyText();\n }\n\n persistSpinner(finalSpinnerText = this._spinnerText): void {\n this._spinnerText = \"\";\n this.writeStdout(finalSpinnerText);\n }\n\n updateFooter(footerTextThunk: string | ((currentFooterText: string) => string)): void {\n assert(this.isInteractive, \"cannot update footer in non-interactive mode\");\n this._footerText = unthunk(footerTextThunk, this._footerText);\n this._writeStickyText();\n }\n\n persistFooter(finalFooterText = this._footerText): void {\n this._footerText = \"\";\n this.writeStdout(finalFooterText);\n }\n\n private _writeStdout(text: string): void {\n if (text === \"\") {\n return;\n }\n\n if (!env.testLike) {\n process.stdout.write(text);\n return;\n }\n\n // we use console.log/error in tests since vitest doesn't display\n // process.stdout/stderr correctly, so we need to remove the\n // trailing newline because console.log/error adds one\n if (text.endsWith(\"\\n\")) {\n text = text.slice(0, -1);\n }\n\n console.log(text);\n }\n\n private _writeStderr(text: string): void {\n if (text === \"\") {\n return;\n }\n\n if (!env.testLike) {\n process.stderr.write(text);\n return;\n }\n\n // we use console.log/error in tests since vitest doesn't display\n // process.stdout/stderr correctly, so we need to remove the\n // trailing newline because console.log/error adds one\n if (text.endsWith(\"\\n\")) {\n text = text.slice(0, -1);\n }\n\n console.error(text);\n }\n\n private _clearStickyText(): void {\n this.lastStickyLineWasEmpty = this.lastPrintedLineWasEmpty;\n if (this._stickyTextLinesToClear === 0) {\n return;\n }\n\n process.stderr.cursorTo(0);\n for (let i = 0; i < this._stickyTextLinesToClear; i++) {\n if (i > 0) {\n process.stderr.moveCursor(0, -1);\n }\n process.stderr.clearLine(1);\n }\n\n this._stickyTextLinesToClear = 0;\n }\n\n private _writeStickyText(): void {\n if (!this.isInteractive) {\n return;\n }\n\n this._clearStickyText();\n\n let formattedStickyText = \"\";\n if (this._promptText) {\n formattedStickyText += this._stripUnnecessaryNewLines(this._promptText, this.lastStickyLineWasEmpty);\n this.lastStickyLineWasEmpty = formattedStickyText === \"\\n\" || formattedStickyText.endsWith(\"\\n\\n\");\n }\n\n if (this._spinnerText) {\n formattedStickyText += this._stripUnnecessaryNewLines(this._spinnerText, this.lastStickyLineWasEmpty);\n this.lastStickyLineWasEmpty = formattedStickyText === \"\\n\" || formattedStickyText.endsWith(\"\\n\\n\");\n }\n\n if (this._footerText) {\n formattedStickyText += this._stripUnnecessaryNewLines(this._footerText, this.lastStickyLineWasEmpty);\n this.lastStickyLineWasEmpty = formattedStickyText === \"\\n\" || formattedStickyText.endsWith(\"\\n\\n\");\n }\n\n this._writeStderr(formattedStickyText);\n this._updateStickyTextLinesToClear(formattedStickyText);\n\n if (cursorIsHidden && !formattedStickyText) {\n cliCursor.show(process.stderr);\n stdinDiscarder.stop();\n cursorIsHidden = false;\n } else if (!cursorIsHidden && formattedStickyText) {\n cliCursor.hide(process.stderr);\n stdinDiscarder.start();\n cursorIsHidden = true;\n }\n }\n\n private _updateStickyTextLinesToClear(lastWrittenStickyText: string): void {\n for (const line of stripAnsi(lastWrittenStickyText).split(/\\r?\\n/)) {\n const numCharacters = stringWidth(line, { countAnsiEscapeCodes: true });\n const numLines = Math.ceil(numCharacters / process.stderr.columns);\n this._stickyTextLinesToClear += Math.max(1, numLines);\n }\n }\n\n private _stripUnnecessaryNewLines(text: string, lastLineWasEmpty: boolean): string {\n // remove duplicate empty lines\n let index = -1;\n while ((index = text.indexOf(\"\\n\\n\\n\")) !== -1) {\n text = text.slice(0, index) + text.slice(index + 1);\n }\n\n if (lastLineWasEmpty) {\n // we just printed an empty line, so don't print another one\n while (text.startsWith(\"\\n\")) {\n text = text.slice(1);\n }\n }\n\n return text;\n }\n}\n\nexport const output = new Output();\n"],"names":["cliCursor","isInteractive","assert","process","stdinDiscarder","stringWidth","stripAnsi","env","unthunk","isObject","cursorIsHidden","Output","testLike","stream","stdout","writeStdout","text","_clearStickyText","_stripUnnecessaryNewLines","lastPrintedLineWasEmpty","_writeStdout","endsWith","lastStickyLineWasEmpty","_writeStickyText","writeStderr","_writeStderr","updatePrompt","promptTextThunk","_promptText","persistPrompt","finalPromptText","updateSpinner","spinnerTextThunk","_spinnerText","persistSpinner","finalSpinnerText","updateFooter","footerTextThunk","_footerText","persistFooter","finalFooterText","write","slice","console","log","stderr","error","_stickyTextLinesToClear","cursorTo","i","moveCursor","clearLine","formattedStickyText","_updateStickyTextLinesToClear","show","stop","hide","start","lastWrittenStickyText","line","split","numCharacters","countAnsiEscapeCodes","numLines","Math","ceil","columns","max","lastLineWasEmpty","index","indexOf","startsWith","constructor","on","err","code","output"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,eAAe,aAAa;AACnC,OAAOC,mBAAmB,iBAAiB;AAC3C,OAAOC,YAAY,cAAc;AACjC,OAAOC,aAAa,eAAe;AACnC,OAAOC,oBAAoB,kBAAkB;AAC7C,OAAOC,iBAAiB,eAAe;AACvC,OAAOC,eAAe,aAAa;AACnC,SAASC,GAAG,QAAQ,mBAAmB;AACvC,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,IAAIC,iBAAiB;AAErB;;;;;CAKC,GACD,OAAO,MAAMC;IAsCX,IAAIV,gBAAyB;QAC3B,OAAO,CAACM,IAAIK,QAAQ,IAAIX,cAAc;YAAEY,QAAQV,QAAQW,MAAM;QAAC;IACjE;IAEAC,YAAYC,IAAY,EAAQ;QAC9B,IAAI,CAACC,gBAAgB;QAErBD,OAAO,IAAI,CAACE,yBAAyB,CAACF,MAAM,IAAI,CAACG,uBAAuB;QACxE,IAAI,CAACC,YAAY,CAACJ;QAClB,IAAI,CAACG,uBAAuB,GAAGH,SAAS,QAAQA,KAAKK,QAAQ,CAAC;QAC9D,IAAI,CAACC,sBAAsB,GAAG,IAAI,CAACH,uBAAuB;QAE1D,IAAI,CAACI,gBAAgB;IACvB;IAEAC,YAAYR,IAAY,EAAQ;QAC9B,IAAI,CAACC,gBAAgB;QAErBD,OAAO,IAAI,CAACE,yB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AAC,SAAQ,MAAO,CAAC,EAAG;YAC9CtD,OAAOA,KAAK0B,KAAK,CAAC,GAAG2B,SAASrD,KAAK0B,KAAK,CAAC2B,QAAQ;QACnD;QAEA,IAAID,kBAAkB;YACpB,4DAA4D;YAC5D,MAAOpD,KAAKuD,UAAU,CAAC,MAAO;gBAC5BvD,OAAOA,KAAK0B,KAAK,CAAC;YACpB;QACF;QAEA,OAAO1B;IACT;IAhMAwD,aAAc;QArBd;;;;;;;;GAQC,GACDrD,uBAAAA,2BAA0B;QAE1BG,uBAAAA,0BAAyB;QAEzB,uBAAQM,eAAc;QAEtB,uBAAQK,gBAAe;QAEvB,uBAAQK,eAAc;QAEtB,uBAAQS,2BAA0B;QAGhC5C,QAAQW,MAAM,CAAC2D,EAAE,CAAC,SAAS,CAACC;YAC1B,IAAIjE,SAASiE,QAAQ,UAAUA,OAAOA,IAAIC,IAAI,KAAK,SAAS;gBAC1D;YACF;YACA,MAAMD;QACR;QAEAvE,QAAQ0C,MAAM,CAAC4B,EAAE,CAAC,SAAS,CAACC;YAC1B,IAAIjE,SAASiE,QAAQ,UAAUA,OAAOA,IAAIC,IAAI,KAAK,SAAS;gBAC1D;YACF;YACA,MAAMD;QACR;IACF;AAmLF;AAEA,OAAO,MAAME,SAAS,IAAIjE,SAAS"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { config } from "../config/config.js";
|
|
2
|
-
import { output } from "./output.js";
|
|
3
|
-
import { isSprintOptions, sprint } from "./sprint.js";
|
|
4
|
-
const createPrint = (options)=>{
|
|
5
|
-
return (templateOrOptions, ...values)=>{
|
|
6
|
-
if (isSprintOptions(templateOrOptions)) {
|
|
7
|
-
return createPrint({
|
|
8
|
-
...options,
|
|
9
|
-
...templateOrOptions
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
const { json, ...sprintOptions } = options;
|
|
13
|
-
if (config.logFormat === "json") {
|
|
14
|
-
if (json) {
|
|
15
|
-
output.writeStdout(JSON.stringify(json) + "\n");
|
|
16
|
-
}
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const text = sprint(sprintOptions)(templateOrOptions, ...values);
|
|
20
|
-
output.writeStdout(text);
|
|
21
|
-
return;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export const print = createPrint({
|
|
25
|
-
ensureNewLine: false
|
|
26
|
-
});
|
|
27
|
-
export const println = createPrint({
|
|
28
|
-
ensureNewLine: true
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=print.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/output/print.ts"],"sourcesContent":["import { config } from \"../config/config.js\";\nimport type { Field } from \"./log/field.js\";\nimport { output } from \"./output.js\";\nimport { isSprintOptions, sprint, type SprintOptions } from \"./sprint.js\";\n\nexport type PrintOptions = SprintOptions & {\n /**\n * What to print if --json was passed.\n *\n * @default undefined (print nothing)\n */\n json?: Field;\n};\n\nexport type print = {\n /**\n * Prints the given string as is.\n *\n * @param str - The string to print.\n * @example\n * print(\"Hello, world!\");\n * // => \"Hello, world!\"\n *\n * print(`\n * Hello, world!\n *\n * How are you?\n * `);\n * // => \"\\n Hello, world!\\n\\n How are you?\\n\"\n */\n (str: string): void;\n\n /**\n * Prints the given template string with dedent and chalk-template.\n *\n * @param template - The template string to format.\n * @param values - The values to interpolate into the template.\n * @example\n * ```\n * let name = \"Jane\";\n *\n * print`Hello, ${name}!`;\n * // => \"Hello, Jane!\"\n *\n * print`Hello, {red ${name}}!`;\n * // => \"Hello, \\u001b[31mJane\\u001b[39m!\"\n *\n * print`\n * Hello, {red ${name}}!\n *\n * How are you?\n * `;\n * // => \"Hello, \\u001b[31mJane\\u001b[39m!\\n\\nHow are you?\"\n * ```\n * @see dedent https://github.com/tamino-martinius/node-ts-dedent\n * @see chalk-template https://github.com/chalk/chalk-template\n */\n (template: TemplateStringsArray, ...values: unknown[]): void;\n\n /**\n * Configures print with options before printing the given template\n * string with dedent and chalk-template.\n *\n * @example\n * ```\n * let name = \"Jane\";\n * print({ ensureEmptyLineAbove: true })`Hello, ${name}!`;\n * // => \"\\nHello, Jane!\"\n *\n * print({ ensureEmptyLineAbove: true })`Hello, {red ${name}}!`;\n * // => \"\\nHello, \\u001b[31mJane\\u001b[39m!\"\n *\n * print({ ensureEmptyLineAbove: true })`\n * Hello, {red ${name}}!\n *\n * How are you?\n * `;\n * // => \"\\nHello, \\u001b[31mJane\\u001b[39m!\\n\\nHow are you?\"\n * ```\n * @see PrintOptions\n */\n (options: PrintOptions): print;\n};\n\nconst createPrint = (options: PrintOptions): print => {\n return ((templateOrOptions: PrintOptions | string | TemplateStringsArray, ...values: unknown[]): print | undefined => {\n if (isSprintOptions(templateOrOptions)) {\n return createPrint({ ...options, ...templateOrOptions });\n }\n\n const { json, ...sprintOptions } = options;\n\n if (config.logFormat === \"json\") {\n if (json) {\n output.writeStdout(JSON.stringify(json) + \"\\n\");\n }\n return;\n }\n\n const text = sprint(sprintOptions)(templateOrOptions as TemplateStringsArray, ...values);\n output.writeStdout(text);\n return;\n }) as print;\n};\n\nexport const print = createPrint({ ensureNewLine: false });\nexport const println = createPrint({ ensureNewLine: true });\n"],"names":["config","output","isSprintOptions","sprint","createPrint","options","templateOrOptions","values","json","sprintOptions","logFormat","writeStdout","JSON","stringify","text","print","ensureNewLine","println"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,sBAAsB;AAE7C,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,eAAe,EAAEC,MAAM,QAA4B,cAAc;AAiF1E,MAAMC,cAAc,CAACC;IACnB,OAAQ,CAACC,mBAAiE,GAAGC;QAC3E,IAAIL,gBAAgBI,oBAAoB;YACtC,OAAOF,YAAY;gBAAE,GAAGC,OAAO;gBAAE,GAAGC,iBAAiB;YAAC;QACxD;QAEA,MAAM,EAAEE,IAAI,EAAE,GAAGC,eAAe,GAAGJ;QAEnC,IAAIL,OAAOU,SAAS,KAAK,QAAQ;YAC/B,IAAIF,MAAM;gBACRP,OAAOU,WAAW,CAACC,KAAKC,SAAS,CAACL,QAAQ;YAC5C;YACA;QACF;QAEA,MAAMM,OAAOX,OAAOM,eAAeH,sBAA8CC;QACjFN,OAAOU,WAAW,CAACG;QACnB;IACF;AACF;AAEA,OAAO,MAAMC,QAAQX,YAAY;IAAEY,eAAe;AAAM,GAAG;AAC3D,OAAO,MAAMC,UAAUb,YAAY;IAAEY,eAAe;AAAK,GAAG"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import pluralize from "pluralize";
|
|
3
|
-
import { compact } from "../util/collection.js";
|
|
4
|
-
import { isGellyFile, isJavaScriptFile, isTypeScriptFile } from "../util/is.js";
|
|
5
|
-
import { println } from "./print.js";
|
|
6
|
-
import { sprint, sprintln } from "./sprint.js";
|
|
7
|
-
export const ProblemSeverity = Object.freeze({
|
|
8
|
-
Fatal: "Fatal",
|
|
9
|
-
Error: "Error",
|
|
10
|
-
Warning: "Warning",
|
|
11
|
-
Info: "Info"
|
|
12
|
-
});
|
|
13
|
-
export const sprintProblems = ({ problems: groupedProblems, showFileTypes, ...sprintOptions })=>{
|
|
14
|
-
let output = "";
|
|
15
|
-
for (const [name, problems] of Object.entries(groupedProblems)){
|
|
16
|
-
output += sprintln("");
|
|
17
|
-
output += sprintln`• {cyan ${name}} {redBright ${pluralize("problem", problems.length, true)}}`;
|
|
18
|
-
for (const problem of problems){
|
|
19
|
-
const [message, ...lines] = problem.message.split("\n");
|
|
20
|
-
output += sprint` {red ✖} `;
|
|
21
|
-
if (showFileTypes ?? problem.type === "SourceFile") {
|
|
22
|
-
output += sprint`${filetype(name)} `;
|
|
23
|
-
}
|
|
24
|
-
output += sprint(message);
|
|
25
|
-
for (const line of lines){
|
|
26
|
-
output += sprintln("");
|
|
27
|
-
output += sprint` ${line}`;
|
|
28
|
-
}
|
|
29
|
-
for (const label of problem.labels){
|
|
30
|
-
output += sprint` {dim ${label}}`;
|
|
31
|
-
}
|
|
32
|
-
output += sprintln("");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return sprintln(sprintOptions)(output);
|
|
36
|
-
};
|
|
37
|
-
export const printProblems = (options)=>{
|
|
38
|
-
println(sprintProblems(options));
|
|
39
|
-
};
|
|
40
|
-
export const filetype = (filename)=>{
|
|
41
|
-
switch(true){
|
|
42
|
-
case isJavaScriptFile(filename):
|
|
43
|
-
return chalk.yellowBright("JavaScript");
|
|
44
|
-
case isTypeScriptFile(filename):
|
|
45
|
-
return chalk.blue("TypeScript");
|
|
46
|
-
case isGellyFile(filename):
|
|
47
|
-
return chalk.magenta("Gelly");
|
|
48
|
-
default:
|
|
49
|
-
return chalk.gray("File");
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
export const publishIssuesToProblems = (issues)=>{
|
|
53
|
-
const problems = {};
|
|
54
|
-
for (const issue of issues){
|
|
55
|
-
const name = issue.node?.apiIdentifier ?? issue.node?.name ?? "Other";
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
57
|
-
problems[name] ??= [];
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
-
problems[name].push({
|
|
60
|
-
type: issue.node?.type ?? "Unknown",
|
|
61
|
-
severity: issue.severity,
|
|
62
|
-
message: issue.message,
|
|
63
|
-
labels: compact(issue.nodeLabels?.map((label)=>label?.identifier) ?? [])
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return problems;
|
|
67
|
-
};
|
|
68
|
-
export const filesyncProblemsToProblems = (filesyncProblems)=>{
|
|
69
|
-
const problems = {};
|
|
70
|
-
for (const filesyncProblem of filesyncProblems){
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
72
|
-
problems[filesyncProblem.path] ??= [];
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
-
problems[filesyncProblem.path].push({
|
|
75
|
-
type: filesyncProblem.type,
|
|
76
|
-
severity: filesyncProblem.level,
|
|
77
|
-
message: filesyncProblem.message,
|
|
78
|
-
labels: []
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return problems;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=problems.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/output/problems.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport pluralize from \"pluralize\";\nimport type { Problem as FileSyncProblem, PublishIssue } from \"../../__generated__/graphql.js\";\nimport { compact } from \"../util/collection.js\";\nimport { isGellyFile, isJavaScriptFile, isTypeScriptFile } from \"../util/is.js\";\nimport { println } from \"./print.js\";\nimport { sprint, sprintln, type SprintOptions } from \"./sprint.js\";\n\nexport type Problems = Record<string, Problem[]>;\n\nexport type Problem = {\n type: string;\n severity: ProblemSeverity;\n message: string;\n labels: string[];\n};\n\nexport const ProblemSeverity = Object.freeze({\n Fatal: \"Fatal\",\n Error: \"Error\",\n Warning: \"Warning\",\n Info: \"Info\",\n});\n\nexport type ProblemSeverity = keyof typeof ProblemSeverity;\n\nexport type PrintProblemsOptions = SprintOptions & {\n /**\n * The problems to print.\n */\n problems: Problems;\n\n /**\n * Whether to show the file type in the output.\n *\n * @default problem.type === \"SourceFile\"\n */\n showFileTypes?: boolean;\n};\n\nexport const sprintProblems = ({ problems: groupedProblems, showFileTypes, ...sprintOptions }: PrintProblemsOptions): string => {\n let output = \"\";\n\n for (const [name, problems] of Object.entries(groupedProblems)) {\n output += sprintln(\"\");\n output += sprintln`• {cyan ${name}} {redBright ${pluralize(\"problem\", problems.length, true)}}`;\n for (const problem of problems) {\n const [message, ...lines] = problem.message.split(\"\\n\") as [string, ...string[]];\n\n output += sprint` {red ✖} `;\n if (showFileTypes ?? problem.type === \"SourceFile\") {\n output += sprint`${filetype(name)} `;\n }\n output += sprint(message);\n\n for (const line of lines) {\n output += sprintln(\"\");\n output += sprint` ${line}`;\n }\n\n for (const label of problem.labels) {\n output += sprint` {dim ${label}}`;\n }\n\n output += sprintln(\"\");\n }\n }\n\n return sprintln(sprintOptions)(output);\n};\n\nexport const printProblems = (options: PrintProblemsOptions): void => {\n println(sprintProblems(options));\n};\n\nexport const filetype = (filename: string): string => {\n switch (true) {\n case isJavaScriptFile(filename):\n return chalk.yellowBright(\"JavaScript\");\n case isTypeScriptFile(filename):\n return chalk.blue(\"TypeScript\");\n case isGellyFile(filename):\n return chalk.magenta(\"Gelly\");\n default:\n return chalk.gray(\"File\");\n }\n};\n\nexport const publishIssuesToProblems = (issues: PublishIssue[]): Problems => {\n const problems: Problems = {};\n for (const issue of issues) {\n const name = issue.node?.apiIdentifier ?? issue.node?.name ?? \"Other\";\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n problems[name] ??= [];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n problems[name]!.push({\n type: issue.node?.type ?? \"Unknown\",\n severity: issue.severity as ProblemSeverity,\n message: issue.message,\n labels: compact(issue.nodeLabels?.map((label) => label?.identifier) ?? []),\n });\n }\n return problems;\n};\n\nexport const filesyncProblemsToProblems = (filesyncProblems: FileSyncProblem[]): Problems => {\n const problems: Problems = {};\n for (const filesyncProblem of filesyncProblems) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n problems[filesyncProblem.path] ??= [];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n problems[filesyncProblem.path]!.push({\n type: filesyncProblem.type,\n severity: filesyncProblem.level as ProblemSeverity,\n message: filesyncProblem.message,\n labels: [],\n });\n }\n return problems;\n};\n"],"names":["chalk","pluralize","compact","isGellyFile","isJavaScriptFile","isTypeScriptFile","println","sprint","sprintln","ProblemSeverity","Object","freeze","Fatal","Error","Warning","Info","sprintProblems","problems","groupedProblems","showFileTypes","sprintOptions","output","name","entries","length","problem","message","lines","split","type","filetype","line","label","labels","printProblems","options","filename","yellowBright","blue","magenta","gray","publishIssuesToProblems","issues","issue","node","apiIdentifier","push","severity","nodeLabels","map","identifier","filesyncProblemsToProblems","filesyncProblems","filesyncProblem","path","level"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,eAAe,YAAY;AAElC,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,gBAAgB;AAChF,SAASC,OAAO,QAAQ,aAAa;AACrC,SAASC,MAAM,EAAEC,QAAQ,QAA4B,cAAc;AAWnE,OAAO,MAAMC,kBAAkBC,OAAOC,MAAM,CAAC;IAC3CC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,MAAM;AACR,GAAG;AAkBH,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,UAAUC,eAAe,EAAEC,aAAa,EAAE,GAAGC,eAAqC;IACjH,IAAIC,SAAS;IAEb,KAAK,MAAM,CAACC,MAAML,SAAS,IAAIP,OAAOa,OAAO,CAACL,iBAAkB;QAC9DG,UAAUb,SAAS;QACnBa,UAAUb,QAAQ,CAAC,QAAQ,EAAEc,KAAK,aAAa,EAAErB,UAAU,WAAWgB,SAASO,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/F,KAAK,MAAMC,WAAWR,SAAU;YAC9B,MAAM,CAACS,SAAS,GAAGC,MAAM,GAAGF,QAAQC,OAAO,CAACE,KAAK,CAAC;YAElDP,UAAUd,MAAM,CAAC,UAAU,CAAC;YAC5B,IAAIY,iBAAiBM,QAAQI,IAAI,KAAK,cAAc;gBAClDR,UAAUd,MAAM,CAAC,EAAEuB,SAASR,MAAM,CAAC,CAAC;YACtC;YACAD,UAAUd,OAAOmB;YAEjB,KAAK,MAAMK,QAAQJ,MAAO;gBACxBN,UAAUb,SAAS;gBACnB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