@settlemint/sdk-cli 1.2.2-pr549e8ff1 → 1.2.2-pr65e8d754
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/cli.js +1014 -1013
- package/dist/cli.js.map +13 -13
- package/package.json +5 -5
package/dist/cli.js
CHANGED
@@ -259517,7 +259517,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
259517
259517
|
var package_default = {
|
259518
259518
|
name: "@settlemint/sdk-cli",
|
259519
259519
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
259520
|
-
version: "1.2.2-
|
259520
|
+
version: "1.2.2-pr65e8d754",
|
259521
259521
|
type: "module",
|
259522
259522
|
private: false,
|
259523
259523
|
license: "FSL-1.1-MIT",
|
@@ -259563,11 +259563,11 @@ var package_default = {
|
|
259563
259563
|
"@commander-js/extra-typings": "11.1.0",
|
259564
259564
|
commander: "11.1.0",
|
259565
259565
|
"@inquirer/confirm": "5.1.7",
|
259566
|
-
"@inquirer/input": "4.1.
|
259567
|
-
"@inquirer/password": "4.0.
|
259566
|
+
"@inquirer/input": "4.1.8",
|
259567
|
+
"@inquirer/password": "4.0.10",
|
259568
259568
|
"@inquirer/select": "4.0.10",
|
259569
|
-
"@settlemint/sdk-js": "1.2.2-
|
259570
|
-
"@settlemint/sdk-utils": "1.2.2-
|
259569
|
+
"@settlemint/sdk-js": "1.2.2-pr65e8d754",
|
259570
|
+
"@settlemint/sdk-utils": "1.2.2-pr65e8d754",
|
259571
259571
|
"@types/node": "22.13.10",
|
259572
259572
|
"@types/semver": "7.5.8",
|
259573
259573
|
"@types/which": "3.0.4",
|
@@ -265042,1116 +265042,1117 @@ function sanitizeName(value4, length = 35) {
|
|
265042
265042
|
}).slice(0, length).replaceAll(/(^\d*)/g, "").replaceAll(/(-$)/g, "").replaceAll(/(^-)/g, "");
|
265043
265043
|
}
|
265044
265044
|
|
265045
|
-
// ../../node_modules/@inquirer/input/dist/esm/
|
265046
|
-
var
|
265047
|
-
|
265048
|
-
|
265049
|
-
|
265050
|
-
|
265051
|
-
|
265052
|
-
|
265053
|
-
|
265054
|
-
|
265055
|
-
const [value4, setValue] = useState("");
|
265056
|
-
const prefix = usePrefix({ status, theme });
|
265057
|
-
useKeypress(async (key2, rl) => {
|
265058
|
-
if (status !== "idle") {
|
265059
|
-
return;
|
265060
|
-
}
|
265061
|
-
if (isEnterKey(key2)) {
|
265062
|
-
const answer = value4 || defaultValue;
|
265063
|
-
setStatus("loading");
|
265064
|
-
const isValid2 = required && !answer ? "You must provide a value" : await validate3(answer);
|
265065
|
-
if (isValid2 === true) {
|
265066
|
-
setValue(answer);
|
265067
|
-
setStatus("done");
|
265068
|
-
done(answer);
|
265069
|
-
} else {
|
265070
|
-
if (theme.validationFailureMode === "clear") {
|
265071
|
-
setValue("");
|
265072
|
-
} else {
|
265073
|
-
rl.write(value4);
|
265074
|
-
}
|
265075
|
-
setError(isValid2 || "You must provide a valid value");
|
265076
|
-
setStatus("idle");
|
265077
|
-
}
|
265078
|
-
} else if (isBackspaceKey(key2) && !value4) {
|
265079
|
-
setDefaultValue(undefined);
|
265080
|
-
} else if (key2.name === "tab" && !value4) {
|
265081
|
-
setDefaultValue(undefined);
|
265082
|
-
rl.clearLine(0);
|
265083
|
-
rl.write(defaultValue);
|
265084
|
-
setValue(defaultValue);
|
265085
|
-
} else {
|
265086
|
-
setValue(rl.line);
|
265087
|
-
setError(undefined);
|
265088
|
-
}
|
265089
|
-
});
|
265090
|
-
const message = theme.style.message(config3.message, status);
|
265091
|
-
let formattedValue = value4;
|
265092
|
-
if (typeof config3.transformer === "function") {
|
265093
|
-
formattedValue = config3.transformer(value4, { isFinal: status === "done" });
|
265094
|
-
} else if (status === "done") {
|
265095
|
-
formattedValue = theme.style.answer(value4);
|
265096
|
-
}
|
265097
|
-
let defaultStr;
|
265098
|
-
if (defaultValue && status !== "done" && !value4) {
|
265099
|
-
defaultStr = theme.style.defaultAnswer(defaultValue);
|
265100
|
-
}
|
265101
|
-
let error5 = "";
|
265102
|
-
if (errorMsg) {
|
265103
|
-
error5 = theme.style.error(errorMsg);
|
265045
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/key.js
|
265046
|
+
var isBackspaceKey2 = (key2) => key2.name === "backspace";
|
265047
|
+
var isEnterKey2 = (key2) => key2.name === "enter" || key2.name === "return";
|
265048
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/errors.js
|
265049
|
+
class AbortPromptError2 extends Error {
|
265050
|
+
name = "AbortPromptError";
|
265051
|
+
message = "Prompt was aborted";
|
265052
|
+
constructor(options) {
|
265053
|
+
super();
|
265054
|
+
this.cause = options?.cause;
|
265104
265055
|
}
|
265105
|
-
|
265106
|
-
[prefix, message, defaultStr, formattedValue].filter((v6) => v6 !== undefined).join(" "),
|
265107
|
-
error5
|
265108
|
-
];
|
265109
|
-
});
|
265056
|
+
}
|
265110
265057
|
|
265111
|
-
|
265112
|
-
|
265113
|
-
|
265114
|
-
env: env2,
|
265115
|
-
accept
|
265116
|
-
}) {
|
265117
|
-
const defaultSubgraphName = defaultName ? sanitizeName(defaultName) : undefined;
|
265118
|
-
if (accept) {
|
265119
|
-
return defaultSubgraphName ?? env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH;
|
265120
|
-
}
|
265121
|
-
const subgraphName = await esm_default2({
|
265122
|
-
message: "What is the name of your subgraph?",
|
265123
|
-
default: defaultSubgraphName,
|
265124
|
-
required: true
|
265125
|
-
});
|
265126
|
-
return sanitizeName(subgraphName);
|
265058
|
+
class CancelPromptError2 extends Error {
|
265059
|
+
name = "CancelPromptError";
|
265060
|
+
message = "Prompt was canceled";
|
265127
265061
|
}
|
265128
265062
|
|
265129
|
-
|
265130
|
-
|
265131
|
-
var import_ansi_escapes2 = __toESM(require_ansi_escapes(), 1);
|
265132
|
-
var selectTheme = {
|
265133
|
-
icon: { cursor: esm_default.pointer },
|
265134
|
-
style: {
|
265135
|
-
disabled: (text2) => import_yoctocolors_cjs3.default.dim(`- ${text2}`),
|
265136
|
-
description: (text2) => import_yoctocolors_cjs3.default.cyan(text2)
|
265137
|
-
},
|
265138
|
-
helpMode: "auto"
|
265139
|
-
};
|
265140
|
-
function isSelectable(item) {
|
265141
|
-
return !Separator.isSeparator(item) && !item.disabled;
|
265063
|
+
class ExitPromptError2 extends Error {
|
265064
|
+
name = "ExitPromptError";
|
265142
265065
|
}
|
265143
|
-
|
265144
|
-
|
265145
|
-
|
265146
|
-
|
265147
|
-
|
265148
|
-
|
265149
|
-
|
265150
|
-
|
265151
|
-
|
265152
|
-
|
265066
|
+
|
265067
|
+
class HookError2 extends Error {
|
265068
|
+
name = "HookError";
|
265069
|
+
}
|
265070
|
+
|
265071
|
+
class ValidationError2 extends Error {
|
265072
|
+
name = "ValidationError";
|
265073
|
+
}
|
265074
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/use-prefix.js
|
265075
|
+
import { AsyncResource as AsyncResource5 } from "node:async_hooks";
|
265076
|
+
|
265077
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/hook-engine.js
|
265078
|
+
import { AsyncLocalStorage as AsyncLocalStorage2, AsyncResource as AsyncResource4 } from "node:async_hooks";
|
265079
|
+
var hookStorage2 = new AsyncLocalStorage2;
|
265080
|
+
function createStore2(rl) {
|
265081
|
+
const store = {
|
265082
|
+
rl,
|
265083
|
+
hooks: [],
|
265084
|
+
hooksCleanup: [],
|
265085
|
+
hooksEffect: [],
|
265086
|
+
index: 0,
|
265087
|
+
handleChange() {}
|
265088
|
+
};
|
265089
|
+
return store;
|
265090
|
+
}
|
265091
|
+
function withHooks2(rl, cb) {
|
265092
|
+
const store = createStore2(rl);
|
265093
|
+
return hookStorage2.run(store, () => {
|
265094
|
+
function cycle(render) {
|
265095
|
+
store.handleChange = () => {
|
265096
|
+
store.index = 0;
|
265097
|
+
render();
|
265153
265098
|
};
|
265099
|
+
store.handleChange();
|
265154
265100
|
}
|
265155
|
-
|
265156
|
-
return {
|
265157
|
-
value: choice.value,
|
265158
|
-
name: name3,
|
265159
|
-
description: choice.description,
|
265160
|
-
short: choice.short ?? name3,
|
265161
|
-
disabled: choice.disabled ?? false
|
265162
|
-
};
|
265101
|
+
return cb(cycle);
|
265163
265102
|
});
|
265164
265103
|
}
|
265165
|
-
|
265166
|
-
const
|
265167
|
-
|
265168
|
-
|
265169
|
-
|
265170
|
-
|
265171
|
-
|
265172
|
-
|
265173
|
-
|
265174
|
-
|
265175
|
-
|
265176
|
-
|
265177
|
-
|
265104
|
+
function getStore2() {
|
265105
|
+
const store = hookStorage2.getStore();
|
265106
|
+
if (!store) {
|
265107
|
+
throw new HookError2("[Inquirer] Hook functions can only be called from within a prompt");
|
265108
|
+
}
|
265109
|
+
return store;
|
265110
|
+
}
|
265111
|
+
function readline3() {
|
265112
|
+
return getStore2().rl;
|
265113
|
+
}
|
265114
|
+
function withUpdates2(fn) {
|
265115
|
+
const wrapped = (...args) => {
|
265116
|
+
const store = getStore2();
|
265117
|
+
let shouldUpdate = false;
|
265118
|
+
const oldHandleChange = store.handleChange;
|
265119
|
+
store.handleChange = () => {
|
265120
|
+
shouldUpdate = true;
|
265121
|
+
};
|
265122
|
+
const returnValue = fn(...args);
|
265123
|
+
if (shouldUpdate) {
|
265124
|
+
oldHandleChange();
|
265178
265125
|
}
|
265179
|
-
|
265180
|
-
|
265181
|
-
|
265182
|
-
|
265183
|
-
|
265184
|
-
|
265185
|
-
|
265186
|
-
const
|
265187
|
-
const
|
265188
|
-
|
265189
|
-
|
265190
|
-
|
265191
|
-
|
265192
|
-
|
265193
|
-
}
|
265194
|
-
|
265195
|
-
|
265196
|
-
|
265197
|
-
|
265198
|
-
|
265199
|
-
|
265200
|
-
|
265201
|
-
|
265202
|
-
|
265203
|
-
|
265204
|
-
|
265205
|
-
|
265206
|
-
|
265207
|
-
|
265208
|
-
|
265126
|
+
store.handleChange = oldHandleChange;
|
265127
|
+
return returnValue;
|
265128
|
+
};
|
265129
|
+
return AsyncResource4.bind(wrapped);
|
265130
|
+
}
|
265131
|
+
function withPointer2(cb) {
|
265132
|
+
const store = getStore2();
|
265133
|
+
const { index } = store;
|
265134
|
+
const pointer = {
|
265135
|
+
get() {
|
265136
|
+
return store.hooks[index];
|
265137
|
+
},
|
265138
|
+
set(value4) {
|
265139
|
+
store.hooks[index] = value4;
|
265140
|
+
},
|
265141
|
+
initialized: index in store.hooks
|
265142
|
+
};
|
265143
|
+
const returnValue = cb(pointer);
|
265144
|
+
store.index++;
|
265145
|
+
return returnValue;
|
265146
|
+
}
|
265147
|
+
function handleChange2() {
|
265148
|
+
getStore2().handleChange();
|
265149
|
+
}
|
265150
|
+
var effectScheduler2 = {
|
265151
|
+
queue(cb) {
|
265152
|
+
const store = getStore2();
|
265153
|
+
const { index } = store;
|
265154
|
+
store.hooksEffect.push(() => {
|
265155
|
+
store.hooksCleanup[index]?.();
|
265156
|
+
const cleanFn = cb(readline3());
|
265157
|
+
if (cleanFn != null && typeof cleanFn !== "function") {
|
265158
|
+
throw new ValidationError2("useEffect return value must be a cleanup function or nothing.");
|
265209
265159
|
}
|
265210
|
-
|
265211
|
-
|
265212
|
-
|
265213
|
-
|
265214
|
-
|
265215
|
-
|
265216
|
-
|
265217
|
-
|
265160
|
+
store.hooksCleanup[index] = cleanFn;
|
265161
|
+
});
|
265162
|
+
},
|
265163
|
+
run() {
|
265164
|
+
const store = getStore2();
|
265165
|
+
withUpdates2(() => {
|
265166
|
+
store.hooksEffect.forEach((effect) => {
|
265167
|
+
effect();
|
265218
265168
|
});
|
265219
|
-
|
265220
|
-
|
265221
|
-
|
265222
|
-
|
265223
|
-
|
265224
|
-
|
265169
|
+
store.hooksEffect.length = 0;
|
265170
|
+
})();
|
265171
|
+
},
|
265172
|
+
clearAll() {
|
265173
|
+
const store = getStore2();
|
265174
|
+
store.hooksCleanup.forEach((cleanFn) => {
|
265175
|
+
cleanFn?.();
|
265176
|
+
});
|
265177
|
+
store.hooksEffect.length = 0;
|
265178
|
+
store.hooksCleanup.length = 0;
|
265179
|
+
}
|
265180
|
+
};
|
265181
|
+
|
265182
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/use-state.js
|
265183
|
+
function useState2(defaultValue) {
|
265184
|
+
return withPointer2((pointer) => {
|
265185
|
+
const setFn = (newValue) => {
|
265186
|
+
if (pointer.get() !== newValue) {
|
265187
|
+
pointer.set(newValue);
|
265188
|
+
handleChange2();
|
265189
|
+
}
|
265190
|
+
};
|
265191
|
+
if (pointer.initialized) {
|
265192
|
+
return [pointer.get(), setFn];
|
265225
265193
|
}
|
265194
|
+
const value4 = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
265195
|
+
pointer.set(value4);
|
265196
|
+
return [value4, setFn];
|
265226
265197
|
});
|
265227
|
-
|
265228
|
-
|
265229
|
-
|
265230
|
-
|
265231
|
-
|
265232
|
-
|
265233
|
-
|
265234
|
-
|
265235
|
-
|
265236
|
-
helpTipBottom = `
|
265237
|
-
${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
265238
|
-
} else {
|
265239
|
-
helpTipTop = theme.style.help("(Use arrow keys)");
|
265198
|
+
}
|
265199
|
+
|
265200
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/use-effect.js
|
265201
|
+
function useEffect2(cb, depArray) {
|
265202
|
+
withPointer2((pointer) => {
|
265203
|
+
const oldDeps = pointer.get();
|
265204
|
+
const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i6) => !Object.is(dep, oldDeps[i6]));
|
265205
|
+
if (hasChanged) {
|
265206
|
+
effectScheduler2.queue(cb);
|
265240
265207
|
}
|
265241
|
-
|
265242
|
-
const page = usePagination({
|
265243
|
-
items,
|
265244
|
-
active,
|
265245
|
-
renderItem({ item, isActive }) {
|
265246
|
-
if (Separator.isSeparator(item)) {
|
265247
|
-
return ` ${item.separator}`;
|
265248
|
-
}
|
265249
|
-
if (item.disabled) {
|
265250
|
-
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
265251
|
-
return theme.style.disabled(`${item.name} ${disabledLabel}`);
|
265252
|
-
}
|
265253
|
-
const color = isActive ? theme.style.highlight : (x6) => x6;
|
265254
|
-
const cursor = isActive ? theme.icon.cursor : ` `;
|
265255
|
-
return color(`${cursor} ${item.name}`);
|
265256
|
-
},
|
265257
|
-
pageSize,
|
265258
|
-
loop
|
265208
|
+
pointer.set(depArray);
|
265259
265209
|
});
|
265260
|
-
|
265261
|
-
|
265210
|
+
}
|
265211
|
+
|
265212
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/theme.js
|
265213
|
+
var import_yoctocolors_cjs3 = __toESM(require_yoctocolors_cjs(), 1);
|
265214
|
+
var defaultTheme2 = {
|
265215
|
+
prefix: {
|
265216
|
+
idle: import_yoctocolors_cjs3.default.blue("?"),
|
265217
|
+
done: import_yoctocolors_cjs3.default.green(esm_default.tick)
|
265218
|
+
},
|
265219
|
+
spinner: {
|
265220
|
+
interval: 80,
|
265221
|
+
frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => import_yoctocolors_cjs3.default.yellow(frame))
|
265222
|
+
},
|
265223
|
+
style: {
|
265224
|
+
answer: import_yoctocolors_cjs3.default.cyan,
|
265225
|
+
message: import_yoctocolors_cjs3.default.bold,
|
265226
|
+
error: (text2) => import_yoctocolors_cjs3.default.red(`> ${text2}`),
|
265227
|
+
defaultAnswer: (text2) => import_yoctocolors_cjs3.default.dim(`(${text2})`),
|
265228
|
+
help: import_yoctocolors_cjs3.default.dim,
|
265229
|
+
highlight: import_yoctocolors_cjs3.default.cyan,
|
265230
|
+
key: (text2) => import_yoctocolors_cjs3.default.cyan(import_yoctocolors_cjs3.default.bold(`<${text2}>`))
|
265262
265231
|
}
|
265263
|
-
|
265264
|
-
${theme.style.description(selectedChoice.description)}` : ``;
|
265265
|
-
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
265266
|
-
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
|
265267
|
-
});
|
265232
|
+
};
|
265268
265233
|
|
265269
|
-
//
|
265270
|
-
|
265271
|
-
|
265272
|
-
|
265273
|
-
|
265274
|
-
|
265275
|
-
|
265276
|
-
allowAll = false,
|
265277
|
-
allowNew = false,
|
265278
|
-
isCi = is_in_ci_default
|
265279
|
-
}) {
|
265280
|
-
const autoAccept = isCi || !!accept;
|
265281
|
-
const subgraphNames = env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS?.map((endpoint) => endpoint.split("/").pop()).filter(Boolean) ?? [];
|
265282
|
-
if (autoAccept) {
|
265283
|
-
if (allowAll) {
|
265284
|
-
return subgraphNames;
|
265285
|
-
}
|
265286
|
-
if (env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH) {
|
265287
|
-
return [env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH];
|
265288
|
-
}
|
265289
|
-
return subgraphNames.length === 1 ? subgraphNames : [];
|
265234
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/make-theme.js
|
265235
|
+
function isPlainObject3(value4) {
|
265236
|
+
if (typeof value4 !== "object" || value4 === null)
|
265237
|
+
return false;
|
265238
|
+
let proto = value4;
|
265239
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
265240
|
+
proto = Object.getPrototypeOf(proto);
|
265290
265241
|
}
|
265291
|
-
|
265292
|
-
|
265293
|
-
|
265294
|
-
|
265295
|
-
|
265296
|
-
|
265242
|
+
return Object.getPrototypeOf(value4) === proto;
|
265243
|
+
}
|
265244
|
+
function deepMerge3(...objects) {
|
265245
|
+
const output = {};
|
265246
|
+
for (const obj of objects) {
|
265247
|
+
for (const [key2, value4] of Object.entries(obj)) {
|
265248
|
+
const prevValue = output[key2];
|
265249
|
+
output[key2] = isPlainObject3(prevValue) && isPlainObject3(value4) ? deepMerge3(prevValue, value4) : value4;
|
265297
265250
|
}
|
265298
265251
|
}
|
265299
|
-
|
265300
|
-
|
265301
|
-
|
265302
|
-
|
265303
|
-
|
265304
|
-
|
265305
|
-
|
265306
|
-
|
265307
|
-
|
265308
|
-
|
265309
|
-
|
265310
|
-
|
265311
|
-
|
265312
|
-
|
265313
|
-
}
|
265314
|
-
|
265315
|
-
|
265316
|
-
|
265317
|
-
|
265318
|
-
|
265319
|
-
|
265320
|
-
|
265321
|
-
|
265322
|
-
|
265323
|
-
|
265324
|
-
|
265325
|
-
|
265326
|
-
|
265327
|
-
|
265328
|
-
|
265329
|
-
|
265330
|
-
|
265331
|
-
if (!newSubgraphName) {
|
265332
|
-
return [];
|
265252
|
+
return output;
|
265253
|
+
}
|
265254
|
+
function makeTheme2(...themes) {
|
265255
|
+
const themesToMerge = [
|
265256
|
+
defaultTheme2,
|
265257
|
+
...themes.filter((theme) => theme != null)
|
265258
|
+
];
|
265259
|
+
return deepMerge3(...themesToMerge);
|
265260
|
+
}
|
265261
|
+
|
265262
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/use-prefix.js
|
265263
|
+
function usePrefix2({ status = "idle", theme }) {
|
265264
|
+
const [showLoader, setShowLoader] = useState2(false);
|
265265
|
+
const [tick, setTick] = useState2(0);
|
265266
|
+
const { prefix, spinner: spinner2 } = makeTheme2(theme);
|
265267
|
+
useEffect2(() => {
|
265268
|
+
if (status === "loading") {
|
265269
|
+
let tickInterval;
|
265270
|
+
let inc = -1;
|
265271
|
+
const delayTimeout = setTimeout(AsyncResource5.bind(() => {
|
265272
|
+
setShowLoader(true);
|
265273
|
+
tickInterval = setInterval(AsyncResource5.bind(() => {
|
265274
|
+
inc = inc + 1;
|
265275
|
+
setTick(inc % spinner2.frames.length);
|
265276
|
+
}), spinner2.interval);
|
265277
|
+
}), 300);
|
265278
|
+
return () => {
|
265279
|
+
clearTimeout(delayTimeout);
|
265280
|
+
clearInterval(tickInterval);
|
265281
|
+
};
|
265282
|
+
} else {
|
265283
|
+
setShowLoader(false);
|
265333
265284
|
}
|
265334
|
-
|
265285
|
+
}, [status]);
|
265286
|
+
if (showLoader) {
|
265287
|
+
return spinner2.frames[tick];
|
265335
265288
|
}
|
265336
|
-
|
265289
|
+
const iconName = status === "loading" ? "idle" : status;
|
265290
|
+
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
265291
|
+
}
|
265292
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/use-ref.js
|
265293
|
+
function useRef2(val) {
|
265294
|
+
return useState2({ current: val })[0];
|
265337
265295
|
}
|
265338
265296
|
|
265339
|
-
//
|
265340
|
-
function
|
265341
|
-
|
265342
|
-
|
265297
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/use-keypress.js
|
265298
|
+
function useKeypress2(userHandler) {
|
265299
|
+
const signal = useRef2(userHandler);
|
265300
|
+
signal.current = userHandler;
|
265301
|
+
useEffect2((rl) => {
|
265302
|
+
let ignore = false;
|
265303
|
+
const handler = withUpdates2((_input, event) => {
|
265304
|
+
if (ignore)
|
265305
|
+
return;
|
265306
|
+
signal.current(event, rl);
|
265307
|
+
});
|
265308
|
+
rl.input.on("keypress", handler);
|
265309
|
+
return () => {
|
265310
|
+
ignore = true;
|
265311
|
+
rl.input.removeListener("keypress", handler);
|
265312
|
+
};
|
265313
|
+
}, []);
|
265314
|
+
}
|
265315
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/utils.js
|
265316
|
+
var import_cli_width2 = __toESM(require_cli_width(), 1);
|
265317
|
+
var import_wrap_ansi2 = __toESM(require_wrap_ansi(), 1);
|
265318
|
+
function breakLines2(content, width) {
|
265319
|
+
return content.split(`
|
265320
|
+
`).flatMap((line) => import_wrap_ansi2.default(line, width, { trim: false, hard: true }).split(`
|
265321
|
+
`).map((str) => str.trimEnd())).join(`
|
265322
|
+
`);
|
265323
|
+
}
|
265324
|
+
function readlineWidth2() {
|
265325
|
+
return import_cli_width2.default({ defaultWidth: 80, output: readline3().output });
|
265326
|
+
}
|
265343
265327
|
|
265344
|
-
|
265345
|
-
|
265346
|
-
|
265347
|
-
|
265328
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
|
265329
|
+
var import_mute_stream2 = __toESM(require_lib(), 1);
|
265330
|
+
import * as readline4 from "node:readline";
|
265331
|
+
import { AsyncResource as AsyncResource6 } from "node:async_hooks";
|
265348
265332
|
|
265349
|
-
|
265333
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
|
265334
|
+
var import_ansi_escapes2 = __toESM(require_ansi_escapes(), 1);
|
265335
|
+
import { stripVTControlCharacters as stripVTControlCharacters3 } from "node:util";
|
265336
|
+
var height2 = (content) => content.split(`
|
265337
|
+
`).length;
|
265338
|
+
var lastLine2 = (content) => content.split(`
|
265339
|
+
`).pop() ?? "";
|
265340
|
+
function cursorDown2(n6) {
|
265341
|
+
return n6 > 0 ? import_ansi_escapes2.default.cursorDown(n6) : "";
|
265350
265342
|
}
|
265351
265343
|
|
265352
|
-
|
265353
|
-
|
265354
|
-
|
265355
|
-
|
265356
|
-
|
265357
|
-
|
265358
|
-
|
265359
|
-
|
265344
|
+
class ScreenManager2 {
|
265345
|
+
height = 0;
|
265346
|
+
extraLinesUnderPrompt = 0;
|
265347
|
+
cursorPos;
|
265348
|
+
rl;
|
265349
|
+
constructor(rl) {
|
265350
|
+
this.rl = rl;
|
265351
|
+
this.cursorPos = rl.getCursorPos();
|
265360
265352
|
}
|
265361
|
-
|
265362
|
-
|
265363
|
-
|
265364
|
-
|
265365
|
-
});
|
265366
|
-
if (!accessToken) {
|
265367
|
-
return;
|
265353
|
+
write(content) {
|
265354
|
+
this.rl.output.unmute();
|
265355
|
+
this.rl.output.write(content);
|
265356
|
+
this.rl.output.mute();
|
265368
265357
|
}
|
265369
|
-
|
265370
|
-
|
265371
|
-
const
|
265372
|
-
|
265373
|
-
|
265374
|
-
|
265375
|
-
|
265376
|
-
|
265377
|
-
|
265378
|
-
|
265379
|
-
|
265380
|
-
|
265381
|
-
|
265382
|
-
|
265383
|
-
|
265384
|
-
|
265385
|
-
|
265386
|
-
|
265387
|
-
|
265388
|
-
|
265389
|
-
|
265390
|
-
|
265391
|
-
|
265392
|
-
|
265393
|
-
|
265394
|
-
|
265395
|
-
}
|
265396
|
-
|
265397
|
-
fragment FullType on __Type {
|
265398
|
-
kind
|
265399
|
-
name
|
265400
|
-
description
|
265401
|
-
fields(includeDeprecated: true) {
|
265402
|
-
name
|
265403
|
-
description
|
265404
|
-
args {
|
265405
|
-
...InputValue
|
265406
|
-
}
|
265407
|
-
type {
|
265408
|
-
...TypeRef
|
265409
|
-
}
|
265410
|
-
isDeprecated
|
265411
|
-
deprecationReason
|
265412
|
-
}
|
265413
|
-
inputFields {
|
265414
|
-
...InputValue
|
265415
|
-
}
|
265416
|
-
interfaces {
|
265417
|
-
...TypeRef
|
265418
|
-
}
|
265419
|
-
enumValues(includeDeprecated: true) {
|
265420
|
-
name
|
265421
|
-
description
|
265422
|
-
isDeprecated
|
265423
|
-
deprecationReason
|
265424
|
-
}
|
265425
|
-
possibleTypes {
|
265426
|
-
...TypeRef
|
265427
|
-
}
|
265428
|
-
}
|
265429
|
-
|
265430
|
-
fragment InputValue on __InputValue {
|
265431
|
-
name
|
265432
|
-
description
|
265433
|
-
type { ...TypeRef }
|
265434
|
-
defaultValue
|
265435
|
-
}
|
265436
|
-
|
265437
|
-
fragment TypeRef on __Type {
|
265438
|
-
kind
|
265439
|
-
name
|
265440
|
-
ofType {
|
265441
|
-
kind
|
265442
|
-
name
|
265443
|
-
ofType {
|
265444
|
-
kind
|
265445
|
-
name
|
265446
|
-
ofType {
|
265447
|
-
kind
|
265448
|
-
name
|
265449
|
-
ofType {
|
265450
|
-
kind
|
265451
|
-
name
|
265452
|
-
ofType {
|
265453
|
-
kind
|
265454
|
-
name
|
265455
|
-
ofType {
|
265456
|
-
kind
|
265457
|
-
name
|
265458
|
-
ofType {
|
265459
|
-
kind
|
265460
|
-
name
|
265461
|
-
ofType {
|
265462
|
-
kind
|
265463
|
-
name
|
265464
|
-
ofType {
|
265465
|
-
kind
|
265466
|
-
name
|
265467
|
-
}
|
265468
|
-
}
|
265469
|
-
}
|
265470
|
-
}
|
265471
|
-
}
|
265472
|
-
}
|
265473
|
-
}
|
265474
|
-
}
|
265475
|
-
}
|
265476
|
-
}
|
265477
|
-
`
|
265478
|
-
})
|
265479
|
-
});
|
265480
|
-
await writeFile6(introspectionJsonPath, JSON.stringify(data));
|
265481
|
-
} catch (err) {
|
265482
|
-
const error5 = err;
|
265483
|
-
note(`GraphQL endpoint '${endpoint}' is not reachable: ${error5.message}`, "warn");
|
265484
|
-
return;
|
265358
|
+
render(content, bottomContent = "") {
|
265359
|
+
const promptLine = lastLine2(content);
|
265360
|
+
const rawPromptLine = stripVTControlCharacters3(promptLine);
|
265361
|
+
let prompt = rawPromptLine;
|
265362
|
+
if (this.rl.line.length > 0) {
|
265363
|
+
prompt = prompt.slice(0, -this.rl.line.length);
|
265364
|
+
}
|
265365
|
+
this.rl.setPrompt(prompt);
|
265366
|
+
this.cursorPos = this.rl.getCursorPos();
|
265367
|
+
const width = readlineWidth2();
|
265368
|
+
content = breakLines2(content, width);
|
265369
|
+
bottomContent = breakLines2(bottomContent, width);
|
265370
|
+
if (rawPromptLine.length % width === 0) {
|
265371
|
+
content += `
|
265372
|
+
`;
|
265373
|
+
}
|
265374
|
+
let output = content + (bottomContent ? `
|
265375
|
+
` + bottomContent : "");
|
265376
|
+
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
|
265377
|
+
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height2(bottomContent) : 0);
|
265378
|
+
if (bottomContentHeight > 0)
|
265379
|
+
output += import_ansi_escapes2.default.cursorUp(bottomContentHeight);
|
265380
|
+
output += import_ansi_escapes2.default.cursorTo(this.cursorPos.cols);
|
265381
|
+
this.write(cursorDown2(this.extraLinesUnderPrompt) + import_ansi_escapes2.default.eraseLines(this.height) + output);
|
265382
|
+
this.extraLinesUnderPrompt = bottomContentHeight;
|
265383
|
+
this.height = height2(output);
|
265485
265384
|
}
|
265486
|
-
|
265487
|
-
|
265488
|
-
|
265489
|
-
|
265490
|
-
|
265491
|
-
|
265492
|
-
});
|
265493
|
-
} finally {
|
265494
|
-
await rm2(introspectionJsonPath);
|
265385
|
+
checkCursorPos() {
|
265386
|
+
const cursorPos = this.rl.getCursorPos();
|
265387
|
+
if (cursorPos.cols !== this.cursorPos.cols) {
|
265388
|
+
this.write(import_ansi_escapes2.default.cursorTo(cursorPos.cols));
|
265389
|
+
this.cursorPos = cursorPos;
|
265390
|
+
}
|
265495
265391
|
}
|
265496
|
-
|
265497
|
-
|
265498
|
-
|
265499
|
-
|
265500
|
-
|
265501
|
-
|
265502
|
-
|
265503
|
-
|
265504
|
-
AddressHash: string;
|
265505
|
-
/** Unpadded big-endian hexadecimal number where each byte pair maps to underlying binary */
|
265506
|
-
Data: string;
|
265507
|
-
/** ISO8601 formatted UTC datetime string */
|
265508
|
-
DateTime: string;
|
265509
|
-
/** String representation of a signed double-precision decimal value */
|
265510
|
-
Decimal: string;
|
265511
|
-
/** 32-byte KECCAK-256 hash */
|
265512
|
-
FullHash: string;
|
265513
|
-
/** Arbitrary JSON string data as UTF-8 */
|
265514
|
-
Json: string;
|
265515
|
-
/** 16 hex character (128 bits/8 bytes) nonce from Proof-of-Work */
|
265516
|
-
NonceHash: string;
|
265517
|
-
/** Smallest fractional unit of Ether, represented as a string for integer math */
|
265518
|
-
Wei: string;
|
265519
|
-
};
|
265520
|
-
}>({
|
265521
|
-
instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT!,
|
265522
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!, // undefined in browser, by design to not leak the secrets
|
265523
|
-
});
|
265524
|
-
|
265525
|
-
export const blockscoutUiEndpoint = process.env.SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT!;`;
|
265526
|
-
await writeTemplate(template, "/lib/settlemint", "blockscout.ts");
|
265527
|
-
const projectDir = await projectRoot3();
|
265528
|
-
if (!await isPackageInstalled(PACKAGE_NAME4, projectDir)) {
|
265529
|
-
await installDependencies(PACKAGE_NAME4, projectDir);
|
265392
|
+
done({ clearContent }) {
|
265393
|
+
this.rl.setPrompt("");
|
265394
|
+
let output = cursorDown2(this.extraLinesUnderPrompt);
|
265395
|
+
output += clearContent ? import_ansi_escapes2.default.eraseLines(this.height) : `
|
265396
|
+
`;
|
265397
|
+
output += import_ansi_escapes2.default.cursorShow;
|
265398
|
+
this.write(output);
|
265399
|
+
this.rl.close();
|
265530
265400
|
}
|
265531
265401
|
}
|
265532
265402
|
|
265533
|
-
//
|
265534
|
-
|
265535
|
-
|
265536
|
-
|
265537
|
-
|
265538
|
-
|
265539
|
-
|
265540
|
-
|
265541
|
-
|
265403
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/promise-polyfill.js
|
265404
|
+
class PromisePolyfill2 extends Promise {
|
265405
|
+
static withResolver() {
|
265406
|
+
let resolve5;
|
265407
|
+
let reject;
|
265408
|
+
const promise = new Promise((res, rej) => {
|
265409
|
+
resolve5 = res;
|
265410
|
+
reject = rej;
|
265411
|
+
});
|
265412
|
+
return { promise, resolve: resolve5, reject };
|
265542
265413
|
}
|
265543
|
-
|
265414
|
+
}
|
265544
265415
|
|
265545
|
-
|
265546
|
-
|
265547
|
-
|
265548
|
-
|
265549
|
-
|
265550
|
-
|
265551
|
-
|
265552
|
-
|
265416
|
+
// ../../node_modules/@inquirer/input/node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
|
265417
|
+
function getCallSites2() {
|
265418
|
+
const _prepareStackTrace = Error.prepareStackTrace;
|
265419
|
+
let result = [];
|
265420
|
+
try {
|
265421
|
+
Error.prepareStackTrace = (_5, callSites) => {
|
265422
|
+
const callSitesWithoutCurrent = callSites.slice(1);
|
265423
|
+
result = callSitesWithoutCurrent;
|
265424
|
+
return callSitesWithoutCurrent;
|
265425
|
+
};
|
265426
|
+
new Error().stack;
|
265427
|
+
} catch {
|
265428
|
+
return result;
|
265553
265429
|
}
|
265430
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
265431
|
+
return result;
|
265554
265432
|
}
|
265555
|
-
|
265556
|
-
|
265557
|
-
|
265558
|
-
|
265559
|
-
|
265560
|
-
|
265561
|
-
|
265562
|
-
|
265563
|
-
|
265564
|
-
|
265565
|
-
|
265566
|
-
const clientTemplate = `import { createServerMinioClient } from "${PACKAGE_NAME6}";
|
265567
|
-
|
265568
|
-
export const { client } = createServerMinioClient({
|
265569
|
-
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
265570
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
|
265571
|
-
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
265572
|
-
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
265573
|
-
});`;
|
265574
|
-
await writeTemplate(clientTemplate, "/lib/settlemint", "minio.ts");
|
265575
|
-
const projectDir = await projectRoot3();
|
265576
|
-
if (!await isPackageInstalled(PACKAGE_NAME6, projectDir)) {
|
265577
|
-
await installDependencies(PACKAGE_NAME6, projectDir);
|
265578
|
-
}
|
265579
|
-
}
|
265580
|
-
|
265581
|
-
// src/commands/codegen.ts
|
265582
|
-
function codegenCommand() {
|
265583
|
-
return new Command("codegen").option("--prod", "Connect to your production environment").option("--thegraph-subgraph-names <subgraph-names...>", "The name(s) of the TheGraph subgraph(s) to generate (skip if you want to generate all)").description("Generate GraphQL and REST types and queries").usage(createExamples([
|
265584
|
-
{
|
265585
|
-
description: "Generate GraphQL types and queries for your dApp",
|
265586
|
-
command: "codegen"
|
265587
|
-
},
|
265588
|
-
{
|
265589
|
-
description: "Generate GraphQL types and queries for specific TheGraph subgraphs",
|
265590
|
-
command: "codegen --thegraph-subgraph-names subgraph1 subgraph2"
|
265591
|
-
}
|
265592
|
-
])).action(async ({ prod, thegraphSubgraphNames }) => {
|
265593
|
-
intro("Generating GraphQL types and queries for your dApp");
|
265594
|
-
const env2 = await loadEnv(true, !!prod);
|
265595
|
-
if (!Array.isArray(thegraphSubgraphNames)) {
|
265596
|
-
thegraphSubgraphNames = await subgraphPrompt({
|
265597
|
-
env: env2,
|
265598
|
-
accept: true,
|
265599
|
-
message: "Which The Graph subgraph do you want to generate types for?",
|
265600
|
-
allowAll: true
|
265601
|
-
});
|
265602
|
-
}
|
265603
|
-
const { hasura, portal, thegraph, blockscout } = await spinner({
|
265604
|
-
startMessage: "Testing configured GraphQL schema",
|
265605
|
-
task: async () => {
|
265606
|
-
return codegenTsconfig(env2, thegraphSubgraphNames);
|
265607
|
-
},
|
265608
|
-
stopMessage: "Tested GraphQL schemas"
|
265433
|
+
function createPrompt2(view) {
|
265434
|
+
const callSites = getCallSites2();
|
265435
|
+
const prompt = (config3, context = {}) => {
|
265436
|
+
const { input = process.stdin, signal } = context;
|
265437
|
+
const cleanups = new Set;
|
265438
|
+
const output = new import_mute_stream2.default;
|
265439
|
+
output.pipe(context.output ?? process.stdout);
|
265440
|
+
const rl = readline4.createInterface({
|
265441
|
+
terminal: true,
|
265442
|
+
input,
|
265443
|
+
output
|
265609
265444
|
});
|
265610
|
-
|
265611
|
-
|
265612
|
-
|
265613
|
-
|
265614
|
-
|
265615
|
-
|
265616
|
-
|
265617
|
-
|
265618
|
-
|
265619
|
-
|
265620
|
-
|
265621
|
-
}
|
265622
|
-
if (blockscout) {
|
265623
|
-
note("Generating Blockscout resources");
|
265624
|
-
await codegenBlockscout(env2);
|
265625
|
-
}
|
265626
|
-
if (shouldCodegenMinio(env2)) {
|
265627
|
-
note("Generating Minio resources");
|
265628
|
-
await codegenMinio(env2);
|
265629
|
-
}
|
265630
|
-
if (shouldCodegenIpfs(env2)) {
|
265631
|
-
note("Generating IPFS resources");
|
265632
|
-
await codegenIpfs(env2);
|
265445
|
+
const screen = new ScreenManager2(rl);
|
265446
|
+
const { promise, resolve: resolve5, reject } = PromisePolyfill2.withResolver();
|
265447
|
+
const cancel3 = () => reject(new CancelPromptError2);
|
265448
|
+
if (signal) {
|
265449
|
+
const abort = () => reject(new AbortPromptError2({ cause: signal.reason }));
|
265450
|
+
if (signal.aborted) {
|
265451
|
+
abort();
|
265452
|
+
return Object.assign(promise, { cancel: cancel3 });
|
265453
|
+
}
|
265454
|
+
signal.addEventListener("abort", abort);
|
265455
|
+
cleanups.add(() => signal.removeEventListener("abort", abort));
|
265633
265456
|
}
|
265634
|
-
|
265635
|
-
|
265636
|
-
|
265637
|
-
|
265457
|
+
cleanups.add(onExit((code2, signal2) => {
|
265458
|
+
reject(new ExitPromptError2(`User force closed the prompt with ${code2} ${signal2}`));
|
265459
|
+
}));
|
265460
|
+
const checkCursorPos = () => screen.checkCursorPos();
|
265461
|
+
rl.input.on("keypress", checkCursorPos);
|
265462
|
+
cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
|
265463
|
+
return withHooks2(rl, (cycle) => {
|
265464
|
+
const hooksCleanup = AsyncResource6.bind(() => effectScheduler2.clearAll());
|
265465
|
+
rl.on("close", hooksCleanup);
|
265466
|
+
cleanups.add(() => rl.removeListener("close", hooksCleanup));
|
265467
|
+
cycle(() => {
|
265468
|
+
try {
|
265469
|
+
const nextView = view(config3, (value4) => {
|
265470
|
+
setImmediate(() => resolve5(value4));
|
265471
|
+
});
|
265472
|
+
if (nextView === undefined) {
|
265473
|
+
const callerFilename = callSites[1]?.getFileName?.();
|
265474
|
+
throw new Error(`Prompt functions must return a string.
|
265475
|
+
at ${callerFilename}`);
|
265476
|
+
}
|
265477
|
+
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
265478
|
+
screen.render(content, bottomContent);
|
265479
|
+
effectScheduler2.run();
|
265480
|
+
} catch (error5) {
|
265481
|
+
reject(error5);
|
265482
|
+
}
|
265638
265483
|
});
|
265639
|
-
|
265640
|
-
|
265641
|
-
|
265642
|
-
}
|
265643
|
-
|
265644
|
-
|
265645
|
-
|
265646
|
-
|
265647
|
-
|
265648
|
-
|
265649
|
-
|
265650
|
-
|
265651
|
-
|
265652
|
-
|
265653
|
-
function boolToString(value4) {
|
265654
|
-
return value4 ? "Yes" : "No";
|
265484
|
+
return Object.assign(promise.then((answer) => {
|
265485
|
+
effectScheduler2.clearAll();
|
265486
|
+
return answer;
|
265487
|
+
}, (error5) => {
|
265488
|
+
effectScheduler2.clearAll();
|
265489
|
+
throw error5;
|
265490
|
+
}).finally(() => {
|
265491
|
+
cleanups.forEach((cleanup) => cleanup());
|
265492
|
+
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
265493
|
+
output.end();
|
265494
|
+
}).then(() => promise), { cancel: cancel3 });
|
265495
|
+
});
|
265496
|
+
};
|
265497
|
+
return prompt;
|
265655
265498
|
}
|
265656
|
-
|
265657
|
-
|
265658
|
-
|
265659
|
-
|
265660
|
-
|
265661
|
-
const
|
265662
|
-
|
265663
|
-
|
265664
|
-
|
265665
|
-
|
265666
|
-
|
265667
|
-
|
265668
|
-
|
265669
|
-
|
265499
|
+
// ../../node_modules/@inquirer/input/dist/esm/index.js
|
265500
|
+
var inputTheme = {
|
265501
|
+
validationFailureMode: "keep"
|
265502
|
+
};
|
265503
|
+
var esm_default2 = createPrompt2((config3, done) => {
|
265504
|
+
const { required, validate: validate3 = () => true } = config3;
|
265505
|
+
const theme = makeTheme2(inputTheme, config3.theme);
|
265506
|
+
const [status, setStatus] = useState2("idle");
|
265507
|
+
const [defaultValue = "", setDefaultValue] = useState2(config3.default);
|
265508
|
+
const [errorMsg, setError] = useState2();
|
265509
|
+
const [value4, setValue] = useState2("");
|
265510
|
+
const prefix = usePrefix2({ status, theme });
|
265511
|
+
useKeypress2(async (key3, rl) => {
|
265512
|
+
if (status !== "idle") {
|
265513
|
+
return;
|
265514
|
+
}
|
265515
|
+
if (isEnterKey2(key3)) {
|
265516
|
+
const answer = value4 || defaultValue;
|
265517
|
+
setStatus("loading");
|
265518
|
+
const isValid2 = required && !answer ? "You must provide a value" : await validate3(answer);
|
265519
|
+
if (isValid2 === true) {
|
265520
|
+
setValue(answer);
|
265521
|
+
setStatus("done");
|
265522
|
+
done(answer);
|
265523
|
+
} else {
|
265524
|
+
if (theme.validationFailureMode === "clear") {
|
265525
|
+
setValue("");
|
265526
|
+
} else {
|
265527
|
+
rl.write(value4);
|
265528
|
+
}
|
265529
|
+
setError(isValid2 || "You must provide a valid value");
|
265530
|
+
setStatus("idle");
|
265531
|
+
}
|
265532
|
+
} else if (isBackspaceKey2(key3) && !value4) {
|
265533
|
+
setDefaultValue(undefined);
|
265534
|
+
} else if (key3.name === "tab" && !value4) {
|
265535
|
+
setDefaultValue(undefined);
|
265670
265536
|
rl.clearLine(0);
|
265671
|
-
rl.write(
|
265672
|
-
setValue(
|
265537
|
+
rl.write(defaultValue);
|
265538
|
+
setValue(defaultValue);
|
265673
265539
|
} else {
|
265674
265540
|
setValue(rl.line);
|
265541
|
+
setError(undefined);
|
265675
265542
|
}
|
265676
265543
|
});
|
265544
|
+
const message = theme.style.message(config3.message, status);
|
265677
265545
|
let formattedValue = value4;
|
265678
|
-
|
265679
|
-
|
265546
|
+
if (typeof config3.transformer === "function") {
|
265547
|
+
formattedValue = config3.transformer(value4, { isFinal: status === "done" });
|
265548
|
+
} else if (status === "done") {
|
265680
265549
|
formattedValue = theme.style.answer(value4);
|
265681
|
-
} else {
|
265682
|
-
defaultValue = ` ${theme.style.defaultAnswer(config3.default === false ? "y/N" : "Y/n")}`;
|
265683
265550
|
}
|
265684
|
-
|
265685
|
-
|
265551
|
+
let defaultStr;
|
265552
|
+
if (defaultValue && status !== "done" && !value4) {
|
265553
|
+
defaultStr = theme.style.defaultAnswer(defaultValue);
|
265554
|
+
}
|
265555
|
+
let error5 = "";
|
265556
|
+
if (errorMsg) {
|
265557
|
+
error5 = theme.style.error(errorMsg);
|
265558
|
+
}
|
265559
|
+
return [
|
265560
|
+
[prefix, message, defaultStr, formattedValue].filter((v6) => v6 !== undefined).join(" "),
|
265561
|
+
error5
|
265562
|
+
];
|
265686
265563
|
});
|
265687
265564
|
|
265688
|
-
//
|
265689
|
-
|
265690
|
-
|
265691
|
-
|
265692
|
-
|
265693
|
-
|
265694
|
-
|
265695
|
-
|
265696
|
-
|
265565
|
+
// src/prompts/smart-contract-set/subgraph-name.prompt.ts
|
265566
|
+
async function subgraphNamePrompt({
|
265567
|
+
defaultName,
|
265568
|
+
env: env2,
|
265569
|
+
accept
|
265570
|
+
}) {
|
265571
|
+
const defaultSubgraphName = defaultName ? sanitizeName(defaultName) : undefined;
|
265572
|
+
if (accept) {
|
265573
|
+
return defaultSubgraphName ?? env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH;
|
265697
265574
|
}
|
265575
|
+
const subgraphName = await esm_default2({
|
265576
|
+
message: "What is the name of your subgraph?",
|
265577
|
+
default: defaultSubgraphName,
|
265578
|
+
required: true
|
265579
|
+
});
|
265580
|
+
return sanitizeName(subgraphName);
|
265698
265581
|
}
|
265699
265582
|
|
265700
|
-
|
265701
|
-
|
265702
|
-
|
265703
|
-
|
265704
|
-
|
265705
|
-
|
265706
|
-
|
265707
|
-
|
265708
|
-
|
265709
|
-
|
265710
|
-
|
265711
|
-
|
265712
|
-
|
265713
|
-
class ValidationError2 extends Error {
|
265714
|
-
name = "ValidationError";
|
265715
|
-
}
|
265716
|
-
// ../../node_modules/@inquirer/password/node_modules/@inquirer/core/dist/esm/lib/use-prefix.js
|
265717
|
-
import { AsyncResource as AsyncResource5 } from "node:async_hooks";
|
265718
|
-
|
265719
|
-
// ../../node_modules/@inquirer/password/node_modules/@inquirer/core/dist/esm/lib/hook-engine.js
|
265720
|
-
import { AsyncLocalStorage as AsyncLocalStorage2, AsyncResource as AsyncResource4 } from "node:async_hooks";
|
265721
|
-
var hookStorage2 = new AsyncLocalStorage2;
|
265722
|
-
function createStore2(rl) {
|
265723
|
-
const store = {
|
265724
|
-
rl,
|
265725
|
-
hooks: [],
|
265726
|
-
hooksCleanup: [],
|
265727
|
-
hooksEffect: [],
|
265728
|
-
index: 0,
|
265729
|
-
handleChange() {}
|
265730
|
-
};
|
265731
|
-
return store;
|
265583
|
+
// ../../node_modules/@inquirer/select/dist/esm/index.js
|
265584
|
+
var import_yoctocolors_cjs4 = __toESM(require_yoctocolors_cjs(), 1);
|
265585
|
+
var import_ansi_escapes3 = __toESM(require_ansi_escapes(), 1);
|
265586
|
+
var selectTheme = {
|
265587
|
+
icon: { cursor: esm_default.pointer },
|
265588
|
+
style: {
|
265589
|
+
disabled: (text2) => import_yoctocolors_cjs4.default.dim(`- ${text2}`),
|
265590
|
+
description: (text2) => import_yoctocolors_cjs4.default.cyan(text2)
|
265591
|
+
},
|
265592
|
+
helpMode: "auto"
|
265593
|
+
};
|
265594
|
+
function isSelectable(item) {
|
265595
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
265732
265596
|
}
|
265733
|
-
function
|
265734
|
-
|
265735
|
-
|
265736
|
-
|
265737
|
-
|
265738
|
-
|
265739
|
-
|
265597
|
+
function normalizeChoices(choices) {
|
265598
|
+
return choices.map((choice) => {
|
265599
|
+
if (Separator.isSeparator(choice))
|
265600
|
+
return choice;
|
265601
|
+
if (typeof choice === "string") {
|
265602
|
+
return {
|
265603
|
+
value: choice,
|
265604
|
+
name: choice,
|
265605
|
+
short: choice,
|
265606
|
+
disabled: false
|
265740
265607
|
};
|
265741
|
-
store.handleChange();
|
265742
265608
|
}
|
265743
|
-
|
265609
|
+
const name3 = choice.name ?? String(choice.value);
|
265610
|
+
return {
|
265611
|
+
value: choice.value,
|
265612
|
+
name: name3,
|
265613
|
+
description: choice.description,
|
265614
|
+
short: choice.short ?? name3,
|
265615
|
+
disabled: choice.disabled ?? false
|
265616
|
+
};
|
265744
265617
|
});
|
265745
265618
|
}
|
265746
|
-
|
265747
|
-
const
|
265748
|
-
|
265749
|
-
|
265750
|
-
|
265751
|
-
|
265752
|
-
|
265753
|
-
|
265754
|
-
|
265755
|
-
|
265756
|
-
|
265757
|
-
|
265758
|
-
|
265759
|
-
let shouldUpdate = false;
|
265760
|
-
const oldHandleChange = store.handleChange;
|
265761
|
-
store.handleChange = () => {
|
265762
|
-
shouldUpdate = true;
|
265763
|
-
};
|
265764
|
-
const returnValue = fn(...args);
|
265765
|
-
if (shouldUpdate) {
|
265766
|
-
oldHandleChange();
|
265619
|
+
var esm_default3 = createPrompt((config3, done) => {
|
265620
|
+
const { loop = true, pageSize = 7 } = config3;
|
265621
|
+
const firstRender = useRef(true);
|
265622
|
+
const theme = makeTheme(selectTheme, config3.theme);
|
265623
|
+
const [status, setStatus] = useState("idle");
|
265624
|
+
const prefix = usePrefix({ status, theme });
|
265625
|
+
const searchTimeoutRef = useRef();
|
265626
|
+
const items = useMemo(() => normalizeChoices(config3.choices), [config3.choices]);
|
265627
|
+
const bounds = useMemo(() => {
|
265628
|
+
const first = items.findIndex(isSelectable);
|
265629
|
+
const last = items.findLastIndex(isSelectable);
|
265630
|
+
if (first === -1) {
|
265631
|
+
throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
|
265767
265632
|
}
|
265768
|
-
|
265769
|
-
|
265770
|
-
|
265771
|
-
|
265772
|
-
|
265773
|
-
|
265774
|
-
|
265775
|
-
const
|
265776
|
-
const
|
265777
|
-
|
265778
|
-
|
265779
|
-
|
265780
|
-
|
265781
|
-
|
265782
|
-
}
|
265783
|
-
|
265784
|
-
|
265785
|
-
|
265786
|
-
|
265787
|
-
|
265788
|
-
|
265789
|
-
|
265790
|
-
|
265791
|
-
}
|
265792
|
-
var effectScheduler2 = {
|
265793
|
-
queue(cb) {
|
265794
|
-
const store = getStore2();
|
265795
|
-
const { index } = store;
|
265796
|
-
store.hooksEffect.push(() => {
|
265797
|
-
store.hooksCleanup[index]?.();
|
265798
|
-
const cleanFn = cb(readline3());
|
265799
|
-
if (cleanFn != null && typeof cleanFn !== "function") {
|
265800
|
-
throw new ValidationError2("useEffect return value must be a cleanup function or nothing.");
|
265633
|
+
return { first, last };
|
265634
|
+
}, [items]);
|
265635
|
+
const defaultItemIndex = useMemo(() => {
|
265636
|
+
if (!("default" in config3))
|
265637
|
+
return -1;
|
265638
|
+
return items.findIndex((item) => isSelectable(item) && item.value === config3.default);
|
265639
|
+
}, [config3.default, items]);
|
265640
|
+
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
265641
|
+
const selectedChoice = items[active];
|
265642
|
+
useKeypress((key3, rl) => {
|
265643
|
+
clearTimeout(searchTimeoutRef.current);
|
265644
|
+
if (isEnterKey(key3)) {
|
265645
|
+
setStatus("done");
|
265646
|
+
done(selectedChoice.value);
|
265647
|
+
} else if (isUpKey(key3) || isDownKey(key3)) {
|
265648
|
+
rl.clearLine(0);
|
265649
|
+
if (loop || isUpKey(key3) && active !== bounds.first || isDownKey(key3) && active !== bounds.last) {
|
265650
|
+
const offset = isUpKey(key3) ? -1 : 1;
|
265651
|
+
let next = active;
|
265652
|
+
do {
|
265653
|
+
next = (next + offset + items.length) % items.length;
|
265654
|
+
} while (!isSelectable(items[next]));
|
265655
|
+
setActive(next);
|
265801
265656
|
}
|
265802
|
-
|
265803
|
-
|
265804
|
-
|
265805
|
-
|
265806
|
-
|
265807
|
-
|
265808
|
-
|
265809
|
-
|
265657
|
+
} else if (isNumberKey(key3)) {
|
265658
|
+
rl.clearLine(0);
|
265659
|
+
const position = Number(key3.name) - 1;
|
265660
|
+
const item = items[position];
|
265661
|
+
if (item != null && isSelectable(item)) {
|
265662
|
+
setActive(position);
|
265663
|
+
}
|
265664
|
+
} else if (isBackspaceKey(key3)) {
|
265665
|
+
rl.clearLine(0);
|
265666
|
+
} else {
|
265667
|
+
const searchTerm = rl.line.toLowerCase();
|
265668
|
+
const matchIndex = items.findIndex((item) => {
|
265669
|
+
if (Separator.isSeparator(item) || !isSelectable(item))
|
265670
|
+
return false;
|
265671
|
+
return item.name.toLowerCase().startsWith(searchTerm);
|
265810
265672
|
});
|
265811
|
-
|
265812
|
-
|
265813
|
-
},
|
265814
|
-
clearAll() {
|
265815
|
-
const store = getStore2();
|
265816
|
-
store.hooksCleanup.forEach((cleanFn) => {
|
265817
|
-
cleanFn?.();
|
265818
|
-
});
|
265819
|
-
store.hooksEffect.length = 0;
|
265820
|
-
store.hooksCleanup.length = 0;
|
265821
|
-
}
|
265822
|
-
};
|
265823
|
-
|
265824
|
-
// ../../node_modules/@inquirer/password/node_modules/@inquirer/core/dist/esm/lib/use-state.js
|
265825
|
-
function useState2(defaultValue) {
|
265826
|
-
return withPointer2((pointer) => {
|
265827
|
-
const setFn = (newValue) => {
|
265828
|
-
if (pointer.get() !== newValue) {
|
265829
|
-
pointer.set(newValue);
|
265830
|
-
handleChange2();
|
265673
|
+
if (matchIndex !== -1) {
|
265674
|
+
setActive(matchIndex);
|
265831
265675
|
}
|
265832
|
-
|
265833
|
-
|
265834
|
-
|
265676
|
+
searchTimeoutRef.current = setTimeout(() => {
|
265677
|
+
rl.clearLine(0);
|
265678
|
+
}, 700);
|
265835
265679
|
}
|
265836
|
-
const value4 = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
265837
|
-
pointer.set(value4);
|
265838
|
-
return [value4, setFn];
|
265839
265680
|
});
|
265840
|
-
|
265841
|
-
|
265842
|
-
|
265843
|
-
|
265844
|
-
|
265845
|
-
|
265846
|
-
|
265847
|
-
|
265848
|
-
|
265681
|
+
useEffect(() => () => {
|
265682
|
+
clearTimeout(searchTimeoutRef.current);
|
265683
|
+
}, []);
|
265684
|
+
const message = theme.style.message(config3.message, status);
|
265685
|
+
let helpTipTop = "";
|
265686
|
+
let helpTipBottom = "";
|
265687
|
+
if (theme.helpMode === "always" || theme.helpMode === "auto" && firstRender.current) {
|
265688
|
+
firstRender.current = false;
|
265689
|
+
if (items.length > pageSize) {
|
265690
|
+
helpTipBottom = `
|
265691
|
+
${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
265692
|
+
} else {
|
265693
|
+
helpTipTop = theme.style.help("(Use arrow keys)");
|
265849
265694
|
}
|
265850
|
-
|
265695
|
+
}
|
265696
|
+
const page = usePagination({
|
265697
|
+
items,
|
265698
|
+
active,
|
265699
|
+
renderItem({ item, isActive }) {
|
265700
|
+
if (Separator.isSeparator(item)) {
|
265701
|
+
return ` ${item.separator}`;
|
265702
|
+
}
|
265703
|
+
if (item.disabled) {
|
265704
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
265705
|
+
return theme.style.disabled(`${item.name} ${disabledLabel}`);
|
265706
|
+
}
|
265707
|
+
const color = isActive ? theme.style.highlight : (x6) => x6;
|
265708
|
+
const cursor = isActive ? theme.icon.cursor : ` `;
|
265709
|
+
return color(`${cursor} ${item.name}`);
|
265710
|
+
},
|
265711
|
+
pageSize,
|
265712
|
+
loop
|
265851
265713
|
});
|
265852
|
-
|
265853
|
-
|
265854
|
-
// ../../node_modules/@inquirer/password/node_modules/@inquirer/core/dist/esm/lib/theme.js
|
265855
|
-
var import_yoctocolors_cjs4 = __toESM(require_yoctocolors_cjs(), 1);
|
265856
|
-
var defaultTheme2 = {
|
265857
|
-
prefix: {
|
265858
|
-
idle: import_yoctocolors_cjs4.default.blue("?"),
|
265859
|
-
done: import_yoctocolors_cjs4.default.green(esm_default.tick)
|
265860
|
-
},
|
265861
|
-
spinner: {
|
265862
|
-
interval: 80,
|
265863
|
-
frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => import_yoctocolors_cjs4.default.yellow(frame))
|
265864
|
-
},
|
265865
|
-
style: {
|
265866
|
-
answer: import_yoctocolors_cjs4.default.cyan,
|
265867
|
-
message: import_yoctocolors_cjs4.default.bold,
|
265868
|
-
error: (text2) => import_yoctocolors_cjs4.default.red(`> ${text2}`),
|
265869
|
-
defaultAnswer: (text2) => import_yoctocolors_cjs4.default.dim(`(${text2})`),
|
265870
|
-
help: import_yoctocolors_cjs4.default.dim,
|
265871
|
-
highlight: import_yoctocolors_cjs4.default.cyan,
|
265872
|
-
key: (text2) => import_yoctocolors_cjs4.default.cyan(import_yoctocolors_cjs4.default.bold(`<${text2}>`))
|
265714
|
+
if (status === "done") {
|
265715
|
+
return `${prefix} ${message} ${theme.style.answer(selectedChoice.short)}`;
|
265873
265716
|
}
|
265874
|
-
|
265717
|
+
const choiceDescription = selectedChoice.description ? `
|
265718
|
+
${theme.style.description(selectedChoice.description)}` : ``;
|
265719
|
+
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
265720
|
+
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes3.default.cursorHide}`;
|
265721
|
+
});
|
265875
265722
|
|
265876
|
-
//
|
265877
|
-
|
265878
|
-
|
265879
|
-
|
265880
|
-
|
265881
|
-
|
265882
|
-
|
265883
|
-
|
265884
|
-
|
265885
|
-
|
265886
|
-
|
265887
|
-
const
|
265888
|
-
|
265889
|
-
|
265890
|
-
|
265891
|
-
|
265723
|
+
// src/prompts/smart-contract-set/subgraph.prompt.ts
|
265724
|
+
var ALL = "All";
|
265725
|
+
var NEW = "New subgraph";
|
265726
|
+
async function subgraphPrompt({
|
265727
|
+
env: env2,
|
265728
|
+
accept,
|
265729
|
+
message,
|
265730
|
+
allowAll = false,
|
265731
|
+
allowNew = false,
|
265732
|
+
isCi = is_in_ci_default
|
265733
|
+
}) {
|
265734
|
+
const autoAccept = isCi || !!accept;
|
265735
|
+
const subgraphNames = env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS?.map((endpoint) => endpoint.split("/").pop()).filter(Boolean) ?? [];
|
265736
|
+
if (autoAccept) {
|
265737
|
+
if (allowAll) {
|
265738
|
+
return subgraphNames;
|
265892
265739
|
}
|
265740
|
+
if (env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH) {
|
265741
|
+
return [env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH];
|
265742
|
+
}
|
265743
|
+
return subgraphNames.length === 1 ? subgraphNames : [];
|
265893
265744
|
}
|
265894
|
-
|
265895
|
-
|
265896
|
-
|
265897
|
-
|
265898
|
-
|
265899
|
-
|
265900
|
-
];
|
265901
|
-
return deepMerge3(...themesToMerge);
|
265902
|
-
}
|
265903
|
-
|
265904
|
-
// ../../node_modules/@inquirer/password/node_modules/@inquirer/core/dist/esm/lib/use-prefix.js
|
265905
|
-
function usePrefix2({ status = "idle", theme }) {
|
265906
|
-
const [showLoader, setShowLoader] = useState2(false);
|
265907
|
-
const [tick, setTick] = useState2(0);
|
265908
|
-
const { prefix, spinner: spinner2 } = makeTheme2(theme);
|
265909
|
-
useEffect2(() => {
|
265910
|
-
if (status === "loading") {
|
265911
|
-
let tickInterval;
|
265912
|
-
let inc = -1;
|
265913
|
-
const delayTimeout = setTimeout(AsyncResource5.bind(() => {
|
265914
|
-
setShowLoader(true);
|
265915
|
-
tickInterval = setInterval(AsyncResource5.bind(() => {
|
265916
|
-
inc = inc + 1;
|
265917
|
-
setTick(inc % spinner2.frames.length);
|
265918
|
-
}), spinner2.interval);
|
265919
|
-
}), 300);
|
265920
|
-
return () => {
|
265921
|
-
clearTimeout(delayTimeout);
|
265922
|
-
clearInterval(tickInterval);
|
265923
|
-
};
|
265924
|
-
} else {
|
265925
|
-
setShowLoader(false);
|
265745
|
+
if (!allowNew) {
|
265746
|
+
if (subgraphNames.length === 0) {
|
265747
|
+
cancel2("No subgraphs found");
|
265748
|
+
}
|
265749
|
+
if (subgraphNames.length === 1) {
|
265750
|
+
return subgraphNames;
|
265926
265751
|
}
|
265927
|
-
}, [status]);
|
265928
|
-
if (showLoader) {
|
265929
|
-
return spinner2.frames[tick];
|
265930
265752
|
}
|
265931
|
-
const
|
265932
|
-
|
265933
|
-
|
265934
|
-
|
265935
|
-
|
265936
|
-
|
265937
|
-
}
|
265938
|
-
|
265939
|
-
|
265940
|
-
|
265941
|
-
|
265942
|
-
|
265943
|
-
|
265944
|
-
|
265945
|
-
|
265946
|
-
|
265947
|
-
|
265948
|
-
|
265753
|
+
const choices = subgraphNames.slice().sort();
|
265754
|
+
if (allowAll) {
|
265755
|
+
choices.unshift(ALL);
|
265756
|
+
}
|
265757
|
+
if (allowNew) {
|
265758
|
+
choices.unshift(NEW);
|
265759
|
+
}
|
265760
|
+
let defaultChoice;
|
265761
|
+
if (allowAll) {
|
265762
|
+
defaultChoice = ALL;
|
265763
|
+
} else if (allowNew) {
|
265764
|
+
defaultChoice = env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH ?? NEW;
|
265765
|
+
} else {
|
265766
|
+
defaultChoice = env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH ?? subgraphNames[0];
|
265767
|
+
}
|
265768
|
+
const subgraphName = choices.length === 1 && choices[0] === NEW ? NEW : await esm_default3({
|
265769
|
+
message,
|
265770
|
+
choices: choices.map((name3) => ({
|
265771
|
+
name: name3,
|
265772
|
+
value: name3
|
265773
|
+
})),
|
265774
|
+
default: defaultChoice
|
265775
|
+
});
|
265776
|
+
if (!subgraphName) {
|
265777
|
+
cancel2("No subgraph selected");
|
265778
|
+
}
|
265779
|
+
if (subgraphName === NEW) {
|
265780
|
+
const newSubgraphName = await subgraphNamePrompt({
|
265781
|
+
defaultName: "",
|
265782
|
+
env: env2,
|
265783
|
+
accept: autoAccept
|
265949
265784
|
});
|
265950
|
-
|
265951
|
-
|
265952
|
-
|
265953
|
-
|
265954
|
-
|
265955
|
-
|
265956
|
-
}
|
265957
|
-
// ../../node_modules/@inquirer/password/node_modules/@inquirer/core/dist/esm/lib/utils.js
|
265958
|
-
var import_cli_width2 = __toESM(require_cli_width(), 1);
|
265959
|
-
var import_wrap_ansi2 = __toESM(require_wrap_ansi(), 1);
|
265960
|
-
function breakLines2(content, width) {
|
265961
|
-
return content.split(`
|
265962
|
-
`).flatMap((line) => import_wrap_ansi2.default(line, width, { trim: false, hard: true }).split(`
|
265963
|
-
`).map((str) => str.trimEnd())).join(`
|
265964
|
-
`);
|
265965
|
-
}
|
265966
|
-
function readlineWidth2() {
|
265967
|
-
return import_cli_width2.default({ defaultWidth: 80, output: readline3().output });
|
265785
|
+
if (!newSubgraphName) {
|
265786
|
+
return [];
|
265787
|
+
}
|
265788
|
+
return [newSubgraphName];
|
265789
|
+
}
|
265790
|
+
return subgraphName === ALL ? subgraphNames : [subgraphName];
|
265968
265791
|
}
|
265969
265792
|
|
265970
|
-
//
|
265971
|
-
|
265972
|
-
|
265973
|
-
|
265793
|
+
// src/utils/commands/create-examples.ts
|
265794
|
+
function createExamples(examples) {
|
265795
|
+
return `
|
265796
|
+
Examples:
|
265974
265797
|
|
265975
|
-
|
265976
|
-
|
265977
|
-
|
265978
|
-
|
265979
|
-
|
265980
|
-
|
265981
|
-
`).pop() ?? "";
|
265982
|
-
function cursorDown2(n6) {
|
265983
|
-
return n6 > 0 ? import_ansi_escapes3.default.cursorDown(n6) : "";
|
265798
|
+
${examples.map(({ description, command, commandPrefix }) => {
|
265799
|
+
return ` # ${description}
|
265800
|
+
$ ${commandPrefix ?? ""}settlemint ${command}`;
|
265801
|
+
}).join(`
|
265802
|
+
|
265803
|
+
`)}`;
|
265984
265804
|
}
|
265985
265805
|
|
265986
|
-
|
265987
|
-
|
265988
|
-
|
265989
|
-
|
265990
|
-
|
265991
|
-
|
265992
|
-
|
265993
|
-
|
265806
|
+
// src/commands/codegen/codegen-blockscout.ts
|
265807
|
+
import { rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
265808
|
+
import { basename, resolve as resolve5 } from "node:path";
|
265809
|
+
var PACKAGE_NAME4 = "@settlemint/sdk-blockscout";
|
265810
|
+
async function codegenBlockscout(env2) {
|
265811
|
+
const endpoint = env2.SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT;
|
265812
|
+
if (!endpoint) {
|
265813
|
+
return;
|
265994
265814
|
}
|
265995
|
-
|
265996
|
-
|
265997
|
-
|
265998
|
-
|
265815
|
+
const accessToken = await getApplicationOrPersonalAccessToken({
|
265816
|
+
env: env2,
|
265817
|
+
instance: env2.SETTLEMINT_INSTANCE,
|
265818
|
+
prefer: "application"
|
265819
|
+
});
|
265820
|
+
if (!accessToken) {
|
265821
|
+
return;
|
265999
265822
|
}
|
266000
|
-
|
266001
|
-
|
266002
|
-
const
|
266003
|
-
|
266004
|
-
|
266005
|
-
|
266006
|
-
|
266007
|
-
|
266008
|
-
|
266009
|
-
|
266010
|
-
|
266011
|
-
|
266012
|
-
|
266013
|
-
|
266014
|
-
|
266015
|
-
|
266016
|
-
|
266017
|
-
|
266018
|
-
|
266019
|
-
|
266020
|
-
|
266021
|
-
|
266022
|
-
|
266023
|
-
|
266024
|
-
|
266025
|
-
|
265823
|
+
const introspectionJsonPath = resolve5(process.cwd(), "__blockscout-introspection__.json");
|
265824
|
+
try {
|
265825
|
+
const data = await graphqlFetchWithRetry(endpoint, {
|
265826
|
+
method: "POST",
|
265827
|
+
headers: {
|
265828
|
+
"x-auth-token": accessToken,
|
265829
|
+
"Content-Type": "application/json"
|
265830
|
+
},
|
265831
|
+
body: JSON.stringify({
|
265832
|
+
query: `
|
265833
|
+
query IntrospectionQuery {
|
265834
|
+
__schema {
|
265835
|
+
queryType { name }
|
265836
|
+
mutationType { name }
|
265837
|
+
types {
|
265838
|
+
...FullType
|
265839
|
+
}
|
265840
|
+
directives {
|
265841
|
+
name
|
265842
|
+
description
|
265843
|
+
locations
|
265844
|
+
args {
|
265845
|
+
...InputValue
|
265846
|
+
}
|
265847
|
+
}
|
265848
|
+
}
|
265849
|
+
}
|
265850
|
+
|
265851
|
+
fragment FullType on __Type {
|
265852
|
+
kind
|
265853
|
+
name
|
265854
|
+
description
|
265855
|
+
fields(includeDeprecated: true) {
|
265856
|
+
name
|
265857
|
+
description
|
265858
|
+
args {
|
265859
|
+
...InputValue
|
265860
|
+
}
|
265861
|
+
type {
|
265862
|
+
...TypeRef
|
265863
|
+
}
|
265864
|
+
isDeprecated
|
265865
|
+
deprecationReason
|
265866
|
+
}
|
265867
|
+
inputFields {
|
265868
|
+
...InputValue
|
265869
|
+
}
|
265870
|
+
interfaces {
|
265871
|
+
...TypeRef
|
265872
|
+
}
|
265873
|
+
enumValues(includeDeprecated: true) {
|
265874
|
+
name
|
265875
|
+
description
|
265876
|
+
isDeprecated
|
265877
|
+
deprecationReason
|
265878
|
+
}
|
265879
|
+
possibleTypes {
|
265880
|
+
...TypeRef
|
265881
|
+
}
|
265882
|
+
}
|
265883
|
+
|
265884
|
+
fragment InputValue on __InputValue {
|
265885
|
+
name
|
265886
|
+
description
|
265887
|
+
type { ...TypeRef }
|
265888
|
+
defaultValue
|
265889
|
+
}
|
265890
|
+
|
265891
|
+
fragment TypeRef on __Type {
|
265892
|
+
kind
|
265893
|
+
name
|
265894
|
+
ofType {
|
265895
|
+
kind
|
265896
|
+
name
|
265897
|
+
ofType {
|
265898
|
+
kind
|
265899
|
+
name
|
265900
|
+
ofType {
|
265901
|
+
kind
|
265902
|
+
name
|
265903
|
+
ofType {
|
265904
|
+
kind
|
265905
|
+
name
|
265906
|
+
ofType {
|
265907
|
+
kind
|
265908
|
+
name
|
265909
|
+
ofType {
|
265910
|
+
kind
|
265911
|
+
name
|
265912
|
+
ofType {
|
265913
|
+
kind
|
265914
|
+
name
|
265915
|
+
ofType {
|
265916
|
+
kind
|
265917
|
+
name
|
265918
|
+
ofType {
|
265919
|
+
kind
|
265920
|
+
name
|
265921
|
+
}
|
265922
|
+
}
|
265923
|
+
}
|
265924
|
+
}
|
265925
|
+
}
|
265926
|
+
}
|
265927
|
+
}
|
265928
|
+
}
|
265929
|
+
}
|
265930
|
+
}
|
265931
|
+
`
|
265932
|
+
})
|
265933
|
+
});
|
265934
|
+
await writeFile6(introspectionJsonPath, JSON.stringify(data));
|
265935
|
+
} catch (err) {
|
265936
|
+
const error5 = err;
|
265937
|
+
note(`GraphQL endpoint '${endpoint}' is not reachable: ${error5.message}`, "warn");
|
265938
|
+
return;
|
265939
|
+
}
|
265940
|
+
try {
|
265941
|
+
await generateSchema({
|
265942
|
+
input: basename(introspectionJsonPath),
|
265943
|
+
output: "blockscout-schema.graphql",
|
265944
|
+
tsconfig: undefined,
|
265945
|
+
headers: undefined
|
265946
|
+
});
|
265947
|
+
} finally {
|
265948
|
+
await rm2(introspectionJsonPath);
|
265949
|
+
}
|
265950
|
+
const template = `import { createBlockscoutClient } from "${PACKAGE_NAME4}";
|
265951
|
+
import type { introspection } from "@schemas/blockscout-env";
|
265952
|
+
|
265953
|
+
export const { client: blockscoutClient, graphql: blockscoutGraphql } = createBlockscoutClient<{
|
265954
|
+
introspection: introspection;
|
265955
|
+
disableMasking: true;
|
265956
|
+
scalars: {
|
265957
|
+
/** 40 hex characters (160 bits/20 bytes) derived from the public key, prefixed with 0x */
|
265958
|
+
AddressHash: string;
|
265959
|
+
/** Unpadded big-endian hexadecimal number where each byte pair maps to underlying binary */
|
265960
|
+
Data: string;
|
265961
|
+
/** ISO8601 formatted UTC datetime string */
|
265962
|
+
DateTime: string;
|
265963
|
+
/** String representation of a signed double-precision decimal value */
|
265964
|
+
Decimal: string;
|
265965
|
+
/** 32-byte KECCAK-256 hash */
|
265966
|
+
FullHash: string;
|
265967
|
+
/** Arbitrary JSON string data as UTF-8 */
|
265968
|
+
Json: string;
|
265969
|
+
/** 16 hex character (128 bits/8 bytes) nonce from Proof-of-Work */
|
265970
|
+
NonceHash: string;
|
265971
|
+
/** Smallest fractional unit of Ether, represented as a string for integer math */
|
265972
|
+
Wei: string;
|
265973
|
+
};
|
265974
|
+
}>({
|
265975
|
+
instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT!,
|
265976
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!, // undefined in browser, by design to not leak the secrets
|
265977
|
+
});
|
265978
|
+
|
265979
|
+
export const blockscoutUiEndpoint = process.env.SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT!;`;
|
265980
|
+
await writeTemplate(template, "/lib/settlemint", "blockscout.ts");
|
265981
|
+
const projectDir = await projectRoot3();
|
265982
|
+
if (!await isPackageInstalled(PACKAGE_NAME4, projectDir)) {
|
265983
|
+
await installDependencies(PACKAGE_NAME4, projectDir);
|
266026
265984
|
}
|
266027
|
-
|
266028
|
-
|
266029
|
-
|
266030
|
-
|
266031
|
-
|
266032
|
-
|
265985
|
+
}
|
265986
|
+
|
265987
|
+
// src/commands/codegen/codegen-ipfs.ts
|
265988
|
+
var PACKAGE_NAME5 = "@settlemint/sdk-ipfs";
|
265989
|
+
function shouldCodegenIpfs(env2) {
|
265990
|
+
return !!env2.SETTLEMINT_IPFS_API_ENDPOINT;
|
265991
|
+
}
|
265992
|
+
async function codegenIpfs(env2) {
|
265993
|
+
const endpoint = env2.SETTLEMINT_IPFS_API_ENDPOINT;
|
265994
|
+
if (!endpoint) {
|
265995
|
+
return;
|
266033
265996
|
}
|
266034
|
-
|
266035
|
-
|
266036
|
-
|
266037
|
-
|
266038
|
-
|
266039
|
-
|
266040
|
-
|
266041
|
-
|
265997
|
+
const clientTemplate = `import { createServerIpfsClient } from "${PACKAGE_NAME5}";
|
265998
|
+
|
265999
|
+
export const { client } = createServerIpfsClient({
|
266000
|
+
instance: process.env.SETTLEMINT_IPFS_API_ENDPOINT!,
|
266001
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
|
266002
|
+
});`;
|
266003
|
+
await writeTemplate(clientTemplate, "/lib/settlemint", "ipfs.ts");
|
266004
|
+
const projectDir = await projectRoot3();
|
266005
|
+
if (!await isPackageInstalled(PACKAGE_NAME5, projectDir)) {
|
266006
|
+
await installDependencies(PACKAGE_NAME5, projectDir);
|
266042
266007
|
}
|
266043
266008
|
}
|
266044
266009
|
|
266045
|
-
//
|
266046
|
-
|
266047
|
-
|
266048
|
-
|
266049
|
-
let reject;
|
266050
|
-
const promise = new Promise((res, rej) => {
|
266051
|
-
resolve6 = res;
|
266052
|
-
reject = rej;
|
266053
|
-
});
|
266054
|
-
return { promise, resolve: resolve6, reject };
|
266055
|
-
}
|
266010
|
+
// src/commands/codegen/codegen-minio.ts
|
266011
|
+
var PACKAGE_NAME6 = "@settlemint/sdk-minio";
|
266012
|
+
function shouldCodegenMinio(env2) {
|
266013
|
+
return !!(env2.SETTLEMINT_MINIO_ENDPOINT && env2.SETTLEMINT_MINIO_ACCESS_KEY && env2.SETTLEMINT_MINIO_SECRET_KEY);
|
266056
266014
|
}
|
266015
|
+
async function codegenMinio(env2) {
|
266016
|
+
const endpoint = env2.SETTLEMINT_MINIO_ENDPOINT;
|
266017
|
+
if (!endpoint) {
|
266018
|
+
return;
|
266019
|
+
}
|
266020
|
+
const clientTemplate = `import { createServerMinioClient } from "${PACKAGE_NAME6}";
|
266057
266021
|
|
266058
|
-
|
266059
|
-
|
266060
|
-
|
266061
|
-
|
266062
|
-
|
266063
|
-
|
266064
|
-
|
266065
|
-
|
266066
|
-
|
266067
|
-
|
266068
|
-
new Error().stack;
|
266069
|
-
} catch {
|
266070
|
-
return result;
|
266022
|
+
export const { client } = createServerMinioClient({
|
266023
|
+
instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
|
266024
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
|
266025
|
+
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
|
266026
|
+
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
|
266027
|
+
});`;
|
266028
|
+
await writeTemplate(clientTemplate, "/lib/settlemint", "minio.ts");
|
266029
|
+
const projectDir = await projectRoot3();
|
266030
|
+
if (!await isPackageInstalled(PACKAGE_NAME6, projectDir)) {
|
266031
|
+
await installDependencies(PACKAGE_NAME6, projectDir);
|
266071
266032
|
}
|
266072
|
-
Error.prepareStackTrace = _prepareStackTrace;
|
266073
|
-
return result;
|
266074
266033
|
}
|
266075
|
-
|
266076
|
-
|
266077
|
-
|
266078
|
-
|
266079
|
-
|
266080
|
-
|
266081
|
-
|
266082
|
-
|
266083
|
-
|
266084
|
-
|
266085
|
-
|
266086
|
-
});
|
266087
|
-
const screen = new ScreenManager2(rl);
|
266088
|
-
const { promise, resolve: resolve6, reject } = PromisePolyfill2.withResolver();
|
266089
|
-
const cancel3 = () => reject(new CancelPromptError2);
|
266090
|
-
if (signal) {
|
266091
|
-
const abort = () => reject(new AbortPromptError2({ cause: signal.reason }));
|
266092
|
-
if (signal.aborted) {
|
266093
|
-
abort();
|
266094
|
-
return Object.assign(promise, { cancel: cancel3 });
|
266095
|
-
}
|
266096
|
-
signal.addEventListener("abort", abort);
|
266097
|
-
cleanups.add(() => signal.removeEventListener("abort", abort));
|
266034
|
+
|
266035
|
+
// src/commands/codegen.ts
|
266036
|
+
function codegenCommand() {
|
266037
|
+
return new Command("codegen").option("--prod", "Connect to your production environment").option("--thegraph-subgraph-names <subgraph-names...>", "The name(s) of the TheGraph subgraph(s) to generate (skip if you want to generate all)").description("Generate GraphQL and REST types and queries").usage(createExamples([
|
266038
|
+
{
|
266039
|
+
description: "Generate GraphQL types and queries for your dApp",
|
266040
|
+
command: "codegen"
|
266041
|
+
},
|
266042
|
+
{
|
266043
|
+
description: "Generate GraphQL types and queries for specific TheGraph subgraphs",
|
266044
|
+
command: "codegen --thegraph-subgraph-names subgraph1 subgraph2"
|
266098
266045
|
}
|
266099
|
-
|
266100
|
-
|
266101
|
-
|
266102
|
-
|
266103
|
-
|
266104
|
-
|
266105
|
-
|
266106
|
-
|
266107
|
-
|
266108
|
-
cleanups.add(() => rl.removeListener("close", hooksCleanup));
|
266109
|
-
cycle(() => {
|
266110
|
-
try {
|
266111
|
-
const nextView = view(config3, (value4) => {
|
266112
|
-
setImmediate(() => resolve6(value4));
|
266113
|
-
});
|
266114
|
-
if (nextView === undefined) {
|
266115
|
-
const callerFilename = callSites[1]?.getFileName?.();
|
266116
|
-
throw new Error(`Prompt functions must return a string.
|
266117
|
-
at ${callerFilename}`);
|
266118
|
-
}
|
266119
|
-
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
266120
|
-
screen.render(content, bottomContent);
|
266121
|
-
effectScheduler2.run();
|
266122
|
-
} catch (error5) {
|
266123
|
-
reject(error5);
|
266124
|
-
}
|
266046
|
+
])).action(async ({ prod, thegraphSubgraphNames }) => {
|
266047
|
+
intro("Generating GraphQL types and queries for your dApp");
|
266048
|
+
const env2 = await loadEnv(true, !!prod);
|
266049
|
+
if (!Array.isArray(thegraphSubgraphNames)) {
|
266050
|
+
thegraphSubgraphNames = await subgraphPrompt({
|
266051
|
+
env: env2,
|
266052
|
+
accept: true,
|
266053
|
+
message: "Which The Graph subgraph do you want to generate types for?",
|
266054
|
+
allowAll: true
|
266125
266055
|
});
|
266126
|
-
|
266127
|
-
|
266128
|
-
|
266129
|
-
|
266130
|
-
|
266131
|
-
|
266132
|
-
|
266133
|
-
cleanups.forEach((cleanup) => cleanup());
|
266134
|
-
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
266135
|
-
output.end();
|
266136
|
-
}).then(() => promise), { cancel: cancel3 });
|
266056
|
+
}
|
266057
|
+
const { hasura, portal, thegraph, blockscout } = await spinner({
|
266058
|
+
startMessage: "Testing configured GraphQL schema",
|
266059
|
+
task: async () => {
|
266060
|
+
return codegenTsconfig(env2, thegraphSubgraphNames);
|
266061
|
+
},
|
266062
|
+
stopMessage: "Tested GraphQL schemas"
|
266137
266063
|
});
|
266138
|
-
|
266139
|
-
|
266064
|
+
if (hasura) {
|
266065
|
+
note("Generating Hasura resources");
|
266066
|
+
await codegenHasura(env2);
|
266067
|
+
}
|
266068
|
+
if (portal) {
|
266069
|
+
note("Generating Portal resources");
|
266070
|
+
await codegenPortal(env2);
|
266071
|
+
}
|
266072
|
+
if (thegraph) {
|
266073
|
+
note("Generating TheGraph resources");
|
266074
|
+
await codegenTheGraph(env2, thegraphSubgraphNames);
|
266075
|
+
}
|
266076
|
+
if (blockscout) {
|
266077
|
+
note("Generating Blockscout resources");
|
266078
|
+
await codegenBlockscout(env2);
|
266079
|
+
}
|
266080
|
+
if (shouldCodegenMinio(env2)) {
|
266081
|
+
note("Generating Minio resources");
|
266082
|
+
await codegenMinio(env2);
|
266083
|
+
}
|
266084
|
+
if (shouldCodegenIpfs(env2)) {
|
266085
|
+
note("Generating IPFS resources");
|
266086
|
+
await codegenIpfs(env2);
|
266087
|
+
}
|
266088
|
+
if (hasura || portal || thegraph || blockscout) {
|
266089
|
+
await generateOutput({
|
266090
|
+
output: undefined,
|
266091
|
+
tsconfig: undefined
|
266092
|
+
});
|
266093
|
+
}
|
266094
|
+
outro("Codegen complete");
|
266095
|
+
});
|
266096
|
+
}
|
266097
|
+
|
266098
|
+
// ../../node_modules/@inquirer/confirm/dist/esm/index.js
|
266099
|
+
function getBooleanValue(value4, defaultValue) {
|
266100
|
+
let answer = defaultValue !== false;
|
266101
|
+
if (/^(y|yes)/i.test(value4))
|
266102
|
+
answer = true;
|
266103
|
+
else if (/^(n|no)/i.test(value4))
|
266104
|
+
answer = false;
|
266105
|
+
return answer;
|
266106
|
+
}
|
266107
|
+
function boolToString(value4) {
|
266108
|
+
return value4 ? "Yes" : "No";
|
266140
266109
|
}
|
266110
|
+
var esm_default4 = createPrompt((config3, done) => {
|
266111
|
+
const { transformer = boolToString } = config3;
|
266112
|
+
const [status, setStatus] = useState("idle");
|
266113
|
+
const [value4, setValue] = useState("");
|
266114
|
+
const theme = makeTheme(config3.theme);
|
266115
|
+
const prefix = usePrefix({ status, theme });
|
266116
|
+
useKeypress((key3, rl) => {
|
266117
|
+
if (isEnterKey(key3)) {
|
266118
|
+
const answer = getBooleanValue(value4, config3.default);
|
266119
|
+
setValue(transformer(answer));
|
266120
|
+
setStatus("done");
|
266121
|
+
done(answer);
|
266122
|
+
} else if (key3.name === "tab") {
|
266123
|
+
const answer = boolToString(!getBooleanValue(value4, config3.default));
|
266124
|
+
rl.clearLine(0);
|
266125
|
+
rl.write(answer);
|
266126
|
+
setValue(answer);
|
266127
|
+
} else {
|
266128
|
+
setValue(rl.line);
|
266129
|
+
}
|
266130
|
+
});
|
266131
|
+
let formattedValue = value4;
|
266132
|
+
let defaultValue = "";
|
266133
|
+
if (status === "done") {
|
266134
|
+
formattedValue = theme.style.answer(value4);
|
266135
|
+
} else {
|
266136
|
+
defaultValue = ` ${theme.style.defaultAnswer(config3.default === false ? "y/N" : "Y/n")}`;
|
266137
|
+
}
|
266138
|
+
const message = theme.style.message(config3.message, status);
|
266139
|
+
return `${prefix} ${message}${defaultValue} ${formattedValue}`;
|
266140
|
+
});
|
266141
|
+
|
266141
266142
|
// ../../node_modules/@inquirer/password/dist/esm/index.js
|
266142
266143
|
var import_ansi_escapes4 = __toESM(require_ansi_escapes(), 1);
|
266143
|
-
var esm_default5 =
|
266144
|
+
var esm_default5 = createPrompt((config3, done) => {
|
266144
266145
|
const { validate: validate3 = () => true } = config3;
|
266145
|
-
const theme =
|
266146
|
-
const [status, setStatus] =
|
266147
|
-
const [errorMsg, setError] =
|
266148
|
-
const [value4, setValue] =
|
266149
|
-
const prefix =
|
266150
|
-
|
266146
|
+
const theme = makeTheme(config3.theme);
|
266147
|
+
const [status, setStatus] = useState("idle");
|
266148
|
+
const [errorMsg, setError] = useState();
|
266149
|
+
const [value4, setValue] = useState("");
|
266150
|
+
const prefix = usePrefix({ status, theme });
|
266151
|
+
useKeypress(async (key3, rl) => {
|
266151
266152
|
if (status !== "idle") {
|
266152
266153
|
return;
|
266153
266154
|
}
|
266154
|
-
if (
|
266155
|
+
if (isEnterKey(key3)) {
|
266155
266156
|
const answer = value4;
|
266156
266157
|
setStatus("loading");
|
266157
266158
|
const isValid2 = await validate3(answer);
|
@@ -273875,4 +273876,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
273875
273876
|
// src/cli.ts
|
273876
273877
|
sdkCliCommand();
|
273877
273878
|
|
273878
|
-
//# debugId=
|
273879
|
+
//# debugId=C1EDC86A987761F564756E2164756E21
|