@secondlayer/cli 3.3.1 → 3.3.2
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.d.ts +0 -0
- package/dist/cli.js +527 -507
- package/dist/cli.js.map +9 -9
- package/dist/{plugin-manager.js → core/plugin-manager.js} +58 -24
- package/dist/{plugin-manager.js.map → core/plugin-manager.js.map} +6 -6
- package/dist/index.d.ts +18 -18
- package/dist/index.js +163 -32
- package/dist/index.js.map +7 -6
- package/dist/plugins/index.d.ts +364 -0
- package/dist/plugins/index.js +2781 -0
- package/dist/plugins/index.js.map +31 -0
- package/package.json +4 -4
- /package/dist/{plugin-manager.d.ts → core/plugin-manager.d.ts} +0 -0
package/dist/cli.js
CHANGED
|
@@ -47,6 +47,348 @@ var __export = (target, all) => {
|
|
|
47
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
48
48
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
49
49
|
|
|
50
|
+
// src/types/plugin.ts
|
|
51
|
+
function isClarinetContract(c) {
|
|
52
|
+
return "_clarinetSource" in c && c._clarinetSource === true;
|
|
53
|
+
}
|
|
54
|
+
function isDirectFileContract(c) {
|
|
55
|
+
return "_directFile" in c && c._directFile === true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/utils/contract-id.ts
|
|
59
|
+
function parseContractId(contractId) {
|
|
60
|
+
const dotIndex = contractId.indexOf(".");
|
|
61
|
+
if (dotIndex === -1) {
|
|
62
|
+
throw new Error(`Invalid contract ID: "${contractId}" (expected "address.contractName")`);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
address: contractId.slice(0, dotIndex),
|
|
66
|
+
contractName: contractId.slice(dotIndex + 1)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/utils/format.ts
|
|
71
|
+
var exports_format = {};
|
|
72
|
+
__export(exports_format, {
|
|
73
|
+
formatCode: () => formatCode
|
|
74
|
+
});
|
|
75
|
+
import { Biome, Distribution } from "@biomejs/js-api";
|
|
76
|
+
async function getBiome() {
|
|
77
|
+
if (!biome) {
|
|
78
|
+
biome = await Biome.create({
|
|
79
|
+
distribution: Distribution.NODE
|
|
80
|
+
});
|
|
81
|
+
biome.applyConfiguration({
|
|
82
|
+
formatter: {
|
|
83
|
+
enabled: true,
|
|
84
|
+
indentStyle: "tab",
|
|
85
|
+
lineWidth: 80
|
|
86
|
+
},
|
|
87
|
+
javascript: {
|
|
88
|
+
formatter: {
|
|
89
|
+
semicolons: "always",
|
|
90
|
+
quoteStyle: "single"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
organizeImports: {
|
|
94
|
+
enabled: true
|
|
95
|
+
},
|
|
96
|
+
linter: {
|
|
97
|
+
enabled: true
|
|
98
|
+
},
|
|
99
|
+
assists: {
|
|
100
|
+
enabled: true
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
biome.registerProjectFolder();
|
|
104
|
+
}
|
|
105
|
+
return biome;
|
|
106
|
+
}
|
|
107
|
+
async function formatCode(code) {
|
|
108
|
+
const b = await getBiome();
|
|
109
|
+
const linted = b.lintContent(code, {
|
|
110
|
+
filePath: "generated.ts",
|
|
111
|
+
fixFileMode: "SafeFixes"
|
|
112
|
+
});
|
|
113
|
+
const formatted = b.formatContent(linted.content, {
|
|
114
|
+
filePath: "generated.ts"
|
|
115
|
+
});
|
|
116
|
+
return formatted.content;
|
|
117
|
+
}
|
|
118
|
+
var biome = null;
|
|
119
|
+
var init_format = () => {};
|
|
120
|
+
|
|
121
|
+
// src/core/plugin-manager.ts
|
|
122
|
+
import { promises as fs } from "fs";
|
|
123
|
+
import path from "path";
|
|
124
|
+
import { isValidAddress as _validateStacksAddress } from "@secondlayer/stacks";
|
|
125
|
+
import { getErrorMessage } from "@secondlayer/shared";
|
|
126
|
+
import { toCamelCase } from "@secondlayer/stacks/clarity";
|
|
127
|
+
|
|
128
|
+
class PluginManager {
|
|
129
|
+
plugins = [];
|
|
130
|
+
logger;
|
|
131
|
+
utils;
|
|
132
|
+
executionContext;
|
|
133
|
+
constructor() {
|
|
134
|
+
this.logger = this.createLogger();
|
|
135
|
+
this.utils = this.createUtils();
|
|
136
|
+
this.executionContext = {
|
|
137
|
+
phase: "config",
|
|
138
|
+
startTime: Date.now(),
|
|
139
|
+
results: new Map
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
register(plugin) {
|
|
143
|
+
if (!plugin.name || !plugin.version) {
|
|
144
|
+
throw new Error("Plugin must have a name and version");
|
|
145
|
+
}
|
|
146
|
+
const existing = this.plugins.find((p) => p.name === plugin.name);
|
|
147
|
+
if (existing) {
|
|
148
|
+
throw new Error(`Plugin "${plugin.name}" is already registered (version ${existing.version})`);
|
|
149
|
+
}
|
|
150
|
+
this.plugins.push(plugin);
|
|
151
|
+
this.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);
|
|
152
|
+
}
|
|
153
|
+
getPlugins() {
|
|
154
|
+
return [...this.plugins];
|
|
155
|
+
}
|
|
156
|
+
async transformConfig(config) {
|
|
157
|
+
this.executionContext.phase = "config";
|
|
158
|
+
let transformedConfig = { ...config };
|
|
159
|
+
for (const plugin of this.plugins) {
|
|
160
|
+
if (plugin.transformConfig) {
|
|
161
|
+
this.executionContext.currentPlugin = plugin;
|
|
162
|
+
try {
|
|
163
|
+
const result = await plugin.transformConfig(transformedConfig);
|
|
164
|
+
transformedConfig = result;
|
|
165
|
+
this.recordHookResult(plugin.name, "transformConfig", {
|
|
166
|
+
success: true
|
|
167
|
+
});
|
|
168
|
+
} catch (error) {
|
|
169
|
+
this.recordHookResult(plugin.name, "transformConfig", {
|
|
170
|
+
success: false,
|
|
171
|
+
error: error instanceof Error ? error : new Error(getErrorMessage(error))
|
|
172
|
+
});
|
|
173
|
+
throw new Error(`Plugin "${plugin.name}" failed during config transformation: ${getErrorMessage(error)}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const resolvedConfig = {
|
|
178
|
+
...transformedConfig,
|
|
179
|
+
plugins: this.plugins
|
|
180
|
+
};
|
|
181
|
+
return resolvedConfig;
|
|
182
|
+
}
|
|
183
|
+
async transformContracts(contracts, _config) {
|
|
184
|
+
const processedContracts = [];
|
|
185
|
+
for (let contract of contracts) {
|
|
186
|
+
if (isClarinetContract(contract) && contract.abi) {
|
|
187
|
+
processedContracts.push(this.contractToProcessed(contract, "clarinet"));
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (isDirectFileContract(contract) && contract.abi) {
|
|
191
|
+
processedContracts.push(this.contractToProcessed(contract, "direct"));
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const plugin of this.plugins) {
|
|
195
|
+
if (plugin.transformContract) {
|
|
196
|
+
this.executionContext.currentPlugin = plugin;
|
|
197
|
+
try {
|
|
198
|
+
contract = await plugin.transformContract(contract);
|
|
199
|
+
this.recordHookResult(plugin.name, "transformContract", {
|
|
200
|
+
success: true
|
|
201
|
+
});
|
|
202
|
+
} catch (error) {
|
|
203
|
+
this.recordHookResult(plugin.name, "transformContract", {
|
|
204
|
+
success: false,
|
|
205
|
+
error: error instanceof Error ? error : new Error(getErrorMessage(error))
|
|
206
|
+
});
|
|
207
|
+
this.logger.warn(`Plugin "${plugin.name}" failed to transform contract: ${getErrorMessage(error)}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (contract.abi) {
|
|
212
|
+
processedContracts.push(this.contractToProcessed(contract, "api"));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return processedContracts;
|
|
216
|
+
}
|
|
217
|
+
async executeHook(hookName, context) {
|
|
218
|
+
for (const plugin of this.plugins) {
|
|
219
|
+
const hook = plugin[hookName];
|
|
220
|
+
if (typeof hook === "function") {
|
|
221
|
+
this.executionContext.currentPlugin = plugin;
|
|
222
|
+
try {
|
|
223
|
+
await hook.call(plugin, context);
|
|
224
|
+
this.recordHookResult(plugin.name, hookName, {
|
|
225
|
+
success: true
|
|
226
|
+
});
|
|
227
|
+
} catch (error) {
|
|
228
|
+
this.recordHookResult(plugin.name, hookName, {
|
|
229
|
+
success: false,
|
|
230
|
+
error: error instanceof Error ? error : new Error(getErrorMessage(error))
|
|
231
|
+
});
|
|
232
|
+
this.logger.error(`Plugin "${plugin.name}" failed during ${hookName}: ${getErrorMessage(error)}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async executeGeneration(contracts, config) {
|
|
238
|
+
this.executionContext.phase = "generate";
|
|
239
|
+
const outputs = new Map;
|
|
240
|
+
const context = {
|
|
241
|
+
config,
|
|
242
|
+
logger: this.logger,
|
|
243
|
+
utils: this.utils,
|
|
244
|
+
contracts,
|
|
245
|
+
outputs,
|
|
246
|
+
augment: (outputKey, contractName, content) => {
|
|
247
|
+
this.augmentOutput(outputs, outputKey, contractName, content);
|
|
248
|
+
},
|
|
249
|
+
addOutput: (key, output) => {
|
|
250
|
+
outputs.set(key, output);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
await this.executeHook("beforeGenerate", context);
|
|
254
|
+
await this.executeHook("generate", context);
|
|
255
|
+
await this.executeHook("afterGenerate", context);
|
|
256
|
+
return outputs;
|
|
257
|
+
}
|
|
258
|
+
async transformOutputs(outputs) {
|
|
259
|
+
this.executionContext.phase = "output";
|
|
260
|
+
const transformedOutputs = new Map;
|
|
261
|
+
for (const [key, output] of outputs) {
|
|
262
|
+
let transformedContent = output.content;
|
|
263
|
+
for (const plugin of this.plugins) {
|
|
264
|
+
if (plugin.transformOutput) {
|
|
265
|
+
this.executionContext.currentPlugin = plugin;
|
|
266
|
+
try {
|
|
267
|
+
transformedContent = await plugin.transformOutput(transformedContent, output.type || "other");
|
|
268
|
+
this.recordHookResult(plugin.name, "transformOutput", {
|
|
269
|
+
success: true
|
|
270
|
+
});
|
|
271
|
+
} catch (error) {
|
|
272
|
+
this.recordHookResult(plugin.name, "transformOutput", {
|
|
273
|
+
success: false,
|
|
274
|
+
error: error instanceof Error ? error : new Error(getErrorMessage(error))
|
|
275
|
+
});
|
|
276
|
+
this.logger.warn(`Plugin "${plugin.name}" failed to transform output: ${getErrorMessage(error)}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
transformedOutputs.set(key, {
|
|
281
|
+
...output,
|
|
282
|
+
content: transformedContent
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return transformedOutputs;
|
|
286
|
+
}
|
|
287
|
+
async writeOutputs(outputs) {
|
|
288
|
+
for (const [, output] of outputs) {
|
|
289
|
+
try {
|
|
290
|
+
const resolvedPath = path.resolve(process.cwd(), output.path);
|
|
291
|
+
await this.utils.ensureDir(path.dirname(resolvedPath));
|
|
292
|
+
await this.utils.writeFile(resolvedPath, output.content);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
this.logger.error(`Failed to write ${output.path}: ${getErrorMessage(error)}`);
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
getExecutionResults() {
|
|
300
|
+
return new Map(this.executionContext.results);
|
|
301
|
+
}
|
|
302
|
+
contractToProcessed(contract, source) {
|
|
303
|
+
const address = typeof contract.address === "string" ? contract.address : "";
|
|
304
|
+
const parsed = parseContractId(address);
|
|
305
|
+
return {
|
|
306
|
+
name: contract.name || parsed.contractName || "unknown",
|
|
307
|
+
address: parsed.address || "unknown",
|
|
308
|
+
contractName: parsed.contractName || contract.name || "unknown",
|
|
309
|
+
abi: contract.abi,
|
|
310
|
+
source: source === "api" ? "api" : "local",
|
|
311
|
+
metadata: contract.metadata ?? { source }
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
augmentOutput(outputs, outputKey, contractName, content) {
|
|
315
|
+
const existing = outputs.get(outputKey);
|
|
316
|
+
if (!existing) {
|
|
317
|
+
this.logger.warn(`Cannot augment non-existent output: ${outputKey}`);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const augmentedContent = `${existing.content}
|
|
321
|
+
|
|
322
|
+
// Augmented by plugin for ${contractName}
|
|
323
|
+
${JSON.stringify(content, null, 2)}`;
|
|
324
|
+
outputs.set(outputKey, {
|
|
325
|
+
...existing,
|
|
326
|
+
content: augmentedContent
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
recordHookResult(pluginName, hookName, result) {
|
|
330
|
+
const key = `${pluginName}:${hookName}`;
|
|
331
|
+
const existing = this.executionContext.results.get(key) || [];
|
|
332
|
+
existing.push({ ...result, plugin: pluginName });
|
|
333
|
+
this.executionContext.results.set(key, existing);
|
|
334
|
+
}
|
|
335
|
+
createLogger() {
|
|
336
|
+
return {
|
|
337
|
+
info: (message) => console.log(`ℹ️ ${message}`),
|
|
338
|
+
warn: (message) => console.warn(`⚠️ ${message}`),
|
|
339
|
+
error: (message) => console.error(`❌ ${message}`),
|
|
340
|
+
debug: (message) => {
|
|
341
|
+
if (process.env.DEBUG) {
|
|
342
|
+
console.log(`\uD83D\uDC1B ${message}`);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
success: (message) => console.log(`✅ ${message}`)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
createUtils() {
|
|
349
|
+
return {
|
|
350
|
+
toCamelCase,
|
|
351
|
+
toKebabCase: (str) => {
|
|
352
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
353
|
+
},
|
|
354
|
+
validateAddress: (address) => {
|
|
355
|
+
return validateStacksAddress(parseContractId(address).address);
|
|
356
|
+
},
|
|
357
|
+
parseContractId: (contractId) => {
|
|
358
|
+
return parseContractId(contractId);
|
|
359
|
+
},
|
|
360
|
+
formatCode: async (code) => {
|
|
361
|
+
const { formatCode: formatCode2 } = await Promise.resolve().then(() => (init_format(), exports_format));
|
|
362
|
+
return formatCode2(code);
|
|
363
|
+
},
|
|
364
|
+
resolvePath: (relativePath) => {
|
|
365
|
+
return path.resolve(process.cwd(), relativePath);
|
|
366
|
+
},
|
|
367
|
+
fileExists: async (filePath) => {
|
|
368
|
+
try {
|
|
369
|
+
await fs.access(filePath);
|
|
370
|
+
return true;
|
|
371
|
+
} catch {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
readFile: async (filePath) => {
|
|
376
|
+
return fs.readFile(filePath, "utf-8");
|
|
377
|
+
},
|
|
378
|
+
writeFile: async (filePath, content) => {
|
|
379
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
380
|
+
},
|
|
381
|
+
ensureDir: async (dirPath) => {
|
|
382
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
var validateStacksAddress;
|
|
388
|
+
var init_plugin_manager = __esm(() => {
|
|
389
|
+
validateStacksAddress = _validateStacksAddress;
|
|
390
|
+
});
|
|
391
|
+
|
|
50
392
|
// ../../node_modules/commander/lib/error.js
|
|
51
393
|
var require_error = __commonJS((exports) => {
|
|
52
394
|
class CommanderError extends Error {
|
|
@@ -769,8 +1111,8 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
769
1111
|
var require_command = __commonJS((exports) => {
|
|
770
1112
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
771
1113
|
var childProcess = __require("node:child_process");
|
|
772
|
-
var
|
|
773
|
-
var
|
|
1114
|
+
var path2 = __require("node:path");
|
|
1115
|
+
var fs2 = __require("node:fs");
|
|
774
1116
|
var process2 = __require("node:process");
|
|
775
1117
|
var { Argument, humanReadableArgName } = require_argument();
|
|
776
1118
|
var { CommanderError } = require_error();
|
|
@@ -1305,7 +1647,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1305
1647
|
this.processedArgs = [];
|
|
1306
1648
|
}
|
|
1307
1649
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1308
|
-
if (
|
|
1650
|
+
if (fs2.existsSync(executableFile))
|
|
1309
1651
|
return;
|
|
1310
1652
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
1311
1653
|
const executableMissing = `'${executableFile}' does not exist
|
|
@@ -1319,12 +1661,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1319
1661
|
let launchWithNode = false;
|
|
1320
1662
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1321
1663
|
function findFile(baseDir, baseName) {
|
|
1322
|
-
const localBin =
|
|
1323
|
-
if (
|
|
1664
|
+
const localBin = path2.resolve(baseDir, baseName);
|
|
1665
|
+
if (fs2.existsSync(localBin))
|
|
1324
1666
|
return localBin;
|
|
1325
|
-
if (sourceExt.includes(
|
|
1667
|
+
if (sourceExt.includes(path2.extname(baseName)))
|
|
1326
1668
|
return;
|
|
1327
|
-
const foundExt = sourceExt.find((ext) =>
|
|
1669
|
+
const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
|
|
1328
1670
|
if (foundExt)
|
|
1329
1671
|
return `${localBin}${foundExt}`;
|
|
1330
1672
|
return;
|
|
@@ -1336,23 +1678,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1336
1678
|
if (this._scriptPath) {
|
|
1337
1679
|
let resolvedScriptPath;
|
|
1338
1680
|
try {
|
|
1339
|
-
resolvedScriptPath =
|
|
1681
|
+
resolvedScriptPath = fs2.realpathSync(this._scriptPath);
|
|
1340
1682
|
} catch {
|
|
1341
1683
|
resolvedScriptPath = this._scriptPath;
|
|
1342
1684
|
}
|
|
1343
|
-
executableDir =
|
|
1685
|
+
executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
|
|
1344
1686
|
}
|
|
1345
1687
|
if (executableDir) {
|
|
1346
1688
|
let localFile = findFile(executableDir, executableFile);
|
|
1347
1689
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1348
|
-
const legacyName =
|
|
1690
|
+
const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
|
|
1349
1691
|
if (legacyName !== this._name) {
|
|
1350
1692
|
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1351
1693
|
}
|
|
1352
1694
|
}
|
|
1353
1695
|
executableFile = localFile || executableFile;
|
|
1354
1696
|
}
|
|
1355
|
-
launchWithNode = sourceExt.includes(
|
|
1697
|
+
launchWithNode = sourceExt.includes(path2.extname(executableFile));
|
|
1356
1698
|
let proc;
|
|
1357
1699
|
if (process2.platform !== "win32") {
|
|
1358
1700
|
if (launchWithNode) {
|
|
@@ -1789,7 +2131,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1789
2131
|
}
|
|
1790
2132
|
return positiveOption || option2;
|
|
1791
2133
|
};
|
|
1792
|
-
const
|
|
2134
|
+
const getErrorMessage2 = (option2) => {
|
|
1793
2135
|
const bestOption = findBestOptionFromValue(option2);
|
|
1794
2136
|
const optionKey = bestOption.attributeName();
|
|
1795
2137
|
const source = this.getOptionValueSource(optionKey);
|
|
@@ -1798,7 +2140,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1798
2140
|
}
|
|
1799
2141
|
return `option '${bestOption.flags}'`;
|
|
1800
2142
|
};
|
|
1801
|
-
const message = `error: ${
|
|
2143
|
+
const message = `error: ${getErrorMessage2(option)} cannot be used with ${getErrorMessage2(conflictingOption)}`;
|
|
1802
2144
|
this.error(message, { code: "commander.conflictingOption" });
|
|
1803
2145
|
}
|
|
1804
2146
|
unknownOption(flag) {
|
|
@@ -1941,13 +2283,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1941
2283
|
cmd.helpGroup(this._defaultCommandGroup);
|
|
1942
2284
|
}
|
|
1943
2285
|
nameFromFilename(filename) {
|
|
1944
|
-
this._name =
|
|
2286
|
+
this._name = path2.basename(filename, path2.extname(filename));
|
|
1945
2287
|
return this;
|
|
1946
2288
|
}
|
|
1947
|
-
executableDir(
|
|
1948
|
-
if (
|
|
2289
|
+
executableDir(path3) {
|
|
2290
|
+
if (path3 === undefined)
|
|
1949
2291
|
return this._executableDir;
|
|
1950
|
-
this._executableDir =
|
|
2292
|
+
this._executableDir = path3;
|
|
1951
2293
|
return this;
|
|
1952
2294
|
}
|
|
1953
2295
|
helpInformation(contextOptions) {
|
|
@@ -2204,18 +2546,18 @@ async function request(url, opts) {
|
|
|
2204
2546
|
return;
|
|
2205
2547
|
return await res.json();
|
|
2206
2548
|
}
|
|
2207
|
-
async function httpPlatform(
|
|
2549
|
+
async function httpPlatform(path2, opts = {}) {
|
|
2208
2550
|
const session = await readSession();
|
|
2209
2551
|
if (!session) {
|
|
2210
2552
|
throw new CliHttpError(401, "SESSION_EXPIRED", { error: "Not logged in" }, "Not logged in — run `sl login`");
|
|
2211
2553
|
}
|
|
2212
|
-
return request(`${PLATFORM_API_URL}${
|
|
2554
|
+
return request(`${PLATFORM_API_URL}${path2}`, {
|
|
2213
2555
|
...opts,
|
|
2214
2556
|
bearer: session.token
|
|
2215
2557
|
});
|
|
2216
2558
|
}
|
|
2217
|
-
async function httpPlatformAnon(
|
|
2218
|
-
return request(`${PLATFORM_API_URL}${
|
|
2559
|
+
async function httpPlatformAnon(path2, opts = {}) {
|
|
2560
|
+
return request(`${PLATFORM_API_URL}${path2}`, opts);
|
|
2219
2561
|
}
|
|
2220
2562
|
var CliHttpError, PLATFORM_API_URL;
|
|
2221
2563
|
var init_http = __esm(() => {
|
|
@@ -2237,26 +2579,26 @@ var init_http = __esm(() => {
|
|
|
2237
2579
|
|
|
2238
2580
|
// src/lib/fs.ts
|
|
2239
2581
|
import { mkdir as mkdir2, readFile as readFile2, stat, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
2240
|
-
async function readJsonFile(
|
|
2241
|
-
const text = await readFile2(
|
|
2582
|
+
async function readJsonFile(path2) {
|
|
2583
|
+
const text = await readFile2(path2, "utf-8");
|
|
2242
2584
|
return JSON.parse(text);
|
|
2243
2585
|
}
|
|
2244
|
-
async function writeTextFile(
|
|
2245
|
-
await writeFile2(
|
|
2586
|
+
async function writeTextFile(path2, content) {
|
|
2587
|
+
await writeFile2(path2, content, "utf-8");
|
|
2246
2588
|
}
|
|
2247
|
-
async function fileExists(
|
|
2589
|
+
async function fileExists(path2) {
|
|
2248
2590
|
try {
|
|
2249
|
-
await stat(
|
|
2591
|
+
await stat(path2);
|
|
2250
2592
|
return true;
|
|
2251
2593
|
} catch {
|
|
2252
2594
|
return false;
|
|
2253
2595
|
}
|
|
2254
2596
|
}
|
|
2255
|
-
async function ensureDir(
|
|
2256
|
-
await mkdir2(
|
|
2597
|
+
async function ensureDir(path2) {
|
|
2598
|
+
await mkdir2(path2, { recursive: true });
|
|
2257
2599
|
}
|
|
2258
|
-
async function removeFile(
|
|
2259
|
-
await unlink(
|
|
2600
|
+
async function removeFile(path2) {
|
|
2601
|
+
await unlink(path2);
|
|
2260
2602
|
}
|
|
2261
2603
|
var init_fs = () => {};
|
|
2262
2604
|
|
|
@@ -2285,11 +2627,11 @@ import { z as z2 } from "zod/v4";
|
|
|
2285
2627
|
async function ensureConfigDir() {
|
|
2286
2628
|
await ensureDir(CONFIG_DIR);
|
|
2287
2629
|
}
|
|
2288
|
-
function resolvePath(
|
|
2289
|
-
if (
|
|
2290
|
-
return join2(homedir2(),
|
|
2630
|
+
function resolvePath(path2) {
|
|
2631
|
+
if (path2.startsWith("~/")) {
|
|
2632
|
+
return join2(homedir2(), path2.slice(2));
|
|
2291
2633
|
}
|
|
2292
|
-
return
|
|
2634
|
+
return path2;
|
|
2293
2635
|
}
|
|
2294
2636
|
function getDataDir(config) {
|
|
2295
2637
|
const dataDir = config?.dataDir ?? DEFAULT_CONFIG.dataDir;
|
|
@@ -4100,13 +4442,13 @@ function Subscribe(postgres2, options) {
|
|
|
4100
4442
|
}
|
|
4101
4443
|
}
|
|
4102
4444
|
function handle(a, b2) {
|
|
4103
|
-
const
|
|
4445
|
+
const path2 = b2.relation.schema + "." + b2.relation.table;
|
|
4104
4446
|
call("*", a, b2);
|
|
4105
|
-
call("*:" +
|
|
4106
|
-
b2.relation.keys.length && call("*:" +
|
|
4447
|
+
call("*:" + path2, a, b2);
|
|
4448
|
+
b2.relation.keys.length && call("*:" + path2 + "=" + b2.relation.keys.map((x2) => a[x2.name]), a, b2);
|
|
4107
4449
|
call(b2.command, a, b2);
|
|
4108
|
-
call(b2.command + ":" +
|
|
4109
|
-
b2.relation.keys.length && call(b2.command + ":" +
|
|
4450
|
+
call(b2.command + ":" + path2, a, b2);
|
|
4451
|
+
b2.relation.keys.length && call(b2.command + ":" + path2 + "=" + b2.relation.keys.map((x2) => a[x2.name]), a, b2);
|
|
4110
4452
|
}
|
|
4111
4453
|
function pong() {
|
|
4112
4454
|
const x2 = Buffer.alloc(34);
|
|
@@ -4208,8 +4550,8 @@ function parseEvent(x) {
|
|
|
4208
4550
|
const xs = x.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i) || [];
|
|
4209
4551
|
if (!xs)
|
|
4210
4552
|
throw new Error("Malformed subscribe pattern: " + x);
|
|
4211
|
-
const [, command,
|
|
4212
|
-
return (command || "*") + (
|
|
4553
|
+
const [, command, path2, key] = xs;
|
|
4554
|
+
return (command || "*") + (path2 ? ":" + (path2.indexOf(".") === -1 ? "public." + path2 : path2) : "") + (key ? "=" + key : "");
|
|
4213
4555
|
}
|
|
4214
4556
|
var noop2 = () => {};
|
|
4215
4557
|
|
|
@@ -4286,7 +4628,7 @@ __export(exports_src, {
|
|
|
4286
4628
|
default: () => src_default
|
|
4287
4629
|
});
|
|
4288
4630
|
import os from "os";
|
|
4289
|
-
import
|
|
4631
|
+
import fs2 from "fs";
|
|
4290
4632
|
function Postgres(a, b2) {
|
|
4291
4633
|
const options = parseOptions(a, b2), subscribe = options.no_subscribe || Subscribe(Postgres, { ...options });
|
|
4292
4634
|
let ending = false;
|
|
@@ -4342,10 +4684,10 @@ function Postgres(a, b2) {
|
|
|
4342
4684
|
});
|
|
4343
4685
|
return query;
|
|
4344
4686
|
}
|
|
4345
|
-
function file(
|
|
4687
|
+
function file(path2, args = [], options2 = {}) {
|
|
4346
4688
|
arguments.length === 2 && !Array.isArray(args) && (options2 = args, args = []);
|
|
4347
4689
|
const query = new Query([], args, (query2) => {
|
|
4348
|
-
|
|
4690
|
+
fs2.readFile(path2, "utf8", (err, string) => {
|
|
4349
4691
|
if (err)
|
|
4350
4692
|
return query2.reject(err);
|
|
4351
4693
|
query2.strings = [string];
|
|
@@ -4772,57 +5114,6 @@ var init_dev_state = __esm(() => {
|
|
|
4772
5114
|
LOGS_DIR = join6(STATE_DIR, "logs");
|
|
4773
5115
|
});
|
|
4774
5116
|
|
|
4775
|
-
// src/utils/format.ts
|
|
4776
|
-
var exports_format = {};
|
|
4777
|
-
__export(exports_format, {
|
|
4778
|
-
formatCode: () => formatCode
|
|
4779
|
-
});
|
|
4780
|
-
import { Biome, Distribution } from "@biomejs/js-api";
|
|
4781
|
-
async function getBiome() {
|
|
4782
|
-
if (!biome) {
|
|
4783
|
-
biome = await Biome.create({
|
|
4784
|
-
distribution: Distribution.NODE
|
|
4785
|
-
});
|
|
4786
|
-
biome.applyConfiguration({
|
|
4787
|
-
formatter: {
|
|
4788
|
-
enabled: true,
|
|
4789
|
-
indentStyle: "tab",
|
|
4790
|
-
lineWidth: 80
|
|
4791
|
-
},
|
|
4792
|
-
javascript: {
|
|
4793
|
-
formatter: {
|
|
4794
|
-
semicolons: "always",
|
|
4795
|
-
quoteStyle: "single"
|
|
4796
|
-
}
|
|
4797
|
-
},
|
|
4798
|
-
organizeImports: {
|
|
4799
|
-
enabled: true
|
|
4800
|
-
},
|
|
4801
|
-
linter: {
|
|
4802
|
-
enabled: true
|
|
4803
|
-
},
|
|
4804
|
-
assists: {
|
|
4805
|
-
enabled: true
|
|
4806
|
-
}
|
|
4807
|
-
});
|
|
4808
|
-
biome.registerProjectFolder();
|
|
4809
|
-
}
|
|
4810
|
-
return biome;
|
|
4811
|
-
}
|
|
4812
|
-
async function formatCode(code) {
|
|
4813
|
-
const b2 = await getBiome();
|
|
4814
|
-
const linted = b2.lintContent(code, {
|
|
4815
|
-
filePath: "generated.ts",
|
|
4816
|
-
fixFileMode: "SafeFixes"
|
|
4817
|
-
});
|
|
4818
|
-
const formatted = b2.formatContent(linted.content, {
|
|
4819
|
-
filePath: "generated.ts"
|
|
4820
|
-
});
|
|
4821
|
-
return formatted.content;
|
|
4822
|
-
}
|
|
4823
|
-
var biome = null;
|
|
4824
|
-
var init_format = () => {};
|
|
4825
|
-
|
|
4826
5117
|
// src/utils/abi-compat.ts
|
|
4827
5118
|
function normalizeAccess(access) {
|
|
4828
5119
|
if (access === "read_only")
|
|
@@ -4977,10 +5268,10 @@ function normalizeAbi(abi) {
|
|
|
4977
5268
|
}
|
|
4978
5269
|
|
|
4979
5270
|
// src/parsers/clarity.ts
|
|
4980
|
-
import { promises as
|
|
5271
|
+
import { promises as fs3 } from "fs";
|
|
4981
5272
|
async function parseClarityFile(filePath) {
|
|
4982
5273
|
try {
|
|
4983
|
-
const content = await
|
|
5274
|
+
const content = await fs3.readFile(filePath, "utf-8");
|
|
4984
5275
|
const result = parseClarityContent(content);
|
|
4985
5276
|
if (result.functions.length === 0) {
|
|
4986
5277
|
console.warn(`⚠️ No functions found in ${filePath}. ` + `For complex contracts, deploy first and use the contract address instead.`);
|
|
@@ -9745,7 +10036,7 @@ var require_auto = __commonJS((exports, module) => {
|
|
|
9745
10036
|
const result = await queue2.get(name);
|
|
9746
10037
|
return { alpnProtocol: result.alpnProtocol };
|
|
9747
10038
|
}
|
|
9748
|
-
const { path } = options;
|
|
10039
|
+
const { path: path2 } = options;
|
|
9749
10040
|
options.path = options.socketPath;
|
|
9750
10041
|
const resultPromise = resolveALPN(options, connect);
|
|
9751
10042
|
queue2.set(name, resultPromise);
|
|
@@ -9753,11 +10044,11 @@ var require_auto = __commonJS((exports, module) => {
|
|
|
9753
10044
|
const result = await resultPromise;
|
|
9754
10045
|
cache2.set(name, result.alpnProtocol);
|
|
9755
10046
|
queue2.delete(name);
|
|
9756
|
-
options.path =
|
|
10047
|
+
options.path = path2;
|
|
9757
10048
|
return result;
|
|
9758
10049
|
} catch (error2) {
|
|
9759
10050
|
queue2.delete(name);
|
|
9760
|
-
options.path =
|
|
10051
|
+
options.path = path2;
|
|
9761
10052
|
throw error2;
|
|
9762
10053
|
}
|
|
9763
10054
|
}
|
|
@@ -10745,10 +11036,10 @@ var init_options = __esm(() => {
|
|
|
10745
11036
|
}
|
|
10746
11037
|
const matches = /(?<socketPath>.+?):(?<path>.+)/.exec(`${url.pathname}${url.search}`);
|
|
10747
11038
|
if (matches?.groups) {
|
|
10748
|
-
const { socketPath, path } = matches.groups;
|
|
11039
|
+
const { socketPath, path: path2 } = matches.groups;
|
|
10749
11040
|
this._unixOptions = {
|
|
10750
11041
|
socketPath,
|
|
10751
|
-
path,
|
|
11042
|
+
path: path2,
|
|
10752
11043
|
host: ""
|
|
10753
11044
|
};
|
|
10754
11045
|
} else {
|
|
@@ -12697,18 +12988,6 @@ var init_source3 = __esm(() => {
|
|
|
12697
12988
|
source_default2 = got;
|
|
12698
12989
|
});
|
|
12699
12990
|
|
|
12700
|
-
// src/utils/contract-id.ts
|
|
12701
|
-
function parseContractId(contractId) {
|
|
12702
|
-
const dotIndex = contractId.indexOf(".");
|
|
12703
|
-
if (dotIndex === -1) {
|
|
12704
|
-
throw new Error(`Invalid contract ID: "${contractId}" (expected "address.contractName")`);
|
|
12705
|
-
}
|
|
12706
|
-
return {
|
|
12707
|
-
address: contractId.slice(0, dotIndex),
|
|
12708
|
-
contractName: contractId.slice(dotIndex + 1)
|
|
12709
|
-
};
|
|
12710
|
-
}
|
|
12711
|
-
|
|
12712
12991
|
// src/utils/api.ts
|
|
12713
12992
|
class StacksApiClient {
|
|
12714
12993
|
baseUrl;
|
|
@@ -12870,9 +13149,9 @@ async function isDockerRunning() {
|
|
|
12870
13149
|
return false;
|
|
12871
13150
|
}
|
|
12872
13151
|
}
|
|
12873
|
-
async function validateNodePath(
|
|
12874
|
-
const manageScript = Bun.file(`${
|
|
12875
|
-
const envFile = Bun.file(`${
|
|
13152
|
+
async function validateNodePath(path2) {
|
|
13153
|
+
const manageScript = Bun.file(`${path2}/manage.sh`);
|
|
13154
|
+
const envFile = Bun.file(`${path2}/.env`);
|
|
12876
13155
|
if (!await manageScript.exists()) {
|
|
12877
13156
|
return { valid: false, error: "manage.sh not found" };
|
|
12878
13157
|
}
|
|
@@ -14861,7 +15140,7 @@ var require_path = __commonJS((exports) => {
|
|
|
14861
15140
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14862
15141
|
exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = undefined;
|
|
14863
15142
|
var os4 = __require("os");
|
|
14864
|
-
var
|
|
15143
|
+
var path2 = __require("path");
|
|
14865
15144
|
var IS_WINDOWS_PLATFORM = os4.platform() === "win32";
|
|
14866
15145
|
var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
14867
15146
|
var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
@@ -14873,7 +15152,7 @@ var require_path = __commonJS((exports) => {
|
|
|
14873
15152
|
}
|
|
14874
15153
|
exports.unixify = unixify;
|
|
14875
15154
|
function makeAbsolute(cwd, filepath) {
|
|
14876
|
-
return
|
|
15155
|
+
return path2.resolve(cwd, filepath);
|
|
14877
15156
|
}
|
|
14878
15157
|
exports.makeAbsolute = makeAbsolute;
|
|
14879
15158
|
function removeLeadingDotSegment(entry) {
|
|
@@ -16131,7 +16410,7 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
16131
16410
|
|
|
16132
16411
|
// ../../node_modules/picomatch/lib/constants.js
|
|
16133
16412
|
var require_constants2 = __commonJS((exports, module) => {
|
|
16134
|
-
var
|
|
16413
|
+
var path2 = __require("path");
|
|
16135
16414
|
var WIN_SLASH = "\\\\/";
|
|
16136
16415
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
16137
16416
|
var DOT_LITERAL = "\\.";
|
|
@@ -16253,7 +16532,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
16253
16532
|
CHAR_UNDERSCORE: 95,
|
|
16254
16533
|
CHAR_VERTICAL_LINE: 124,
|
|
16255
16534
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
16256
|
-
SEP:
|
|
16535
|
+
SEP: path2.sep,
|
|
16257
16536
|
extglobChars(chars) {
|
|
16258
16537
|
return {
|
|
16259
16538
|
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
@@ -16271,7 +16550,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
16271
16550
|
|
|
16272
16551
|
// ../../node_modules/picomatch/lib/utils.js
|
|
16273
16552
|
var require_utils2 = __commonJS((exports) => {
|
|
16274
|
-
var
|
|
16553
|
+
var path2 = __require("path");
|
|
16275
16554
|
var win32 = process.platform === "win32";
|
|
16276
16555
|
var {
|
|
16277
16556
|
REGEX_BACKSLASH,
|
|
@@ -16300,7 +16579,7 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
16300
16579
|
if (options2 && typeof options2.windows === "boolean") {
|
|
16301
16580
|
return options2.windows;
|
|
16302
16581
|
}
|
|
16303
|
-
return win32 === true ||
|
|
16582
|
+
return win32 === true || path2.sep === "\\";
|
|
16304
16583
|
};
|
|
16305
16584
|
exports.escapeLast = (input6, char, lastIdx) => {
|
|
16306
16585
|
const idx = input6.lastIndexOf(char, lastIdx);
|
|
@@ -17424,7 +17703,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17424
17703
|
|
|
17425
17704
|
// ../../node_modules/picomatch/lib/picomatch.js
|
|
17426
17705
|
var require_picomatch = __commonJS((exports, module) => {
|
|
17427
|
-
var
|
|
17706
|
+
var path2 = __require("path");
|
|
17428
17707
|
var scan = require_scan();
|
|
17429
17708
|
var parse2 = require_parse2();
|
|
17430
17709
|
var utils = require_utils2();
|
|
@@ -17510,7 +17789,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17510
17789
|
};
|
|
17511
17790
|
picomatch.matchBase = (input6, glob, options2, posix = utils.isWindows(options2)) => {
|
|
17512
17791
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options2);
|
|
17513
|
-
return regex.test(
|
|
17792
|
+
return regex.test(path2.basename(input6));
|
|
17514
17793
|
};
|
|
17515
17794
|
picomatch.isMatch = (str, patterns, options2) => picomatch(patterns, options2)(str);
|
|
17516
17795
|
picomatch.parse = (pattern, options2) => {
|
|
@@ -17731,7 +18010,7 @@ var require_micromatch = __commonJS((exports, module) => {
|
|
|
17731
18010
|
var require_pattern = __commonJS((exports) => {
|
|
17732
18011
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17733
18012
|
exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = undefined;
|
|
17734
|
-
var
|
|
18013
|
+
var path2 = __require("path");
|
|
17735
18014
|
var globParent = require_glob_parent();
|
|
17736
18015
|
var micromatch = require_micromatch();
|
|
17737
18016
|
var GLOBSTAR = "**";
|
|
@@ -17826,7 +18105,7 @@ var require_pattern = __commonJS((exports) => {
|
|
|
17826
18105
|
}
|
|
17827
18106
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
17828
18107
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
17829
|
-
const basename =
|
|
18108
|
+
const basename = path2.basename(pattern);
|
|
17830
18109
|
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
|
17831
18110
|
}
|
|
17832
18111
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -17884,7 +18163,7 @@ var require_pattern = __commonJS((exports) => {
|
|
|
17884
18163
|
}
|
|
17885
18164
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
17886
18165
|
function isAbsolute(pattern) {
|
|
17887
|
-
return
|
|
18166
|
+
return path2.isAbsolute(pattern);
|
|
17888
18167
|
}
|
|
17889
18168
|
exports.isAbsolute = isAbsolute;
|
|
17890
18169
|
});
|
|
@@ -18047,10 +18326,10 @@ var require_utils3 = __commonJS((exports) => {
|
|
|
18047
18326
|
exports.array = array;
|
|
18048
18327
|
var errno = require_errno();
|
|
18049
18328
|
exports.errno = errno;
|
|
18050
|
-
var
|
|
18051
|
-
exports.fs =
|
|
18052
|
-
var
|
|
18053
|
-
exports.path =
|
|
18329
|
+
var fs4 = require_fs();
|
|
18330
|
+
exports.fs = fs4;
|
|
18331
|
+
var path2 = require_path();
|
|
18332
|
+
exports.path = path2;
|
|
18054
18333
|
var pattern = require_pattern();
|
|
18055
18334
|
exports.pattern = pattern;
|
|
18056
18335
|
var stream2 = require_stream();
|
|
@@ -18146,8 +18425,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
18146
18425
|
var require_async = __commonJS((exports) => {
|
|
18147
18426
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18148
18427
|
exports.read = undefined;
|
|
18149
|
-
function read(
|
|
18150
|
-
settings.fs.lstat(
|
|
18428
|
+
function read(path2, settings, callback) {
|
|
18429
|
+
settings.fs.lstat(path2, (lstatError, lstat) => {
|
|
18151
18430
|
if (lstatError !== null) {
|
|
18152
18431
|
callFailureCallback(callback, lstatError);
|
|
18153
18432
|
return;
|
|
@@ -18156,7 +18435,7 @@ var require_async = __commonJS((exports) => {
|
|
|
18156
18435
|
callSuccessCallback(callback, lstat);
|
|
18157
18436
|
return;
|
|
18158
18437
|
}
|
|
18159
|
-
settings.fs.stat(
|
|
18438
|
+
settings.fs.stat(path2, (statError, stat2) => {
|
|
18160
18439
|
if (statError !== null) {
|
|
18161
18440
|
if (settings.throwErrorOnBrokenSymbolicLink) {
|
|
18162
18441
|
callFailureCallback(callback, statError);
|
|
@@ -18185,13 +18464,13 @@ var require_async = __commonJS((exports) => {
|
|
|
18185
18464
|
var require_sync = __commonJS((exports) => {
|
|
18186
18465
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18187
18466
|
exports.read = undefined;
|
|
18188
|
-
function read(
|
|
18189
|
-
const lstat = settings.fs.lstatSync(
|
|
18467
|
+
function read(path2, settings) {
|
|
18468
|
+
const lstat = settings.fs.lstatSync(path2);
|
|
18190
18469
|
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
|
18191
18470
|
return lstat;
|
|
18192
18471
|
}
|
|
18193
18472
|
try {
|
|
18194
|
-
const stat2 = settings.fs.statSync(
|
|
18473
|
+
const stat2 = settings.fs.statSync(path2);
|
|
18195
18474
|
if (settings.markSymbolicLink) {
|
|
18196
18475
|
stat2.isSymbolicLink = () => true;
|
|
18197
18476
|
}
|
|
@@ -18210,12 +18489,12 @@ var require_sync = __commonJS((exports) => {
|
|
|
18210
18489
|
var require_fs2 = __commonJS((exports) => {
|
|
18211
18490
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18212
18491
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
|
|
18213
|
-
var
|
|
18492
|
+
var fs4 = __require("fs");
|
|
18214
18493
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18215
|
-
lstat:
|
|
18216
|
-
stat:
|
|
18217
|
-
lstatSync:
|
|
18218
|
-
statSync:
|
|
18494
|
+
lstat: fs4.lstat,
|
|
18495
|
+
stat: fs4.stat,
|
|
18496
|
+
lstatSync: fs4.lstatSync,
|
|
18497
|
+
statSync: fs4.statSync
|
|
18219
18498
|
};
|
|
18220
18499
|
function createFileSystemAdapter(fsMethods) {
|
|
18221
18500
|
if (fsMethods === undefined) {
|
|
@@ -18229,13 +18508,13 @@ var require_fs2 = __commonJS((exports) => {
|
|
|
18229
18508
|
// ../../node_modules/@nodelib/fs.stat/out/settings.js
|
|
18230
18509
|
var require_settings = __commonJS((exports) => {
|
|
18231
18510
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18232
|
-
var
|
|
18511
|
+
var fs4 = require_fs2();
|
|
18233
18512
|
|
|
18234
18513
|
class Settings {
|
|
18235
18514
|
constructor(_options = {}) {
|
|
18236
18515
|
this._options = _options;
|
|
18237
18516
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
18238
|
-
this.fs =
|
|
18517
|
+
this.fs = fs4.createFileSystemAdapter(this._options.fs);
|
|
18239
18518
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
18240
18519
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
18241
18520
|
}
|
|
@@ -18254,17 +18533,17 @@ var require_out = __commonJS((exports) => {
|
|
|
18254
18533
|
var sync = require_sync();
|
|
18255
18534
|
var settings_1 = require_settings();
|
|
18256
18535
|
exports.Settings = settings_1.default;
|
|
18257
|
-
function stat2(
|
|
18536
|
+
function stat2(path2, optionsOrSettingsOrCallback, callback) {
|
|
18258
18537
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
18259
|
-
async.read(
|
|
18538
|
+
async.read(path2, getSettings(), optionsOrSettingsOrCallback);
|
|
18260
18539
|
return;
|
|
18261
18540
|
}
|
|
18262
|
-
async.read(
|
|
18541
|
+
async.read(path2, getSettings(optionsOrSettingsOrCallback), callback);
|
|
18263
18542
|
}
|
|
18264
18543
|
exports.stat = stat2;
|
|
18265
|
-
function statSync2(
|
|
18544
|
+
function statSync2(path2, optionsOrSettings) {
|
|
18266
18545
|
const settings = getSettings(optionsOrSettings);
|
|
18267
|
-
return sync.read(
|
|
18546
|
+
return sync.read(path2, settings);
|
|
18268
18547
|
}
|
|
18269
18548
|
exports.statSync = statSync2;
|
|
18270
18549
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -18380,8 +18659,8 @@ var require_fs3 = __commonJS((exports) => {
|
|
|
18380
18659
|
var require_utils4 = __commonJS((exports) => {
|
|
18381
18660
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18382
18661
|
exports.fs = undefined;
|
|
18383
|
-
var
|
|
18384
|
-
exports.fs =
|
|
18662
|
+
var fs4 = require_fs3();
|
|
18663
|
+
exports.fs = fs4;
|
|
18385
18664
|
});
|
|
18386
18665
|
|
|
18387
18666
|
// ../../node_modules/@nodelib/fs.scandir/out/providers/common.js
|
|
@@ -18467,16 +18746,16 @@ var require_async2 = __commonJS((exports) => {
|
|
|
18467
18746
|
return;
|
|
18468
18747
|
}
|
|
18469
18748
|
const tasks = names.map((name) => {
|
|
18470
|
-
const
|
|
18749
|
+
const path2 = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
|
18471
18750
|
return (done) => {
|
|
18472
|
-
fsStat.stat(
|
|
18751
|
+
fsStat.stat(path2, settings.fsStatSettings, (error2, stats) => {
|
|
18473
18752
|
if (error2 !== null) {
|
|
18474
18753
|
done(error2);
|
|
18475
18754
|
return;
|
|
18476
18755
|
}
|
|
18477
18756
|
const entry = {
|
|
18478
18757
|
name,
|
|
18479
|
-
path,
|
|
18758
|
+
path: path2,
|
|
18480
18759
|
dirent: utils.fs.createDirentFromStats(name, stats)
|
|
18481
18760
|
};
|
|
18482
18761
|
if (settings.stats) {
|
|
@@ -18564,14 +18843,14 @@ var require_sync2 = __commonJS((exports) => {
|
|
|
18564
18843
|
var require_fs4 = __commonJS((exports) => {
|
|
18565
18844
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18566
18845
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
|
|
18567
|
-
var
|
|
18846
|
+
var fs4 = __require("fs");
|
|
18568
18847
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18569
|
-
lstat:
|
|
18570
|
-
stat:
|
|
18571
|
-
lstatSync:
|
|
18572
|
-
statSync:
|
|
18573
|
-
readdir:
|
|
18574
|
-
readdirSync:
|
|
18848
|
+
lstat: fs4.lstat,
|
|
18849
|
+
stat: fs4.stat,
|
|
18850
|
+
lstatSync: fs4.lstatSync,
|
|
18851
|
+
statSync: fs4.statSync,
|
|
18852
|
+
readdir: fs4.readdir,
|
|
18853
|
+
readdirSync: fs4.readdirSync
|
|
18575
18854
|
};
|
|
18576
18855
|
function createFileSystemAdapter(fsMethods) {
|
|
18577
18856
|
if (fsMethods === undefined) {
|
|
@@ -18585,16 +18864,16 @@ var require_fs4 = __commonJS((exports) => {
|
|
|
18585
18864
|
// ../../node_modules/@nodelib/fs.scandir/out/settings.js
|
|
18586
18865
|
var require_settings2 = __commonJS((exports) => {
|
|
18587
18866
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18588
|
-
var
|
|
18867
|
+
var path2 = __require("path");
|
|
18589
18868
|
var fsStat = require_out();
|
|
18590
|
-
var
|
|
18869
|
+
var fs4 = require_fs4();
|
|
18591
18870
|
|
|
18592
18871
|
class Settings {
|
|
18593
18872
|
constructor(_options = {}) {
|
|
18594
18873
|
this._options = _options;
|
|
18595
18874
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
18596
|
-
this.fs =
|
|
18597
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
18875
|
+
this.fs = fs4.createFileSystemAdapter(this._options.fs);
|
|
18876
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path2.sep);
|
|
18598
18877
|
this.stats = this._getValue(this._options.stats, false);
|
|
18599
18878
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
18600
18879
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -18618,17 +18897,17 @@ var require_out2 = __commonJS((exports) => {
|
|
|
18618
18897
|
var sync = require_sync2();
|
|
18619
18898
|
var settings_1 = require_settings2();
|
|
18620
18899
|
exports.Settings = settings_1.default;
|
|
18621
|
-
function scandir(
|
|
18900
|
+
function scandir(path2, optionsOrSettingsOrCallback, callback) {
|
|
18622
18901
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
18623
|
-
async.read(
|
|
18902
|
+
async.read(path2, getSettings(), optionsOrSettingsOrCallback);
|
|
18624
18903
|
return;
|
|
18625
18904
|
}
|
|
18626
|
-
async.read(
|
|
18905
|
+
async.read(path2, getSettings(optionsOrSettingsOrCallback), callback);
|
|
18627
18906
|
}
|
|
18628
18907
|
exports.scandir = scandir;
|
|
18629
|
-
function scandirSync(
|
|
18908
|
+
function scandirSync(path2, optionsOrSettings) {
|
|
18630
18909
|
const settings = getSettings(optionsOrSettings);
|
|
18631
|
-
return sync.read(
|
|
18910
|
+
return sync.read(path2, settings);
|
|
18632
18911
|
}
|
|
18633
18912
|
exports.scandirSync = scandirSync;
|
|
18634
18913
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -19229,7 +19508,7 @@ var require_sync4 = __commonJS((exports) => {
|
|
|
19229
19508
|
// ../../node_modules/@nodelib/fs.walk/out/settings.js
|
|
19230
19509
|
var require_settings3 = __commonJS((exports) => {
|
|
19231
19510
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19232
|
-
var
|
|
19511
|
+
var path2 = __require("path");
|
|
19233
19512
|
var fsScandir = require_out2();
|
|
19234
19513
|
|
|
19235
19514
|
class Settings {
|
|
@@ -19240,7 +19519,7 @@ var require_settings3 = __commonJS((exports) => {
|
|
|
19240
19519
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
19241
19520
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
19242
19521
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
19243
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
19522
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path2.sep);
|
|
19244
19523
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
19245
19524
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
19246
19525
|
fs: this._options.fs,
|
|
@@ -19296,7 +19575,7 @@ var require_out3 = __commonJS((exports) => {
|
|
|
19296
19575
|
// ../../node_modules/fast-glob/out/readers/reader.js
|
|
19297
19576
|
var require_reader2 = __commonJS((exports) => {
|
|
19298
19577
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19299
|
-
var
|
|
19578
|
+
var path2 = __require("path");
|
|
19300
19579
|
var fsStat = require_out();
|
|
19301
19580
|
var utils = require_utils3();
|
|
19302
19581
|
|
|
@@ -19310,7 +19589,7 @@ var require_reader2 = __commonJS((exports) => {
|
|
|
19310
19589
|
});
|
|
19311
19590
|
}
|
|
19312
19591
|
_getFullEntryPath(filepath) {
|
|
19313
|
-
return
|
|
19592
|
+
return path2.resolve(this._settings.cwd, filepath);
|
|
19314
19593
|
}
|
|
19315
19594
|
_makeEntry(stats, pattern) {
|
|
19316
19595
|
const entry = {
|
|
@@ -19707,7 +19986,7 @@ var require_entry2 = __commonJS((exports) => {
|
|
|
19707
19986
|
// ../../node_modules/fast-glob/out/providers/provider.js
|
|
19708
19987
|
var require_provider = __commonJS((exports) => {
|
|
19709
19988
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19710
|
-
var
|
|
19989
|
+
var path2 = __require("path");
|
|
19711
19990
|
var deep_1 = require_deep();
|
|
19712
19991
|
var entry_1 = require_entry();
|
|
19713
19992
|
var error_1 = require_error2();
|
|
@@ -19722,7 +20001,7 @@ var require_provider = __commonJS((exports) => {
|
|
|
19722
20001
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
19723
20002
|
}
|
|
19724
20003
|
_getRootDirectory(task) {
|
|
19725
|
-
return
|
|
20004
|
+
return path2.resolve(this._settings.cwd, task.base);
|
|
19726
20005
|
}
|
|
19727
20006
|
_getReaderOptions(task) {
|
|
19728
20007
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -19891,16 +20170,16 @@ var require_sync6 = __commonJS((exports) => {
|
|
|
19891
20170
|
var require_settings4 = __commonJS((exports) => {
|
|
19892
20171
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19893
20172
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
|
|
19894
|
-
var
|
|
20173
|
+
var fs4 = __require("fs");
|
|
19895
20174
|
var os4 = __require("os");
|
|
19896
20175
|
var CPU_COUNT = Math.max(os4.cpus().length, 1);
|
|
19897
20176
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
19898
|
-
lstat:
|
|
19899
|
-
lstatSync:
|
|
19900
|
-
stat:
|
|
19901
|
-
statSync:
|
|
19902
|
-
readdir:
|
|
19903
|
-
readdirSync:
|
|
20177
|
+
lstat: fs4.lstat,
|
|
20178
|
+
lstatSync: fs4.lstatSync,
|
|
20179
|
+
stat: fs4.stat,
|
|
20180
|
+
statSync: fs4.statSync,
|
|
20181
|
+
readdir: fs4.readdir,
|
|
20182
|
+
readdirSync: fs4.readdirSync
|
|
19904
20183
|
};
|
|
19905
20184
|
|
|
19906
20185
|
class Settings {
|
|
@@ -20043,285 +20322,6 @@ var require_out4 = __commonJS((exports, module) => {
|
|
|
20043
20322
|
module.exports = FastGlob;
|
|
20044
20323
|
});
|
|
20045
20324
|
|
|
20046
|
-
// src/types/plugin.ts
|
|
20047
|
-
function isClarinetContract(c) {
|
|
20048
|
-
return "_clarinetSource" in c && c._clarinetSource === true;
|
|
20049
|
-
}
|
|
20050
|
-
function isDirectFileContract(c) {
|
|
20051
|
-
return "_directFile" in c && c._directFile === true;
|
|
20052
|
-
}
|
|
20053
|
-
|
|
20054
|
-
// src/core/plugin-manager.ts
|
|
20055
|
-
import { promises as fs3 } from "fs";
|
|
20056
|
-
import path from "path";
|
|
20057
|
-
import { isValidAddress as _validateStacksAddress } from "@secondlayer/stacks";
|
|
20058
|
-
import { getErrorMessage } from "@secondlayer/shared";
|
|
20059
|
-
import { toCamelCase as toCamelCase3 } from "@secondlayer/stacks/clarity";
|
|
20060
|
-
|
|
20061
|
-
class PluginManager {
|
|
20062
|
-
plugins = [];
|
|
20063
|
-
logger;
|
|
20064
|
-
utils;
|
|
20065
|
-
executionContext;
|
|
20066
|
-
constructor() {
|
|
20067
|
-
this.logger = this.createLogger();
|
|
20068
|
-
this.utils = this.createUtils();
|
|
20069
|
-
this.executionContext = {
|
|
20070
|
-
phase: "config",
|
|
20071
|
-
startTime: Date.now(),
|
|
20072
|
-
results: new Map
|
|
20073
|
-
};
|
|
20074
|
-
}
|
|
20075
|
-
register(plugin) {
|
|
20076
|
-
if (!plugin.name || !plugin.version) {
|
|
20077
|
-
throw new Error("Plugin must have a name and version");
|
|
20078
|
-
}
|
|
20079
|
-
const existing = this.plugins.find((p) => p.name === plugin.name);
|
|
20080
|
-
if (existing) {
|
|
20081
|
-
throw new Error(`Plugin "${plugin.name}" is already registered (version ${existing.version})`);
|
|
20082
|
-
}
|
|
20083
|
-
this.plugins.push(plugin);
|
|
20084
|
-
this.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);
|
|
20085
|
-
}
|
|
20086
|
-
getPlugins() {
|
|
20087
|
-
return [...this.plugins];
|
|
20088
|
-
}
|
|
20089
|
-
async transformConfig(config) {
|
|
20090
|
-
this.executionContext.phase = "config";
|
|
20091
|
-
let transformedConfig = { ...config };
|
|
20092
|
-
for (const plugin of this.plugins) {
|
|
20093
|
-
if (plugin.transformConfig) {
|
|
20094
|
-
this.executionContext.currentPlugin = plugin;
|
|
20095
|
-
try {
|
|
20096
|
-
const result = await plugin.transformConfig(transformedConfig);
|
|
20097
|
-
transformedConfig = result;
|
|
20098
|
-
this.recordHookResult(plugin.name, "transformConfig", {
|
|
20099
|
-
success: true
|
|
20100
|
-
});
|
|
20101
|
-
} catch (error2) {
|
|
20102
|
-
this.recordHookResult(plugin.name, "transformConfig", {
|
|
20103
|
-
success: false,
|
|
20104
|
-
error: error2 instanceof Error ? error2 : new Error(getErrorMessage(error2))
|
|
20105
|
-
});
|
|
20106
|
-
throw new Error(`Plugin "${plugin.name}" failed during config transformation: ${getErrorMessage(error2)}`);
|
|
20107
|
-
}
|
|
20108
|
-
}
|
|
20109
|
-
}
|
|
20110
|
-
const resolvedConfig = {
|
|
20111
|
-
...transformedConfig,
|
|
20112
|
-
plugins: this.plugins
|
|
20113
|
-
};
|
|
20114
|
-
return resolvedConfig;
|
|
20115
|
-
}
|
|
20116
|
-
async transformContracts(contracts, _config) {
|
|
20117
|
-
const processedContracts = [];
|
|
20118
|
-
for (let contract of contracts) {
|
|
20119
|
-
if (isClarinetContract(contract) && contract.abi) {
|
|
20120
|
-
processedContracts.push(this.contractToProcessed(contract, "clarinet"));
|
|
20121
|
-
continue;
|
|
20122
|
-
}
|
|
20123
|
-
if (isDirectFileContract(contract) && contract.abi) {
|
|
20124
|
-
processedContracts.push(this.contractToProcessed(contract, "direct"));
|
|
20125
|
-
continue;
|
|
20126
|
-
}
|
|
20127
|
-
for (const plugin of this.plugins) {
|
|
20128
|
-
if (plugin.transformContract) {
|
|
20129
|
-
this.executionContext.currentPlugin = plugin;
|
|
20130
|
-
try {
|
|
20131
|
-
contract = await plugin.transformContract(contract);
|
|
20132
|
-
this.recordHookResult(plugin.name, "transformContract", {
|
|
20133
|
-
success: true
|
|
20134
|
-
});
|
|
20135
|
-
} catch (error2) {
|
|
20136
|
-
this.recordHookResult(plugin.name, "transformContract", {
|
|
20137
|
-
success: false,
|
|
20138
|
-
error: error2 instanceof Error ? error2 : new Error(getErrorMessage(error2))
|
|
20139
|
-
});
|
|
20140
|
-
this.logger.warn(`Plugin "${plugin.name}" failed to transform contract: ${getErrorMessage(error2)}`);
|
|
20141
|
-
}
|
|
20142
|
-
}
|
|
20143
|
-
}
|
|
20144
|
-
if (contract.abi) {
|
|
20145
|
-
processedContracts.push(this.contractToProcessed(contract, "api"));
|
|
20146
|
-
}
|
|
20147
|
-
}
|
|
20148
|
-
return processedContracts;
|
|
20149
|
-
}
|
|
20150
|
-
async executeHook(hookName, context) {
|
|
20151
|
-
for (const plugin of this.plugins) {
|
|
20152
|
-
const hook = plugin[hookName];
|
|
20153
|
-
if (typeof hook === "function") {
|
|
20154
|
-
this.executionContext.currentPlugin = plugin;
|
|
20155
|
-
try {
|
|
20156
|
-
await hook.call(plugin, context);
|
|
20157
|
-
this.recordHookResult(plugin.name, hookName, {
|
|
20158
|
-
success: true
|
|
20159
|
-
});
|
|
20160
|
-
} catch (error2) {
|
|
20161
|
-
this.recordHookResult(plugin.name, hookName, {
|
|
20162
|
-
success: false,
|
|
20163
|
-
error: error2 instanceof Error ? error2 : new Error(getErrorMessage(error2))
|
|
20164
|
-
});
|
|
20165
|
-
this.logger.error(`Plugin "${plugin.name}" failed during ${hookName}: ${getErrorMessage(error2)}`);
|
|
20166
|
-
}
|
|
20167
|
-
}
|
|
20168
|
-
}
|
|
20169
|
-
}
|
|
20170
|
-
async executeGeneration(contracts, config) {
|
|
20171
|
-
this.executionContext.phase = "generate";
|
|
20172
|
-
const outputs = new Map;
|
|
20173
|
-
const context = {
|
|
20174
|
-
config,
|
|
20175
|
-
logger: this.logger,
|
|
20176
|
-
utils: this.utils,
|
|
20177
|
-
contracts,
|
|
20178
|
-
outputs,
|
|
20179
|
-
augment: (outputKey, contractName, content) => {
|
|
20180
|
-
this.augmentOutput(outputs, outputKey, contractName, content);
|
|
20181
|
-
},
|
|
20182
|
-
addOutput: (key, output) => {
|
|
20183
|
-
outputs.set(key, output);
|
|
20184
|
-
}
|
|
20185
|
-
};
|
|
20186
|
-
await this.executeHook("beforeGenerate", context);
|
|
20187
|
-
await this.executeHook("generate", context);
|
|
20188
|
-
await this.executeHook("afterGenerate", context);
|
|
20189
|
-
return outputs;
|
|
20190
|
-
}
|
|
20191
|
-
async transformOutputs(outputs) {
|
|
20192
|
-
this.executionContext.phase = "output";
|
|
20193
|
-
const transformedOutputs = new Map;
|
|
20194
|
-
for (const [key, output] of outputs) {
|
|
20195
|
-
let transformedContent = output.content;
|
|
20196
|
-
for (const plugin of this.plugins) {
|
|
20197
|
-
if (plugin.transformOutput) {
|
|
20198
|
-
this.executionContext.currentPlugin = plugin;
|
|
20199
|
-
try {
|
|
20200
|
-
transformedContent = await plugin.transformOutput(transformedContent, output.type || "other");
|
|
20201
|
-
this.recordHookResult(plugin.name, "transformOutput", {
|
|
20202
|
-
success: true
|
|
20203
|
-
});
|
|
20204
|
-
} catch (error2) {
|
|
20205
|
-
this.recordHookResult(plugin.name, "transformOutput", {
|
|
20206
|
-
success: false,
|
|
20207
|
-
error: error2 instanceof Error ? error2 : new Error(getErrorMessage(error2))
|
|
20208
|
-
});
|
|
20209
|
-
this.logger.warn(`Plugin "${plugin.name}" failed to transform output: ${getErrorMessage(error2)}`);
|
|
20210
|
-
}
|
|
20211
|
-
}
|
|
20212
|
-
}
|
|
20213
|
-
transformedOutputs.set(key, {
|
|
20214
|
-
...output,
|
|
20215
|
-
content: transformedContent
|
|
20216
|
-
});
|
|
20217
|
-
}
|
|
20218
|
-
return transformedOutputs;
|
|
20219
|
-
}
|
|
20220
|
-
async writeOutputs(outputs) {
|
|
20221
|
-
for (const [, output] of outputs) {
|
|
20222
|
-
try {
|
|
20223
|
-
const resolvedPath = path.resolve(process.cwd(), output.path);
|
|
20224
|
-
await this.utils.ensureDir(path.dirname(resolvedPath));
|
|
20225
|
-
await this.utils.writeFile(resolvedPath, output.content);
|
|
20226
|
-
} catch (error2) {
|
|
20227
|
-
this.logger.error(`Failed to write ${output.path}: ${getErrorMessage(error2)}`);
|
|
20228
|
-
throw error2;
|
|
20229
|
-
}
|
|
20230
|
-
}
|
|
20231
|
-
}
|
|
20232
|
-
getExecutionResults() {
|
|
20233
|
-
return new Map(this.executionContext.results);
|
|
20234
|
-
}
|
|
20235
|
-
contractToProcessed(contract, source) {
|
|
20236
|
-
const address = typeof contract.address === "string" ? contract.address : "";
|
|
20237
|
-
const parsed = parseContractId(address);
|
|
20238
|
-
return {
|
|
20239
|
-
name: contract.name || parsed.contractName || "unknown",
|
|
20240
|
-
address: parsed.address || "unknown",
|
|
20241
|
-
contractName: parsed.contractName || contract.name || "unknown",
|
|
20242
|
-
abi: contract.abi,
|
|
20243
|
-
source: source === "api" ? "api" : "local",
|
|
20244
|
-
metadata: contract.metadata ?? { source }
|
|
20245
|
-
};
|
|
20246
|
-
}
|
|
20247
|
-
augmentOutput(outputs, outputKey, contractName, content) {
|
|
20248
|
-
const existing = outputs.get(outputKey);
|
|
20249
|
-
if (!existing) {
|
|
20250
|
-
this.logger.warn(`Cannot augment non-existent output: ${outputKey}`);
|
|
20251
|
-
return;
|
|
20252
|
-
}
|
|
20253
|
-
const augmentedContent = `${existing.content}
|
|
20254
|
-
|
|
20255
|
-
// Augmented by plugin for ${contractName}
|
|
20256
|
-
${JSON.stringify(content, null, 2)}`;
|
|
20257
|
-
outputs.set(outputKey, {
|
|
20258
|
-
...existing,
|
|
20259
|
-
content: augmentedContent
|
|
20260
|
-
});
|
|
20261
|
-
}
|
|
20262
|
-
recordHookResult(pluginName, hookName, result) {
|
|
20263
|
-
const key = `${pluginName}:${hookName}`;
|
|
20264
|
-
const existing = this.executionContext.results.get(key) || [];
|
|
20265
|
-
existing.push({ ...result, plugin: pluginName });
|
|
20266
|
-
this.executionContext.results.set(key, existing);
|
|
20267
|
-
}
|
|
20268
|
-
createLogger() {
|
|
20269
|
-
return {
|
|
20270
|
-
info: (message) => console.log(`ℹ️ ${message}`),
|
|
20271
|
-
warn: (message) => console.warn(`⚠️ ${message}`),
|
|
20272
|
-
error: (message) => console.error(`❌ ${message}`),
|
|
20273
|
-
debug: (message) => {
|
|
20274
|
-
if (process.env.DEBUG) {
|
|
20275
|
-
console.log(`\uD83D\uDC1B ${message}`);
|
|
20276
|
-
}
|
|
20277
|
-
},
|
|
20278
|
-
success: (message) => console.log(`✅ ${message}`)
|
|
20279
|
-
};
|
|
20280
|
-
}
|
|
20281
|
-
createUtils() {
|
|
20282
|
-
return {
|
|
20283
|
-
toCamelCase: toCamelCase3,
|
|
20284
|
-
toKebabCase: (str) => {
|
|
20285
|
-
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
20286
|
-
},
|
|
20287
|
-
validateAddress: (address) => {
|
|
20288
|
-
return validateStacksAddress(parseContractId(address).address);
|
|
20289
|
-
},
|
|
20290
|
-
parseContractId: (contractId) => {
|
|
20291
|
-
return parseContractId(contractId);
|
|
20292
|
-
},
|
|
20293
|
-
formatCode: async (code) => {
|
|
20294
|
-
const { formatCode: formatCode2 } = await Promise.resolve().then(() => (init_format(), exports_format));
|
|
20295
|
-
return formatCode2(code);
|
|
20296
|
-
},
|
|
20297
|
-
resolvePath: (relativePath) => {
|
|
20298
|
-
return path.resolve(process.cwd(), relativePath);
|
|
20299
|
-
},
|
|
20300
|
-
fileExists: async (filePath) => {
|
|
20301
|
-
try {
|
|
20302
|
-
await fs3.access(filePath);
|
|
20303
|
-
return true;
|
|
20304
|
-
} catch {
|
|
20305
|
-
return false;
|
|
20306
|
-
}
|
|
20307
|
-
},
|
|
20308
|
-
readFile: async (filePath) => {
|
|
20309
|
-
return fs3.readFile(filePath, "utf-8");
|
|
20310
|
-
},
|
|
20311
|
-
writeFile: async (filePath, content) => {
|
|
20312
|
-
await fs3.writeFile(filePath, content, "utf-8");
|
|
20313
|
-
},
|
|
20314
|
-
ensureDir: async (dirPath) => {
|
|
20315
|
-
await fs3.mkdir(dirPath, { recursive: true });
|
|
20316
|
-
}
|
|
20317
|
-
};
|
|
20318
|
-
}
|
|
20319
|
-
}
|
|
20320
|
-
var validateStacksAddress;
|
|
20321
|
-
var init_plugin_manager = __esm(() => {
|
|
20322
|
-
validateStacksAddress = _validateStacksAddress;
|
|
20323
|
-
});
|
|
20324
|
-
|
|
20325
20325
|
// src/utils/clarity-conversion.ts
|
|
20326
20326
|
import {
|
|
20327
20327
|
isAbiBuffer as isAbiBuffer2,
|
|
@@ -20543,6 +20543,23 @@ import {
|
|
|
20543
20543
|
isAbiTuple as isAbiTuple3,
|
|
20544
20544
|
toCamelCase as toCamelCase6
|
|
20545
20545
|
} from "@secondlayer/stacks/clarity";
|
|
20546
|
+
function generateArgsSignature(args) {
|
|
20547
|
+
if (args.length === 0)
|
|
20548
|
+
return "";
|
|
20549
|
+
const argsTypes = args.map((arg) => {
|
|
20550
|
+
const camelName = toCamelCase6(arg.name);
|
|
20551
|
+
return `${camelName}: ${getTypeForArg(arg)}`;
|
|
20552
|
+
}).join("; ");
|
|
20553
|
+
return `args: { ${argsTypes} }, `;
|
|
20554
|
+
}
|
|
20555
|
+
function generateClarityArgs(args) {
|
|
20556
|
+
if (args.length === 0)
|
|
20557
|
+
return "";
|
|
20558
|
+
return args.map((arg) => {
|
|
20559
|
+
const argName = `args.${toCamelCase6(arg.name)}`;
|
|
20560
|
+
return generateClarityConversion(argName, arg);
|
|
20561
|
+
}).join(", ");
|
|
20562
|
+
}
|
|
20546
20563
|
function generateMapKeyConversion(keyType) {
|
|
20547
20564
|
if (isAbiTuple3(keyType)) {
|
|
20548
20565
|
const fields = keyType.tuple.map((field) => {
|
|
@@ -20958,6 +20975,9 @@ function validateConfig(config) {
|
|
|
20958
20975
|
throw new Error("Config plugins must be an array");
|
|
20959
20976
|
}
|
|
20960
20977
|
}
|
|
20978
|
+
function defineConfig(configOrDefiner) {
|
|
20979
|
+
return configOrDefiner;
|
|
20980
|
+
}
|
|
20961
20981
|
var CONFIG_FILE_NAMES;
|
|
20962
20982
|
var init_config2 = __esm(() => {
|
|
20963
20983
|
init_plugin_manager();
|
|
@@ -32410,7 +32430,7 @@ var {
|
|
|
32410
32430
|
// package.json
|
|
32411
32431
|
var package_default = {
|
|
32412
32432
|
name: "@secondlayer/cli",
|
|
32413
|
-
version: "3.3.
|
|
32433
|
+
version: "3.3.2",
|
|
32414
32434
|
description: "CLI for subgraphs and blockchain indexing on Stacks",
|
|
32415
32435
|
type: "module",
|
|
32416
32436
|
bin: {
|
|
@@ -32454,9 +32474,9 @@ var package_default = {
|
|
|
32454
32474
|
"@inquirer/prompts": "^8.2.0",
|
|
32455
32475
|
"@secondlayer/bundler": "^0.3.1",
|
|
32456
32476
|
"@secondlayer/sdk": "^3.1.0",
|
|
32457
|
-
"@secondlayer/shared": "^4.1.
|
|
32458
|
-
"@secondlayer/stacks": "^
|
|
32459
|
-
"@secondlayer/subgraphs": "^1.
|
|
32477
|
+
"@secondlayer/shared": "^4.1.1",
|
|
32478
|
+
"@secondlayer/stacks": "^2.0.0",
|
|
32479
|
+
"@secondlayer/subgraphs": "^1.2.0",
|
|
32460
32480
|
"@biomejs/js-api": "^0.7.0",
|
|
32461
32481
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
32462
32482
|
esbuild: "^0.19.0",
|
|
@@ -32632,13 +32652,13 @@ async function detectRunningContainers() {
|
|
|
32632
32652
|
return null;
|
|
32633
32653
|
}
|
|
32634
32654
|
const container = inspectData[0];
|
|
32635
|
-
const
|
|
32636
|
-
if (!
|
|
32655
|
+
const path2 = await extractPathFromMounts(container);
|
|
32656
|
+
if (!path2) {
|
|
32637
32657
|
return null;
|
|
32638
32658
|
}
|
|
32639
32659
|
const network = detectNetworkFromContainer(container);
|
|
32640
32660
|
return {
|
|
32641
|
-
path,
|
|
32661
|
+
path: path2,
|
|
32642
32662
|
network,
|
|
32643
32663
|
running: true,
|
|
32644
32664
|
source: "container"
|
|
@@ -32689,8 +32709,8 @@ async function findDockerComposeRoot(startPath) {
|
|
|
32689
32709
|
}
|
|
32690
32710
|
return getParentPath(startPath);
|
|
32691
32711
|
}
|
|
32692
|
-
function getParentPath(
|
|
32693
|
-
const parts =
|
|
32712
|
+
function getParentPath(path2) {
|
|
32713
|
+
const parts = path2.split("/").filter(Boolean);
|
|
32694
32714
|
parts.pop();
|
|
32695
32715
|
return "/" + parts.join("/");
|
|
32696
32716
|
}
|
|
@@ -32732,17 +32752,17 @@ async function scanFilesystemPaths() {
|
|
|
32732
32752
|
const checkedPaths = new Set;
|
|
32733
32753
|
for (const pattern of SEARCH_PATTERNS) {
|
|
32734
32754
|
const paths = await expandGlobPattern(pattern);
|
|
32735
|
-
for (const
|
|
32736
|
-
if (checkedPaths.has(
|
|
32755
|
+
for (const path2 of paths) {
|
|
32756
|
+
if (checkedPaths.has(path2))
|
|
32737
32757
|
continue;
|
|
32738
|
-
checkedPaths.add(
|
|
32739
|
-
const isValid = await isValidStacksNodeDir(
|
|
32758
|
+
checkedPaths.add(path2);
|
|
32759
|
+
const isValid = await isValidStacksNodeDir(path2);
|
|
32740
32760
|
if (!isValid)
|
|
32741
32761
|
continue;
|
|
32742
|
-
const network = await detectNetworkFromFilesystem(
|
|
32743
|
-
const running = await isComposeProjectRunning(
|
|
32762
|
+
const network = await detectNetworkFromFilesystem(path2);
|
|
32763
|
+
const running = await isComposeProjectRunning(path2);
|
|
32744
32764
|
nodes.push({
|
|
32745
|
-
path,
|
|
32765
|
+
path: path2,
|
|
32746
32766
|
network,
|
|
32747
32767
|
running,
|
|
32748
32768
|
source: "filesystem"
|
|
@@ -32763,14 +32783,14 @@ async function expandGlobPattern(pattern) {
|
|
|
32763
32783
|
return [];
|
|
32764
32784
|
}
|
|
32765
32785
|
}
|
|
32766
|
-
async function isValidStacksNodeDir(
|
|
32767
|
-
const dirName =
|
|
32786
|
+
async function isValidStacksNodeDir(path2) {
|
|
32787
|
+
const dirName = path2.split("/").filter(Boolean).pop() ?? "";
|
|
32768
32788
|
if (dirName.includes("stacks-blockchain") || dirName.includes("stacks-node")) {
|
|
32769
32789
|
return true;
|
|
32770
32790
|
}
|
|
32771
32791
|
try {
|
|
32772
|
-
const composeYml = Bun.file(join4(
|
|
32773
|
-
const composeYaml = Bun.file(join4(
|
|
32792
|
+
const composeYml = Bun.file(join4(path2, "docker-compose.yml"));
|
|
32793
|
+
const composeYaml = Bun.file(join4(path2, "docker-compose.yaml"));
|
|
32774
32794
|
const hasCompose = await composeYml.exists() || await composeYaml.exists();
|
|
32775
32795
|
if (!hasCompose) {
|
|
32776
32796
|
return false;
|
|
@@ -32782,8 +32802,8 @@ async function isValidStacksNodeDir(path) {
|
|
|
32782
32802
|
return false;
|
|
32783
32803
|
}
|
|
32784
32804
|
}
|
|
32785
|
-
async function detectNetworkFromFilesystem(
|
|
32786
|
-
const envFile = Bun.file(join4(
|
|
32805
|
+
async function detectNetworkFromFilesystem(path2) {
|
|
32806
|
+
const envFile = Bun.file(join4(path2, ".env"));
|
|
32787
32807
|
if (await envFile.exists()) {
|
|
32788
32808
|
try {
|
|
32789
32809
|
const content = await envFile.text();
|
|
@@ -32795,25 +32815,25 @@ async function detectNetworkFromFilesystem(path) {
|
|
|
32795
32815
|
}
|
|
32796
32816
|
} catch {}
|
|
32797
32817
|
}
|
|
32798
|
-
const testnetConfig = Bun.file(join4(
|
|
32799
|
-
const mainnetConfig = Bun.file(join4(
|
|
32800
|
-
const activeConfig = Bun.file(join4(
|
|
32818
|
+
const testnetConfig = Bun.file(join4(path2, "configurations/testnet"));
|
|
32819
|
+
const mainnetConfig = Bun.file(join4(path2, "configurations/mainnet"));
|
|
32820
|
+
const activeConfig = Bun.file(join4(path2, "configurations/active"));
|
|
32801
32821
|
if (await activeConfig.exists()) {
|
|
32802
32822
|
try {
|
|
32803
|
-
const result = await Bun.$`readlink ${join4(
|
|
32823
|
+
const result = await Bun.$`readlink ${join4(path2, "configurations/active")}`.quiet().nothrow();
|
|
32804
32824
|
const link = result.stdout.toString().trim();
|
|
32805
32825
|
if (link.includes("testnet"))
|
|
32806
32826
|
return "testnet";
|
|
32807
32827
|
} catch {}
|
|
32808
32828
|
}
|
|
32809
|
-
if (
|
|
32829
|
+
if (path2.toLowerCase().includes("testnet")) {
|
|
32810
32830
|
return "testnet";
|
|
32811
32831
|
}
|
|
32812
32832
|
return "mainnet";
|
|
32813
32833
|
}
|
|
32814
|
-
async function isComposeProjectRunning(
|
|
32834
|
+
async function isComposeProjectRunning(path2) {
|
|
32815
32835
|
try {
|
|
32816
|
-
const result = await Bun.$`docker compose -f ${join4(
|
|
32836
|
+
const result = await Bun.$`docker compose -f ${join4(path2, "docker-compose.yml")} ps -q`.quiet().nothrow();
|
|
32817
32837
|
return result.exitCode === 0 && result.stdout.toString().trim().length > 0;
|
|
32818
32838
|
} catch {
|
|
32819
32839
|
return false;
|
|
@@ -34320,7 +34340,7 @@ function mapType(abiType, nullable) {
|
|
|
34320
34340
|
}
|
|
34321
34341
|
|
|
34322
34342
|
// src/generators/subgraph-scaffold.ts
|
|
34323
|
-
function
|
|
34343
|
+
function toCamelCase2(str) {
|
|
34324
34344
|
return str.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
34325
34345
|
}
|
|
34326
34346
|
async function generateSubgraphScaffold(input2) {
|
|
@@ -34333,7 +34353,7 @@ async function generateSubgraphScaffold(input2) {
|
|
|
34333
34353
|
throw new Error(`No public functions found in ${contractId}`);
|
|
34334
34354
|
}
|
|
34335
34355
|
const sourceEntries = publicFunctions.map((fn) => {
|
|
34336
|
-
const sourceName =
|
|
34356
|
+
const sourceName = toCamelCase2(fn.name);
|
|
34337
34357
|
return ` ${sourceName}: { type: 'contract_call', contractId: '${contractId}', functionName: '${fn.name}' }`;
|
|
34338
34358
|
});
|
|
34339
34359
|
const sourcesBlock = sourceEntries.join(`,
|
|
@@ -34355,7 +34375,7 @@ ${columns || " _placeholder: { type: 'text' }"}
|
|
|
34355
34375
|
const schemaBlock = tables.join(`,
|
|
34356
34376
|
`);
|
|
34357
34377
|
const handlerEntries = publicFunctions.map((fn) => {
|
|
34358
|
-
const sourceName =
|
|
34378
|
+
const sourceName = toCamelCase2(fn.name);
|
|
34359
34379
|
return ` ${sourceName}: async (event, ctx) => {
|
|
34360
34380
|
// TODO: implement ${fn.name} handler
|
|
34361
34381
|
// event.args contains the function arguments
|
|
@@ -34385,12 +34405,12 @@ ${handlersBlock}
|
|
|
34385
34405
|
}
|
|
34386
34406
|
|
|
34387
34407
|
// src/utils/case-conversion.ts
|
|
34388
|
-
import { toCamelCase as
|
|
34408
|
+
import { toCamelCase as toCamelCase3 } from "@secondlayer/stacks/clarity";
|
|
34389
34409
|
function capitalize(str) {
|
|
34390
34410
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
34391
34411
|
}
|
|
34392
34412
|
function toPascalCase(str) {
|
|
34393
|
-
return capitalize(
|
|
34413
|
+
return capitalize(toCamelCase3(str));
|
|
34394
34414
|
}
|
|
34395
34415
|
|
|
34396
34416
|
// src/generators/subgraphs.ts
|
|
@@ -36058,17 +36078,17 @@ function registerInstanceCommand(program2) {
|
|
|
36058
36078
|
handleInstanceError(err, "fetch db access info");
|
|
36059
36079
|
}
|
|
36060
36080
|
});
|
|
36061
|
-
db.command("add-key <path>").description("Upload an SSH public key to the bastion for this instance").action(async (
|
|
36081
|
+
db.command("add-key <path>").description("Upload an SSH public key to the bastion for this instance").action(async (path2) => {
|
|
36062
36082
|
guardOssMode();
|
|
36063
36083
|
let publicKey;
|
|
36064
36084
|
try {
|
|
36065
|
-
publicKey = (await Bun.file(
|
|
36085
|
+
publicKey = (await Bun.file(path2).text()).trim();
|
|
36066
36086
|
} catch (err) {
|
|
36067
|
-
error(`Could not read ${
|
|
36087
|
+
error(`Could not read ${path2}: ${err instanceof Error ? err.message : String(err)}`);
|
|
36068
36088
|
process.exit(1);
|
|
36069
36089
|
}
|
|
36070
36090
|
if (!publicKey) {
|
|
36071
|
-
error(`${
|
|
36091
|
+
error(`${path2} is empty`);
|
|
36072
36092
|
process.exit(1);
|
|
36073
36093
|
}
|
|
36074
36094
|
try {
|
|
@@ -36186,8 +36206,8 @@ function registerProjectCommand(program2) {
|
|
|
36186
36206
|
try {
|
|
36187
36207
|
const res = await httpPlatform("/api/projects", { method: "POST", body: { name } });
|
|
36188
36208
|
success(`Created project ${res.project.name} (${res.project.slug})`);
|
|
36189
|
-
const
|
|
36190
|
-
info(dim(`Bound to this directory → ${
|
|
36209
|
+
const path2 = await writeActiveProject(res.project.slug, process.cwd());
|
|
36210
|
+
info(dim(`Bound to this directory → ${path2}`));
|
|
36191
36211
|
info(dim("Next: sl instance create --plan launch"));
|
|
36192
36212
|
} catch (err) {
|
|
36193
36213
|
handleProjectError(err);
|
|
@@ -36225,9 +36245,9 @@ function registerProjectCommand(program2) {
|
|
|
36225
36245
|
}
|
|
36226
36246
|
handleProjectError(err);
|
|
36227
36247
|
}
|
|
36228
|
-
const
|
|
36248
|
+
const path2 = await writeActiveProject(slug, process.cwd());
|
|
36229
36249
|
success(`Bound to project "${slug}"`);
|
|
36230
|
-
info(dim(`Written to ${
|
|
36250
|
+
info(dim(`Written to ${path2}`));
|
|
36231
36251
|
});
|
|
36232
36252
|
project.command("current").description("Show the active project for this directory").action(async () => {
|
|
36233
36253
|
const config = await loadConfig();
|
|
@@ -36294,5 +36314,5 @@ registerLocalCommand(program);
|
|
|
36294
36314
|
registerAccountCommand(program);
|
|
36295
36315
|
program.parse();
|
|
36296
36316
|
|
|
36297
|
-
//# debugId=
|
|
36317
|
+
//# debugId=6B94E8C4AE7AD17564756E2164756E21
|
|
36298
36318
|
//# sourceMappingURL=cli.js.map
|