@sparkdotfi/abi-cli 0.2.0-20260327.ea3b9dfb → 0.2.0-20260331.c0d582b0
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/src/codegen/codegenModule.js +2 -2
- package/dist/src/codegen/formatGeneratedModule.js +18 -0
- package/dist/types/src/codegen/formatGeneratedModule.d.ts +2 -0
- package/dist/types/src/codegen/formatGeneratedModule.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/src/codegen/formatWithPrettier.js +0 -19
- package/dist/types/src/codegen/formatWithPrettier.d.ts +0 -2
- package/dist/types/src/codegen/formatWithPrettier.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatGeneratedModule } from './formatGeneratedModule.js';
|
|
2
2
|
import { contractSection, eoaSection, importsSection } from './sections.js';
|
|
3
3
|
export function codegenModule(manifest, metadataStore) {
|
|
4
4
|
const options = {
|
|
@@ -11,5 +11,5 @@ export function codegenModule(manifest, metadataStore) {
|
|
|
11
11
|
...Object.keys(manifest.interfaces).map((name) => contractSection(name, metadataStore.getInterface(name), options)),
|
|
12
12
|
];
|
|
13
13
|
const source = sections.join('\n');
|
|
14
|
-
return
|
|
14
|
+
return formatGeneratedModule(source);
|
|
15
15
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { format } from 'oxfmt';
|
|
2
|
+
const OXFMT_OPTIONS = {
|
|
3
|
+
arrowParens: 'always',
|
|
4
|
+
endOfLine: 'lf',
|
|
5
|
+
printWidth: 120,
|
|
6
|
+
semi: false,
|
|
7
|
+
singleQuote: true,
|
|
8
|
+
tabWidth: 2,
|
|
9
|
+
trailingComma: 'all',
|
|
10
|
+
};
|
|
11
|
+
export async function formatGeneratedModule(content) {
|
|
12
|
+
const { code, errors } = await format('contracts-generated.ts', content, OXFMT_OPTIONS);
|
|
13
|
+
if (errors.length > 0) {
|
|
14
|
+
const details = errors.map((error) => error.message).join('\n');
|
|
15
|
+
throw new Error(`Failed to format generated module with oxfmt:\n${details}`);
|
|
16
|
+
}
|
|
17
|
+
return code;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatGeneratedModule.d.ts","sourceRoot":"","sources":["../../../../src/codegen/formatGeneratedModule.ts"],"names":[],"mappings":"AAYA,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkdotfi/abi-cli",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-20260331.c0d582b0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sparkdotfi/spark-app.git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/cli-progress": "^3.11.6",
|
|
40
40
|
"bundle-require": "^5.1.0",
|
|
41
41
|
"cli-progress": "^3.12.0",
|
|
42
|
-
"
|
|
42
|
+
"oxfmt": "^0.42.0",
|
|
43
43
|
"remeda": "^2.30.0",
|
|
44
44
|
"viem": "^2.0.0",
|
|
45
45
|
"zod": "^3.24.0"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import prettier from 'prettier';
|
|
2
|
-
// This code is basically copied from wagmi-cli. Any idea how to improve it?
|
|
3
|
-
// Theoretically, we could not do it at all and rely on repo configured linting.
|
|
4
|
-
// In practice e.g. when I hit ctrl+s in not formatted file - I had a huge lag.
|
|
5
|
-
export async function formatWithPrettier(content) {
|
|
6
|
-
const config = await prettier.resolveConfig(process.cwd());
|
|
7
|
-
return prettier.format(content, {
|
|
8
|
-
arrowParens: 'always',
|
|
9
|
-
endOfLine: 'lf',
|
|
10
|
-
parser: 'typescript',
|
|
11
|
-
printWidth: 120,
|
|
12
|
-
semi: false,
|
|
13
|
-
singleQuote: true,
|
|
14
|
-
tabWidth: 2,
|
|
15
|
-
trailingComma: 'all',
|
|
16
|
-
...config,
|
|
17
|
-
plugins: [],
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatWithPrettier.d.ts","sourceRoot":"","sources":["../../../../src/codegen/formatWithPrettier.ts"],"names":[],"mappings":"AAKA,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAezE"}
|