@clarigen/cli 1.0.0-next.25 → 1.0.0-next.26
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/commands/index.js +22 -14
- package/dist/index.js +22 -14
- package/package.json +2 -2
- package/src/config.ts +2 -0
- package/src/contract.ts +9 -5
- package/src/utils.ts +10 -6
package/dist/commands/index.js
CHANGED
|
@@ -215,7 +215,8 @@ async function getClarinetAccounts(folder) {
|
|
|
215
215
|
// src/config.ts
|
|
216
216
|
var defaultConfigFile = {
|
|
217
217
|
outputDir: "src/clarigen",
|
|
218
|
-
clarinet: "."
|
|
218
|
+
clarinet: ".",
|
|
219
|
+
legacy: false
|
|
219
220
|
};
|
|
220
221
|
function configFilePath(rootPath) {
|
|
221
222
|
return (0, import_path4.resolve)(rootPath, "clarigen.config.json");
|
|
@@ -657,7 +658,8 @@ var generateFilesForContractWithSession = async ({
|
|
|
657
658
|
sessionContract,
|
|
658
659
|
dirName,
|
|
659
660
|
docsPath,
|
|
660
|
-
contractFile
|
|
661
|
+
contractFile,
|
|
662
|
+
legacy = false
|
|
661
663
|
}) => {
|
|
662
664
|
const contractIdentifier = sessionContract.contract_id;
|
|
663
665
|
const [contractAddress, contractName] = contractIdentifier.split(".");
|
|
@@ -679,11 +681,13 @@ var generateFilesForContractWithSession = async ({
|
|
|
679
681
|
dirName
|
|
680
682
|
});
|
|
681
683
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
684
|
+
if (legacy) {
|
|
685
|
+
const outputPath = (0, import_path8.resolve)(outputFolder, dirName || ".", contractName);
|
|
686
|
+
await (0, import_promises7.mkdir)(outputPath, { recursive: true });
|
|
687
|
+
await writeFile((0, import_path8.resolve)(outputPath, "abi.ts"), abiFile);
|
|
688
|
+
await writeFile((0, import_path8.resolve)(outputPath, "index.ts"), indexFile);
|
|
689
|
+
await writeFile((0, import_path8.resolve)(outputPath, "types.ts"), typesFile);
|
|
690
|
+
}
|
|
687
691
|
return {
|
|
688
692
|
abi,
|
|
689
693
|
contractFile,
|
|
@@ -712,17 +716,21 @@ var generateProject = async (projectPath) => {
|
|
|
712
716
|
sessionContract: contract,
|
|
713
717
|
outputFolder,
|
|
714
718
|
docsPath: configFile.docs,
|
|
715
|
-
contractFile
|
|
719
|
+
contractFile,
|
|
720
|
+
legacy: configFile.legacy
|
|
716
721
|
});
|
|
717
722
|
metas.push(meta);
|
|
718
723
|
}
|
|
719
|
-
const indexFile = generateProjectIndexFile(configFile);
|
|
720
724
|
await generateDocsIndex(configFile);
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
725
|
+
if (configFile.legacy) {
|
|
726
|
+
const indexFile = generateProjectIndexFile(configFile);
|
|
727
|
+
const indexPath = (0, import_path9.resolve)(outputFolder, "index.ts");
|
|
728
|
+
await writeFile(indexPath, indexFile);
|
|
729
|
+
}
|
|
730
|
+
const singleFileContents = await generateSingleFile(configFile, metas);
|
|
731
|
+
const singleFile = configFile.legacy ? "single.ts" : "index.ts";
|
|
732
|
+
const singlePath = (0, import_path9.resolve)(outputFolder, singleFile);
|
|
733
|
+
await writeFile(singlePath, singleFileContents);
|
|
726
734
|
await generateDeployments(configFile);
|
|
727
735
|
};
|
|
728
736
|
|
package/dist/index.js
CHANGED
|
@@ -221,7 +221,8 @@ async function getClarinetAccounts(folder) {
|
|
|
221
221
|
// src/config.ts
|
|
222
222
|
var defaultConfigFile = {
|
|
223
223
|
outputDir: "src/clarigen",
|
|
224
|
-
clarinet: "."
|
|
224
|
+
clarinet: ".",
|
|
225
|
+
legacy: false
|
|
225
226
|
};
|
|
226
227
|
function configFilePath(rootPath) {
|
|
227
228
|
return (0, import_path4.resolve)(rootPath, "clarigen.config.json");
|
|
@@ -668,7 +669,8 @@ var generateFilesForContractWithSession = async ({
|
|
|
668
669
|
sessionContract,
|
|
669
670
|
dirName,
|
|
670
671
|
docsPath,
|
|
671
|
-
contractFile
|
|
672
|
+
contractFile,
|
|
673
|
+
legacy = false
|
|
672
674
|
}) => {
|
|
673
675
|
const contractIdentifier = sessionContract.contract_id;
|
|
674
676
|
const [contractAddress, contractName] = contractIdentifier.split(".");
|
|
@@ -690,11 +692,13 @@ var generateFilesForContractWithSession = async ({
|
|
|
690
692
|
dirName
|
|
691
693
|
});
|
|
692
694
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
695
|
+
if (legacy) {
|
|
696
|
+
const outputPath = (0, import_path8.resolve)(outputFolder, dirName || ".", contractName);
|
|
697
|
+
await (0, import_promises7.mkdir)(outputPath, { recursive: true });
|
|
698
|
+
await writeFile((0, import_path8.resolve)(outputPath, "abi.ts"), abiFile);
|
|
699
|
+
await writeFile((0, import_path8.resolve)(outputPath, "index.ts"), indexFile);
|
|
700
|
+
await writeFile((0, import_path8.resolve)(outputPath, "types.ts"), typesFile);
|
|
701
|
+
}
|
|
698
702
|
return {
|
|
699
703
|
abi,
|
|
700
704
|
contractFile,
|
|
@@ -723,17 +727,21 @@ var generateProject = async (projectPath) => {
|
|
|
723
727
|
sessionContract: contract,
|
|
724
728
|
outputFolder,
|
|
725
729
|
docsPath: configFile.docs,
|
|
726
|
-
contractFile
|
|
730
|
+
contractFile,
|
|
731
|
+
legacy: configFile.legacy
|
|
727
732
|
});
|
|
728
733
|
metas.push(meta);
|
|
729
734
|
}
|
|
730
|
-
const indexFile = generateProjectIndexFile(configFile);
|
|
731
735
|
await generateDocsIndex(configFile);
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
736
|
+
if (configFile.legacy) {
|
|
737
|
+
const indexFile = generateProjectIndexFile(configFile);
|
|
738
|
+
const indexPath = (0, import_path9.resolve)(outputFolder, "index.ts");
|
|
739
|
+
await writeFile(indexPath, indexFile);
|
|
740
|
+
}
|
|
741
|
+
const singleFileContents = await generateSingleFile(configFile, metas);
|
|
742
|
+
const singleFile = configFile.legacy ? "single.ts" : "index.ts";
|
|
743
|
+
const singlePath = (0, import_path9.resolve)(outputFolder, singleFile);
|
|
744
|
+
await writeFile(singlePath, singleFileContents);
|
|
737
745
|
await generateDeployments(configFile);
|
|
738
746
|
};
|
|
739
747
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@clarigen/cli",
|
|
3
3
|
"description": "A CLI for generating a Typescript interface for a Clarity contract.",
|
|
4
4
|
"author": "Hank Stoever",
|
|
5
|
-
"version": "1.0.0-next.
|
|
5
|
+
"version": "1.0.0-next.26",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"main": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@clarigen/claridocs": "1.0.0-next.25",
|
|
42
|
-
"@clarigen/core": "1.0.0-next.
|
|
42
|
+
"@clarigen/core": "1.0.0-next.26",
|
|
43
43
|
"@clarigen/native-bin": "1.0.0-next.25",
|
|
44
44
|
"@iarna/toml": "^2.2.5",
|
|
45
45
|
"@oclif/command": "^1.8.0",
|
package/src/config.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface ConfigFileContents {
|
|
|
20
20
|
outputDir: string;
|
|
21
21
|
clarinet: string;
|
|
22
22
|
docs?: string;
|
|
23
|
+
legacy?: boolean;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface ConfigFile extends ConfigFileContents {
|
|
@@ -32,6 +33,7 @@ export interface ConfigFile extends ConfigFileContents {
|
|
|
32
33
|
export const defaultConfigFile: ConfigFileContents = {
|
|
33
34
|
outputDir: 'src/clarigen',
|
|
34
35
|
clarinet: '.',
|
|
36
|
+
legacy: false,
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
export function configFilePath(rootPath: string) {
|
package/src/contract.ts
CHANGED
|
@@ -16,12 +16,14 @@ export const generateFilesForContractWithSession = async ({
|
|
|
16
16
|
dirName,
|
|
17
17
|
docsPath,
|
|
18
18
|
contractFile,
|
|
19
|
+
legacy = false,
|
|
19
20
|
}: {
|
|
20
21
|
outputFolder: string;
|
|
21
22
|
sessionContract: SessionContract;
|
|
22
23
|
dirName?: string;
|
|
23
24
|
docsPath?: string;
|
|
24
25
|
contractFile: string;
|
|
26
|
+
legacy?: boolean;
|
|
25
27
|
}): Promise<ContractMeta> => {
|
|
26
28
|
const contractIdentifier = sessionContract.contract_id;
|
|
27
29
|
const [contractAddress, contractName] = contractIdentifier.split('.');
|
|
@@ -47,12 +49,14 @@ export const generateFilesForContractWithSession = async ({
|
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (legacy) {
|
|
53
|
+
const outputPath = resolve(outputFolder, dirName || '.', contractName);
|
|
54
|
+
await mkdir(outputPath, { recursive: true });
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
await writeFile(resolve(outputPath, 'abi.ts'), abiFile);
|
|
57
|
+
await writeFile(resolve(outputPath, 'index.ts'), indexFile);
|
|
58
|
+
await writeFile(resolve(outputPath, 'types.ts'), typesFile);
|
|
59
|
+
}
|
|
56
60
|
|
|
57
61
|
return {
|
|
58
62
|
abi,
|
package/src/utils.ts
CHANGED
|
@@ -124,18 +124,22 @@ export const generateProject = async (projectPath: string) => {
|
|
|
124
124
|
outputFolder,
|
|
125
125
|
docsPath: configFile.docs,
|
|
126
126
|
contractFile,
|
|
127
|
+
legacy: configFile.legacy,
|
|
127
128
|
});
|
|
128
129
|
metas.push(meta);
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
const indexFile = generateProjectIndexFile(configFile);
|
|
132
132
|
await generateDocsIndex(configFile);
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
if (configFile.legacy) {
|
|
135
|
+
const indexFile = generateProjectIndexFile(configFile);
|
|
136
|
+
const indexPath = resolve(outputFolder, 'index.ts');
|
|
137
|
+
await writeFile(indexPath, indexFile);
|
|
138
|
+
}
|
|
136
139
|
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
+
const singleFileContents = await generateSingleFile(configFile, metas);
|
|
141
|
+
const singleFile = configFile.legacy ? 'single.ts' : 'index.ts';
|
|
142
|
+
const singlePath = resolve(outputFolder, singleFile);
|
|
143
|
+
await writeFile(singlePath, singleFileContents);
|
|
140
144
|
await generateDeployments(configFile);
|
|
141
145
|
};
|