@haneullabs/codegen 0.1.0
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/CHANGELOG.md +259 -0
- package/README.md +195 -0
- package/dist/cjs/bin/bash-complete.d.ts +2 -0
- package/dist/cjs/bin/bash-complete.js +51 -0
- package/dist/cjs/bin/bash-complete.js.map +7 -0
- package/dist/cjs/bin/cli.d.ts +2 -0
- package/dist/cjs/bin/cli.js +34 -0
- package/dist/cjs/bin/cli.js.map +7 -0
- package/dist/cjs/cli/cli.d.ts +1 -0
- package/dist/cjs/cli/cli.js +49 -0
- package/dist/cjs/cli/cli.js.map +7 -0
- package/dist/cjs/cli/commands/generate/command.d.ts +1 -0
- package/dist/cjs/cli/commands/generate/command.js +80 -0
- package/dist/cjs/cli/commands/generate/command.js.map +7 -0
- package/dist/cjs/cli/commands/generate/impl.d.ts +8 -0
- package/dist/cjs/cli/commands/generate/impl.js +66 -0
- package/dist/cjs/cli/commands/generate/impl.js.map +7 -0
- package/dist/cjs/cli/context.d.ts +6 -0
- package/dist/cjs/cli/context.js +45 -0
- package/dist/cjs/cli/context.js.map +7 -0
- package/dist/cjs/config.d.ts +51 -0
- package/dist/cjs/config.js +75 -0
- package/dist/cjs/config.js.map +7 -0
- package/dist/cjs/file-builder.d.ts +13 -0
- package/dist/cjs/file-builder.js +83 -0
- package/dist/cjs/file-builder.js.map +7 -0
- package/dist/cjs/generate-utils.d.ts +1 -0
- package/dist/cjs/generate-utils.js +187 -0
- package/dist/cjs/generate-utils.js.map +7 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +124 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/move-module-builder.d.ts +26 -0
- package/dist/cjs/move-module-builder.js +464 -0
- package/dist/cjs/move-module-builder.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/render-types.d.ts +19 -0
- package/dist/cjs/render-types.js +313 -0
- package/dist/cjs/render-types.js.map +7 -0
- package/dist/cjs/summary.d.ts +3 -0
- package/dist/cjs/summary.js +218 -0
- package/dist/cjs/summary.js.map +7 -0
- package/dist/cjs/types/deserialized.d.ts +89 -0
- package/dist/cjs/types/deserialized.js +17 -0
- package/dist/cjs/types/deserialized.js.map +7 -0
- package/dist/cjs/types/summary.d.ts +105 -0
- package/dist/cjs/types/summary.js +17 -0
- package/dist/cjs/types/summary.js.map +7 -0
- package/dist/cjs/utils.d.ts +22 -0
- package/dist/cjs/utils.js +164 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/bin/bash-complete.d.ts +2 -0
- package/dist/esm/bin/bash-complete.js +31 -0
- package/dist/esm/bin/bash-complete.js.map +7 -0
- package/dist/esm/bin/cli.d.ts +2 -0
- package/dist/esm/bin/cli.js +32 -0
- package/dist/esm/bin/cli.js.map +7 -0
- package/dist/esm/cli/cli.d.ts +1 -0
- package/dist/esm/cli/cli.js +29 -0
- package/dist/esm/cli/cli.js.map +7 -0
- package/dist/esm/cli/commands/generate/command.d.ts +1 -0
- package/dist/esm/cli/commands/generate/command.js +50 -0
- package/dist/esm/cli/commands/generate/command.js.map +7 -0
- package/dist/esm/cli/commands/generate/impl.d.ts +8 -0
- package/dist/esm/cli/commands/generate/impl.js +46 -0
- package/dist/esm/cli/commands/generate/impl.js.map +7 -0
- package/dist/esm/cli/context.d.ts +6 -0
- package/dist/esm/cli/context.js +15 -0
- package/dist/esm/cli/context.js.map +7 -0
- package/dist/esm/config.d.ts +51 -0
- package/dist/esm/config.js +45 -0
- package/dist/esm/config.js.map +7 -0
- package/dist/esm/file-builder.d.ts +13 -0
- package/dist/esm/file-builder.js +63 -0
- package/dist/esm/file-builder.js.map +7 -0
- package/dist/esm/generate-utils.d.ts +1 -0
- package/dist/esm/generate-utils.js +167 -0
- package/dist/esm/generate-utils.js.map +7 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +104 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/move-module-builder.d.ts +26 -0
- package/dist/esm/move-module-builder.js +457 -0
- package/dist/esm/move-module-builder.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/render-types.d.ts +19 -0
- package/dist/esm/render-types.js +293 -0
- package/dist/esm/render-types.js.map +7 -0
- package/dist/esm/summary.d.ts +3 -0
- package/dist/esm/summary.js +198 -0
- package/dist/esm/summary.js.map +7 -0
- package/dist/esm/types/deserialized.d.ts +89 -0
- package/dist/esm/types/deserialized.js +1 -0
- package/dist/esm/types/deserialized.js.map +7 -0
- package/dist/esm/types/summary.d.ts +105 -0
- package/dist/esm/types/summary.js +1 -0
- package/dist/esm/types/summary.js.map +7 -0
- package/dist/esm/utils.d.ts +22 -0
- package/dist/esm/utils.js +134 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +70 -0
- package/src/bin/bash-complete.ts +35 -0
- package/src/bin/cli.ts +40 -0
- package/src/cli/cli.ts +29 -0
- package/src/cli/commands/generate/command.ts +50 -0
- package/src/cli/commands/generate/impl.ts +66 -0
- package/src/cli/context.ts +21 -0
- package/src/config.ts +54 -0
- package/src/file-builder.ts +74 -0
- package/src/generate-utils.ts +163 -0
- package/src/index.ts +131 -0
- package/src/move-module-builder.ts +599 -0
- package/src/render-types.ts +349 -0
- package/src/summary.ts +242 -0
- package/src/types/deserialized.ts +107 -0
- package/src/types/summary.ts +144 -0
- package/src/utils.ts +180 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type TypeSignature = 'U8' | 'U16' | 'U32' | 'U64' | 'U128' | 'U256' | 'Address' | 'Bool' | {
|
|
2
|
+
Datatype: number;
|
|
3
|
+
} | {
|
|
4
|
+
DatatypeInstantiation: [number, TypeSignature[]];
|
|
5
|
+
} | {
|
|
6
|
+
Vector: TypeSignature;
|
|
7
|
+
} | {
|
|
8
|
+
TypeParameter: number;
|
|
9
|
+
} | {
|
|
10
|
+
Reference: TypeSignature;
|
|
11
|
+
} | {
|
|
12
|
+
MutableReference: TypeSignature;
|
|
13
|
+
};
|
|
14
|
+
export interface DeserializedModule {
|
|
15
|
+
version: number;
|
|
16
|
+
self_module_handle_idx: number;
|
|
17
|
+
module_handles: Array<{
|
|
18
|
+
name: number;
|
|
19
|
+
address: number;
|
|
20
|
+
}>;
|
|
21
|
+
datatype_handles: Array<{
|
|
22
|
+
name: number;
|
|
23
|
+
module: number;
|
|
24
|
+
abilities: number;
|
|
25
|
+
type_parameters: Array<{
|
|
26
|
+
constraints: number;
|
|
27
|
+
is_phantom: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|
|
30
|
+
function_handles: Array<{
|
|
31
|
+
module: number;
|
|
32
|
+
name: number;
|
|
33
|
+
parameters: number;
|
|
34
|
+
return_: number;
|
|
35
|
+
type_parameters: Array<{
|
|
36
|
+
constraints: number;
|
|
37
|
+
is_phantom: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
field_handles: Array<{
|
|
41
|
+
owner: number;
|
|
42
|
+
field: number;
|
|
43
|
+
}>;
|
|
44
|
+
friend_decls: Array<unknown>;
|
|
45
|
+
struct_def_instantiations: Array<unknown>;
|
|
46
|
+
function_instantiations: Array<unknown>;
|
|
47
|
+
field_instantiations: Array<unknown>;
|
|
48
|
+
signatures: Array<Array<TypeSignature>>;
|
|
49
|
+
identifiers: Array<string>;
|
|
50
|
+
address_identifiers: Array<string>;
|
|
51
|
+
constant_pool: Array<{
|
|
52
|
+
type_: TypeSignature;
|
|
53
|
+
data: Array<number>;
|
|
54
|
+
}>;
|
|
55
|
+
metadata: Array<unknown>;
|
|
56
|
+
struct_defs: Array<{
|
|
57
|
+
struct_handle: number;
|
|
58
|
+
field_information: {
|
|
59
|
+
Declared?: Array<{
|
|
60
|
+
name: number;
|
|
61
|
+
signature: TypeSignature;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
function_defs: Array<{
|
|
66
|
+
function: number;
|
|
67
|
+
visibility: 'Public' | 'Private' | 'Friend';
|
|
68
|
+
is_entry: boolean;
|
|
69
|
+
acquires_global_resources: Array<unknown>;
|
|
70
|
+
flags: number;
|
|
71
|
+
code: unknown;
|
|
72
|
+
}>;
|
|
73
|
+
enum_defs: Array<{
|
|
74
|
+
enum_handle: number;
|
|
75
|
+
variants: Array<{
|
|
76
|
+
variant_name: number;
|
|
77
|
+
fields: Array<{
|
|
78
|
+
name: number;
|
|
79
|
+
signature: TypeSignature;
|
|
80
|
+
}>;
|
|
81
|
+
}>;
|
|
82
|
+
}>;
|
|
83
|
+
enum_def_instantiations: Array<unknown>;
|
|
84
|
+
variant_handles: Array<{
|
|
85
|
+
enum_def: number;
|
|
86
|
+
variant: number;
|
|
87
|
+
}>;
|
|
88
|
+
variant_instantiation_handles: Array<unknown>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var deserialized_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(deserialized_exports);
|
|
17
|
+
//# sourceMappingURL=deserialized.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/deserialized.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport type TypeSignature =\n\t| 'U8'\n\t| 'U16'\n\t| 'U32'\n\t| 'U64'\n\t| 'U128'\n\t| 'U256'\n\t| 'Address'\n\t| 'Bool'\n\t| {\n\t\t\tDatatype: number;\n\t }\n\t| {\n\t\t\tDatatypeInstantiation: [number, TypeSignature[]];\n\t }\n\t| {\n\t\t\tVector: TypeSignature;\n\t }\n\t| {\n\t\t\tTypeParameter: number;\n\t }\n\t| {\n\t\t\tReference: TypeSignature;\n\t }\n\t| {\n\t\t\tMutableReference: TypeSignature;\n\t };\n\nexport interface DeserializedModule {\n\tversion: number;\n\tself_module_handle_idx: number;\n\tmodule_handles: Array<{\n\t\tname: number;\n\t\taddress: number;\n\t}>;\n\tdatatype_handles: Array<{\n\t\tname: number;\n\t\tmodule: number;\n\t\tabilities: number;\n\t\ttype_parameters: Array<{\n\t\t\tconstraints: number;\n\t\t\tis_phantom: boolean;\n\t\t}>;\n\t}>;\n\tfunction_handles: Array<{\n\t\tmodule: number;\n\t\tname: number;\n\t\tparameters: number;\n\t\treturn_: number;\n\t\ttype_parameters: Array<{\n\t\t\tconstraints: number;\n\t\t\tis_phantom: boolean;\n\t\t}>;\n\t}>;\n\tfield_handles: Array<{\n\t\towner: number;\n\t\tfield: number;\n\t}>;\n\tfriend_decls: Array<unknown>;\n\tstruct_def_instantiations: Array<unknown>;\n\tfunction_instantiations: Array<unknown>;\n\tfield_instantiations: Array<unknown>;\n\tsignatures: Array<Array<TypeSignature>>;\n\tidentifiers: Array<string>;\n\taddress_identifiers: Array<string>;\n\tconstant_pool: Array<{\n\t\ttype_: TypeSignature;\n\t\tdata: Array<number>;\n\t}>;\n\tmetadata: Array<unknown>;\n\tstruct_defs: Array<{\n\t\tstruct_handle: number;\n\t\tfield_information: {\n\t\t\tDeclared?: Array<{\n\t\t\t\tname: number;\n\t\t\t\tsignature: TypeSignature;\n\t\t\t}>;\n\t\t};\n\t}>;\n\tfunction_defs: Array<{\n\t\tfunction: number;\n\t\tvisibility: 'Public' | 'Private' | 'Friend';\n\t\tis_entry: boolean;\n\t\tacquires_global_resources: Array<unknown>;\n\t\tflags: number;\n\t\tcode: unknown;\n\t}>;\n\tenum_defs: Array<{\n\t\tenum_handle: number;\n\t\tvariants: Array<{\n\t\t\tvariant_name: number;\n\t\t\tfields: Array<{\n\t\t\t\tname: number;\n\t\t\t\tsignature: TypeSignature;\n\t\t\t}>;\n\t\t}>;\n\t}>;\n\tenum_def_instantiations: Array<unknown>;\n\tvariant_handles: Array<{\n\t\tenum_def: number;\n\t\tvariant: number;\n\t}>;\n\tvariant_instantiation_handles: Array<unknown>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export interface ModuleSummary {
|
|
2
|
+
id: {
|
|
3
|
+
address: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
doc?: string | null;
|
|
7
|
+
immediate_dependencies: {
|
|
8
|
+
address: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}[];
|
|
11
|
+
attributes?: Attribute[];
|
|
12
|
+
functions: Record<string, FunctionSummary>;
|
|
13
|
+
structs: Record<string, StructSummary>;
|
|
14
|
+
enums: Record<string, EnumSummary>;
|
|
15
|
+
}
|
|
16
|
+
export type Attribute = {
|
|
17
|
+
Name: string;
|
|
18
|
+
} | {
|
|
19
|
+
Assigned: [string, string];
|
|
20
|
+
} | {
|
|
21
|
+
Parameterized: [string, Attribute[]];
|
|
22
|
+
};
|
|
23
|
+
export interface FunctionSummary {
|
|
24
|
+
source_index?: number;
|
|
25
|
+
index: number;
|
|
26
|
+
doc?: string | null;
|
|
27
|
+
attributes?: Attribute[];
|
|
28
|
+
visibility: FunctionVisibility;
|
|
29
|
+
entry: boolean;
|
|
30
|
+
macro_?: boolean;
|
|
31
|
+
type_parameters: DatatypeParameter[];
|
|
32
|
+
parameters: Parameter[];
|
|
33
|
+
return_: Type[];
|
|
34
|
+
}
|
|
35
|
+
export interface StructSummary {
|
|
36
|
+
index: number;
|
|
37
|
+
doc?: string | null;
|
|
38
|
+
attributes?: Attribute[];
|
|
39
|
+
abilities: Ability[];
|
|
40
|
+
type_parameters: DatatypeParameter[];
|
|
41
|
+
fields: Fields;
|
|
42
|
+
}
|
|
43
|
+
export interface EnumSummary {
|
|
44
|
+
index: number;
|
|
45
|
+
doc?: string | null;
|
|
46
|
+
attributes?: Attribute[];
|
|
47
|
+
abilities: Ability[];
|
|
48
|
+
type_parameters: DatatypeParameter[];
|
|
49
|
+
variants: Record<string, Variant>;
|
|
50
|
+
}
|
|
51
|
+
export interface Variant {
|
|
52
|
+
index: number;
|
|
53
|
+
doc?: string | null;
|
|
54
|
+
fields: Fields;
|
|
55
|
+
}
|
|
56
|
+
export interface Fields {
|
|
57
|
+
positional_fields: boolean;
|
|
58
|
+
fields: Record<string, Field>;
|
|
59
|
+
}
|
|
60
|
+
export interface Field {
|
|
61
|
+
index: number;
|
|
62
|
+
doc?: string | null;
|
|
63
|
+
type_: Type;
|
|
64
|
+
}
|
|
65
|
+
export interface TypeParameter {
|
|
66
|
+
name?: string;
|
|
67
|
+
constraints: Ability[];
|
|
68
|
+
}
|
|
69
|
+
export interface DatatypeParameter extends TypeParameter {
|
|
70
|
+
phantom: boolean;
|
|
71
|
+
}
|
|
72
|
+
export type Ability = 'Drop' | 'Copy' | 'Key' | 'Store';
|
|
73
|
+
export interface Parameter {
|
|
74
|
+
name?: string;
|
|
75
|
+
type_: Type;
|
|
76
|
+
}
|
|
77
|
+
export type Type = 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'address' | 'signer' | '_' | {
|
|
78
|
+
Datatype: Datatype;
|
|
79
|
+
} | {
|
|
80
|
+
vector: Type;
|
|
81
|
+
} | {
|
|
82
|
+
Reference: [boolean, Type];
|
|
83
|
+
} | {
|
|
84
|
+
TypeParameter: number;
|
|
85
|
+
} | {
|
|
86
|
+
NamedTypeParameter: string;
|
|
87
|
+
} | {
|
|
88
|
+
tuple: Type[];
|
|
89
|
+
} | {
|
|
90
|
+
fun: [Type[], Type];
|
|
91
|
+
};
|
|
92
|
+
export interface Datatype {
|
|
93
|
+
module: ModuleId;
|
|
94
|
+
name: string;
|
|
95
|
+
type_arguments: TypeArgument[];
|
|
96
|
+
}
|
|
97
|
+
export interface TypeArgument {
|
|
98
|
+
phantom: boolean;
|
|
99
|
+
argument: Type;
|
|
100
|
+
}
|
|
101
|
+
export interface ModuleId {
|
|
102
|
+
address: string;
|
|
103
|
+
name: string;
|
|
104
|
+
}
|
|
105
|
+
export type FunctionVisibility = 'Public' | 'Friend' | 'Package' | 'Private';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var summary_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(summary_exports);
|
|
17
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/summary.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface ModuleSummary {\n\tid: {\n\t\taddress: string;\n\t\tname: string;\n\t};\n\tdoc?: string | null;\n\timmediate_dependencies: {\n\t\taddress: string;\n\t\tname: string;\n\t}[];\n\tattributes?: Attribute[];\n\tfunctions: Record<string, FunctionSummary>;\n\tstructs: Record<string, StructSummary>;\n\tenums: Record<string, EnumSummary>;\n}\n\nexport type Attribute =\n\t| {\n\t\t\tName: string;\n\t }\n\t| {\n\t\t\tAssigned: [string, string];\n\t }\n\t| {\n\t\t\tParameterized: [string, Attribute[]];\n\t };\n\nexport interface FunctionSummary {\n\tsource_index?: number;\n\tindex: number;\n\tdoc?: string | null;\n\tattributes?: Attribute[];\n\tvisibility: FunctionVisibility;\n\tentry: boolean;\n\tmacro_?: boolean;\n\ttype_parameters: DatatypeParameter[];\n\tparameters: Parameter[];\n\treturn_: Type[];\n}\n\nexport interface StructSummary {\n\tindex: number;\n\tdoc?: string | null;\n\tattributes?: Attribute[];\n\tabilities: Ability[];\n\ttype_parameters: DatatypeParameter[];\n\tfields: Fields;\n}\n\nexport interface EnumSummary {\n\tindex: number;\n\tdoc?: string | null;\n\tattributes?: Attribute[];\n\tabilities: Ability[];\n\ttype_parameters: DatatypeParameter[];\n\tvariants: Record<string, Variant>;\n}\n\nexport interface Variant {\n\tindex: number;\n\tdoc?: string | null;\n\tfields: Fields;\n}\n\nexport interface Fields {\n\tpositional_fields: boolean;\n\tfields: Record<string, Field>;\n}\n\nexport interface Field {\n\tindex: number;\n\tdoc?: string | null;\n\ttype_: Type;\n}\n\nexport interface TypeParameter {\n\tname?: string;\n\tconstraints: Ability[];\n}\n\nexport interface DatatypeParameter extends TypeParameter {\n\tphantom: boolean;\n}\n\nexport type Ability = 'Drop' | 'Copy' | 'Key' | 'Store';\n\nexport interface Parameter {\n\tname?: string;\n\ttype_: Type;\n}\n\nexport type Type =\n\t| 'bool'\n\t| 'u8'\n\t| 'u16'\n\t| 'u32'\n\t| 'u64'\n\t| 'u128'\n\t| 'u256'\n\t| 'address'\n\t| 'signer'\n\t| '_'\n\t| {\n\t\t\tDatatype: Datatype;\n\t }\n\t| {\n\t\t\tvector: Type;\n\t }\n\t| {\n\t\t\tReference: [boolean, Type];\n\t }\n\t| {\n\t\t\tTypeParameter: number;\n\t }\n\t| {\n\t\t\tNamedTypeParameter: string;\n\t }\n\t| {\n\t\t\ttuple: Type[];\n\t }\n\t| {\n\t\t\tfun: [Type[], Type];\n\t };\n\nexport interface Datatype {\n\tmodule: ModuleId;\n\tname: string;\n\ttype_arguments: TypeArgument[];\n}\n\nexport interface TypeArgument {\n\tphantom: boolean;\n\targument: Type;\n}\n\nexport interface ModuleId {\n\taddress: string;\n\tname: string;\n}\n\nexport type FunctionVisibility = 'Public' | 'Friend' | 'Package' | 'Private';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { Type } from './types/summary.js';
|
|
3
|
+
export declare function printNodes(...nodes: ts.Node[]): string;
|
|
4
|
+
type TSTemplateValue = string | number | boolean | ts.Statement[] | ts.Expression;
|
|
5
|
+
export declare function parseTS(strings: TemplateStringsArray, ...values: TSTemplateValue[]): ts.Statement[];
|
|
6
|
+
export declare function mapToObject<T>({ items, mapper, getComment, }: {
|
|
7
|
+
items: Iterable<T>;
|
|
8
|
+
mapper: (item: T) => Promise<null | [string, TSTemplateValue]> | null | [string, TSTemplateValue];
|
|
9
|
+
getComment?: (item: T) => string | null | undefined;
|
|
10
|
+
}): Promise<ts.ObjectLiteralExpression>;
|
|
11
|
+
export declare function withComment<T extends ts.Node | ts.Node[]>(options: {
|
|
12
|
+
comment?: string | null;
|
|
13
|
+
doc?: never;
|
|
14
|
+
} | {
|
|
15
|
+
doc?: string | null | undefined;
|
|
16
|
+
comment?: never;
|
|
17
|
+
}, nodes: T): Promise<T>;
|
|
18
|
+
export declare function formatComment(text: string): Promise<string>;
|
|
19
|
+
export declare function camelCase(str: string): string;
|
|
20
|
+
export declare function capitalize(str: string): string;
|
|
21
|
+
export declare function isWellKnownObjectParameter(type: Type, resolveAddress: (address: string) => string): boolean;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var utils_exports = {};
|
|
30
|
+
__export(utils_exports, {
|
|
31
|
+
camelCase: () => camelCase,
|
|
32
|
+
capitalize: () => capitalize,
|
|
33
|
+
formatComment: () => formatComment,
|
|
34
|
+
isWellKnownObjectParameter: () => isWellKnownObjectParameter,
|
|
35
|
+
mapToObject: () => mapToObject,
|
|
36
|
+
parseTS: () => parseTS,
|
|
37
|
+
printNodes: () => printNodes,
|
|
38
|
+
withComment: () => withComment
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(utils_exports);
|
|
41
|
+
var import_prettier = require("prettier");
|
|
42
|
+
var import_typescript = __toESM(require("typescript"));
|
|
43
|
+
var import_render_types = require("./render-types.js");
|
|
44
|
+
function printNodes(...nodes) {
|
|
45
|
+
const printer = import_typescript.default.createPrinter({
|
|
46
|
+
removeComments: false
|
|
47
|
+
});
|
|
48
|
+
return nodes.map((node) => printer.printNode(import_typescript.default.EmitHint.Unspecified, node, node.getSourceFile())).join("\n");
|
|
49
|
+
}
|
|
50
|
+
function parseTS(strings, ...values) {
|
|
51
|
+
const source = strings.reduce((acc, str, i) => {
|
|
52
|
+
if (typeof values[i] === "object") {
|
|
53
|
+
if (Array.isArray(values[i])) {
|
|
54
|
+
return `${acc}${str}${printNodes(...values[i])}`;
|
|
55
|
+
}
|
|
56
|
+
return `${acc}${str}${printNodes(values[i])}`;
|
|
57
|
+
}
|
|
58
|
+
return `${acc}${str}${values[i] ?? ""}`;
|
|
59
|
+
}, "");
|
|
60
|
+
const lines = source.replace(/^\s/m, "").split("\n");
|
|
61
|
+
const firstLine = lines[0];
|
|
62
|
+
const indent = firstLine.match(/^\s*/)?.[0] ?? "";
|
|
63
|
+
const unIndented = lines.map((line) => line.replace(indent, "")).join("\n");
|
|
64
|
+
const sourceFile = import_typescript.default.createSourceFile("file.ts", unIndented, import_typescript.default.ScriptTarget.Latest, true);
|
|
65
|
+
return [...sourceFile.statements.values()];
|
|
66
|
+
}
|
|
67
|
+
async function mapToObject({
|
|
68
|
+
items,
|
|
69
|
+
mapper,
|
|
70
|
+
getComment
|
|
71
|
+
}) {
|
|
72
|
+
const fieldProps = await Promise.all(
|
|
73
|
+
(await Promise.all(
|
|
74
|
+
[...items].map(async (item) => {
|
|
75
|
+
const mapped = await mapper(item);
|
|
76
|
+
if (!mapped) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const [key, value] = mapped;
|
|
80
|
+
return [item, key, value];
|
|
81
|
+
})
|
|
82
|
+
)).filter((value) => value !== null).map(([item, key, value]) => {
|
|
83
|
+
const [node] = parseTS`({${key}: ${value}})`;
|
|
84
|
+
if (!import_typescript.default.isExpressionStatement(node)) {
|
|
85
|
+
throw new Error("Expected Expression statement");
|
|
86
|
+
}
|
|
87
|
+
if (!import_typescript.default.isParenthesizedExpression(node.expression)) {
|
|
88
|
+
throw new Error("Expected Parenthesized Expression");
|
|
89
|
+
}
|
|
90
|
+
if (!import_typescript.default.isObjectLiteralExpression(node.expression.expression)) {
|
|
91
|
+
throw new Error("Expected Object Literal Expression");
|
|
92
|
+
}
|
|
93
|
+
const comment = getComment?.(item);
|
|
94
|
+
return withComment({ comment }, node.expression.expression.properties[0]);
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
return import_typescript.default.factory.createObjectLiteralExpression(fieldProps, true);
|
|
98
|
+
}
|
|
99
|
+
async function withComment(options, nodes) {
|
|
100
|
+
const comment = options.comment ?? options.doc;
|
|
101
|
+
if (comment) {
|
|
102
|
+
const firstNode = Array.isArray(nodes) ? nodes[0] : nodes;
|
|
103
|
+
import_typescript.default.addSyntheticLeadingComment(
|
|
104
|
+
firstNode,
|
|
105
|
+
import_typescript.default.SyntaxKind.MultiLineCommentTrivia,
|
|
106
|
+
await formatComment(comment),
|
|
107
|
+
true
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return nodes;
|
|
111
|
+
}
|
|
112
|
+
async function formatComment(text) {
|
|
113
|
+
const lines = (await (0, import_prettier.format)(text, {
|
|
114
|
+
printWidth: 80,
|
|
115
|
+
semi: true,
|
|
116
|
+
singleQuote: true,
|
|
117
|
+
tabWidth: 2,
|
|
118
|
+
trailingComma: "all",
|
|
119
|
+
useTabs: true,
|
|
120
|
+
proseWrap: "always",
|
|
121
|
+
parser: "markdown"
|
|
122
|
+
})).trim().replaceAll("*/", "*\\/").split("\n");
|
|
123
|
+
if (lines.length === 1) return `* ${lines[0]} `;
|
|
124
|
+
return `*
|
|
125
|
+
${lines.map((line) => ` * ${line}`).join("\n")}
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
function camelCase(str) {
|
|
129
|
+
return str.replaceAll(/(?:_)([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
130
|
+
}
|
|
131
|
+
function capitalize(str) {
|
|
132
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
133
|
+
}
|
|
134
|
+
function isWellKnownObjectParameter(type, resolveAddress) {
|
|
135
|
+
if (typeof type === "string") {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if ("Reference" in type) {
|
|
139
|
+
return isWellKnownObjectParameter(type.Reference[1], resolveAddress);
|
|
140
|
+
}
|
|
141
|
+
if (!("Datatype" in type)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
const { Datatype } = type;
|
|
145
|
+
const address = resolveAddress(Datatype.module.address);
|
|
146
|
+
if (address === import_render_types.HANEUL_FRAMEWORK_ADDRESS) {
|
|
147
|
+
if (Datatype.module.name === "deny_list") {
|
|
148
|
+
return Datatype.name === "DenyList";
|
|
149
|
+
}
|
|
150
|
+
if (Datatype.module.name === "random") {
|
|
151
|
+
return Datatype.name === "Random";
|
|
152
|
+
}
|
|
153
|
+
if (Datatype.module.name === "clock") {
|
|
154
|
+
return Datatype.name === "Clock";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (address === import_render_types.HANEUL_SYSTEM_ADDRESS) {
|
|
158
|
+
if (Datatype.module.name === "haneul_system") {
|
|
159
|
+
return Datatype.name === "HaneulSystemState";
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { format } from 'prettier';\nimport ts from 'typescript';\nimport type { Type } from './types/summary.js';\nimport { HANEUL_FRAMEWORK_ADDRESS, HANEUL_SYSTEM_ADDRESS } from './render-types.js';\n\nexport function printNodes(...nodes: ts.Node[]) {\n\tconst printer = ts.createPrinter({\n\t\tremoveComments: false,\n\t});\n\n\treturn nodes\n\t\t.map((node) => printer.printNode(ts.EmitHint.Unspecified, node, node.getSourceFile()))\n\t\t.join('\\n');\n}\n\ntype TSTemplateValue = string | number | boolean | ts.Statement[] | ts.Expression;\n\nexport function parseTS(strings: TemplateStringsArray, ...values: TSTemplateValue[]) {\n\tconst source = strings.reduce((acc, str, i) => {\n\t\tif (typeof values[i] === 'object') {\n\t\t\tif (Array.isArray(values[i])) {\n\t\t\t\treturn `${acc}${str}${printNodes(...values[i])}`;\n\t\t\t}\n\n\t\t\treturn `${acc}${str}${printNodes(values[i])}`;\n\t\t}\n\n\t\treturn `${acc}${str}${values[i] ?? ''}`;\n\t}, '');\n\n\tconst lines = source.replace(/^\\s/m, '').split('\\n');\n\tconst firstLine = lines[0];\n\tconst indent = firstLine.match(/^\\s*/)?.[0] ?? '';\n\tconst unIndented = lines.map((line) => line.replace(indent, '')).join('\\n');\n\n\tconst sourceFile = ts.createSourceFile('file.ts', unIndented, ts.ScriptTarget.Latest, true);\n\treturn [...sourceFile.statements.values()];\n}\n\nexport async function mapToObject<T>({\n\titems,\n\tmapper,\n\tgetComment,\n}: {\n\titems: Iterable<T>;\n\tmapper: (item: T) => Promise<null | [string, TSTemplateValue]> | null | [string, TSTemplateValue];\n\tgetComment?: (item: T) => string | null | undefined;\n}) {\n\tconst fieldProps = await Promise.all(\n\t\t(\n\t\t\tawait Promise.all(\n\t\t\t\t[...items].map(async (item) => {\n\t\t\t\t\tconst mapped = await mapper(item);\n\t\t\t\t\tif (!mapped) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [key, value] = mapped;\n\t\t\t\t\treturn [item, key, value] as const;\n\t\t\t\t}),\n\t\t\t)\n\t\t)\n\t\t\t.filter((value) => value !== null)\n\t\t\t.map(([item, key, value]) => {\n\t\t\t\tconst [node] = parseTS /* ts */ `({${key}: ${value}})`;\n\n\t\t\t\tif (!ts.isExpressionStatement(node)) {\n\t\t\t\t\tthrow new Error('Expected Expression statement');\n\t\t\t\t}\n\n\t\t\t\tif (!ts.isParenthesizedExpression(node.expression)) {\n\t\t\t\t\tthrow new Error('Expected Parenthesized Expression');\n\t\t\t\t}\n\n\t\t\t\tif (!ts.isObjectLiteralExpression(node.expression.expression)) {\n\t\t\t\t\tthrow new Error('Expected Object Literal Expression');\n\t\t\t\t}\n\n\t\t\t\tconst comment = getComment?.(item);\n\t\t\t\treturn withComment({ comment }, node.expression.expression.properties[0]);\n\t\t\t}),\n\t);\n\n\treturn ts.factory.createObjectLiteralExpression(fieldProps, true);\n}\n\nexport async function withComment<T extends ts.Node | ts.Node[]>(\n\toptions:\n\t\t| { comment?: string | null; doc?: never }\n\t\t| { doc?: string | null | undefined; comment?: never },\n\tnodes: T,\n): Promise<T> {\n\tconst comment = options.comment ?? options.doc;\n\n\tif (comment) {\n\t\tconst firstNode = Array.isArray(nodes) ? nodes[0] : (nodes as ts.Node);\n\t\tts.addSyntheticLeadingComment(\n\t\t\tfirstNode,\n\t\t\tts.SyntaxKind.MultiLineCommentTrivia,\n\t\t\tawait formatComment(comment),\n\t\t\ttrue,\n\t\t);\n\t}\n\n\treturn nodes;\n}\n\nexport async function formatComment(text: string) {\n\tconst lines = (\n\t\tawait format(text, {\n\t\t\tprintWidth: 80,\n\t\t\tsemi: true,\n\t\t\tsingleQuote: true,\n\t\t\ttabWidth: 2,\n\t\t\ttrailingComma: 'all',\n\t\t\tuseTabs: true,\n\t\t\tproseWrap: 'always',\n\t\t\tparser: 'markdown',\n\t\t})\n\t)\n\t\t.trim()\n\t\t.replaceAll('*/', '*\\\\/')\n\t\t.split('\\n');\n\n\tif (lines.length === 1) return `* ${lines[0]} `;\n\n\treturn `*\\n${lines.map((line) => ` * ${line}`).join('\\n')}\\n `;\n}\n\nexport function camelCase(str: string) {\n\treturn str.replaceAll(/(?:_)([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport function capitalize(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport function isWellKnownObjectParameter(\n\ttype: Type,\n\tresolveAddress: (address: string) => string,\n) {\n\tif (typeof type === 'string') {\n\t\treturn false;\n\t}\n\n\tif ('Reference' in type) {\n\t\treturn isWellKnownObjectParameter(type.Reference[1], resolveAddress);\n\t}\n\n\tif (!('Datatype' in type)) {\n\t\treturn false;\n\t}\n\n\tconst { Datatype } = type;\n\n\tconst address = resolveAddress(Datatype.module.address);\n\tif (address === HANEUL_FRAMEWORK_ADDRESS) {\n\t\tif (Datatype.module.name === 'deny_list') {\n\t\t\treturn Datatype.name === 'DenyList';\n\t\t}\n\n\t\tif (Datatype.module.name === 'random') {\n\t\t\treturn Datatype.name === 'Random';\n\t\t}\n\n\t\tif (Datatype.module.name === 'clock') {\n\t\t\treturn Datatype.name === 'Clock';\n\t\t}\n\t}\n\n\tif (address === HANEUL_SYSTEM_ADDRESS) {\n\t\tif (Datatype.module.name === 'haneul_system') {\n\t\t\treturn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AAI,SAAS,OAAO,SAAS,SAAS;AACrC,aAAO,SAAS,SAAS;AAAA,IAC1B;AAAA,EACD;AAEA,MAAI,YAAY,2CAAuB;AACtC,QAAI,SAAS,OAAO,SAAS,iBAAiB;AAC7C,aAAO,SAAS,SAAS;AAAA,IAC1B;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": ["ts"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { proposeCompletions } from "@stricli/core";
|
|
3
|
+
import { buildContext } from "../cli/context.js";
|
|
4
|
+
import { buildCli } from "../cli/cli.js";
|
|
5
|
+
const { version } = require("../../../package.json");
|
|
6
|
+
const cli = buildCli(version);
|
|
7
|
+
const inputs = process.argv.slice(3);
|
|
8
|
+
if (process.env["COMP_LINE"]?.endsWith(" ")) {
|
|
9
|
+
inputs.push("");
|
|
10
|
+
}
|
|
11
|
+
async function main() {
|
|
12
|
+
await proposeCompletions(cli, inputs, buildContext(process));
|
|
13
|
+
try {
|
|
14
|
+
for (const { completion } of await proposeCompletions(cli, inputs, buildContext(process))) {
|
|
15
|
+
process.stdout.write(`${completion}
|
|
16
|
+
`);
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
main().then(
|
|
22
|
+
() => process.exit(0),
|
|
23
|
+
(error) => {
|
|
24
|
+
console.error(error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
export {
|
|
29
|
+
main
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=bash-complete.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/bash-complete.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { proposeCompletions } from '@stricli/core';\nimport { buildContext } from '../cli/context.js';\nimport { buildCli } from '../cli/cli.js';\n\nconst { version }: { version: string } = require('../../../package.json');\nconst cli = buildCli(version);\n\nconst inputs = process.argv.slice(3);\nif (process.env['COMP_LINE']?.endsWith(' ')) {\n\tinputs.push('');\n}\n\nexport async function main() {\n\tawait proposeCompletions(cli, inputs, buildContext(process));\n\n\ttry {\n\t\tfor (const { completion } of await proposeCompletions(cli, inputs, buildContext(process))) {\n\t\t\tprocess.stdout.write(`${completion}\\n`);\n\t\t}\n\t} catch {\n\t\t// ignore\n\t}\n}\n\nmain().then(\n\t() => process.exit(0),\n\t(error) => {\n\t\tconsole.error(error);\n\t\tprocess.exit(1);\n\t},\n);\n"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAEzB,MAAM,EAAE,QAAQ,IAAyB,QAAQ,uBAAuB;AACxE,MAAM,MAAM,SAAS,OAAO;AAE5B,MAAM,SAAS,QAAQ,KAAK,MAAM,CAAC;AACnC,IAAI,QAAQ,IAAI,WAAW,GAAG,SAAS,GAAG,GAAG;AAC5C,SAAO,KAAK,EAAE;AACf;AAEA,eAAsB,OAAO;AAC5B,QAAM,mBAAmB,KAAK,QAAQ,aAAa,OAAO,CAAC;AAE3D,MAAI;AACH,eAAW,EAAE,WAAW,KAAK,MAAM,mBAAmB,KAAK,QAAQ,aAAa,OAAO,CAAC,GAAG;AAC1F,cAAQ,OAAO,MAAM,GAAG,UAAU;AAAA,CAAI;AAAA,IACvC;AAAA,EACD,QAAQ;AAAA,EAER;AACD;AAEA,KAAK,EAAE;AAAA,EACN,MAAM,QAAQ,KAAK,CAAC;AAAA,EACpB,CAAC,UAAU;AACV,YAAQ,MAAM,KAAK;AACnB,YAAQ,KAAK,CAAC;AAAA,EACf;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from "@stricli/core";
|
|
3
|
+
import { buildContext } from "../cli/context.js";
|
|
4
|
+
import { buildCli } from "../cli/cli.js";
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
async function getVersion() {
|
|
8
|
+
let dirname;
|
|
9
|
+
try {
|
|
10
|
+
dirname = __dirname;
|
|
11
|
+
} catch {
|
|
12
|
+
dirname = import.meta.dirname;
|
|
13
|
+
}
|
|
14
|
+
const packageJsonPath = resolve(
|
|
15
|
+
dirname,
|
|
16
|
+
dirname.endsWith("src/bin") ? "../../package.json" : "../../../package.json"
|
|
17
|
+
);
|
|
18
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
19
|
+
return packageJson.version;
|
|
20
|
+
}
|
|
21
|
+
async function main() {
|
|
22
|
+
const version = await getVersion();
|
|
23
|
+
await run(buildCli(version), process.argv.slice(2), buildContext(process));
|
|
24
|
+
}
|
|
25
|
+
main().then(
|
|
26
|
+
() => process.exit(0),
|
|
27
|
+
(error) => {
|
|
28
|
+
console.error(error);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/cli.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { run } from '@stricli/core';\nimport { buildContext } from '../cli/context.js';\nimport { buildCli } from '../cli/cli.js';\nimport { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\n\nasync function getVersion() {\n\tlet dirname;\n\n\ttry {\n\t\tdirname = __dirname;\n\t} catch {\n\t\t// @ts-ignore\n\t\tdirname = import.meta.dirname;\n\t}\n\n\tconst packageJsonPath = resolve(\n\t\tdirname,\n\t\tdirname.endsWith('src/bin') ? '../../package.json' : '../../../package.json',\n\t);\n\tconst packageJson: { version: string } = JSON.parse(await readFile(packageJsonPath, 'utf-8'));\n\treturn packageJson.version;\n}\n\nasync function main() {\n\tconst version = await getVersion();\n\tawait run(buildCli(version), process.argv.slice(2), buildContext(process));\n}\n\nmain().then(\n\t() => process.exit(0),\n\t(error) => {\n\t\tconsole.error(error);\n\t\tprocess.exit(1);\n\t},\n);\n"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AAExB,eAAe,aAAa;AAC3B,MAAI;AAEJ,MAAI;AACH,cAAU;AAAA,EACX,QAAQ;AAEP,cAAU,YAAY;AAAA,EACvB;AAEA,QAAM,kBAAkB;AAAA,IACvB;AAAA,IACA,QAAQ,SAAS,SAAS,IAAI,uBAAuB;AAAA,EACtD;AACA,QAAM,cAAmC,KAAK,MAAM,MAAM,SAAS,iBAAiB,OAAO,CAAC;AAC5F,SAAO,YAAY;AACpB;AAEA,eAAe,OAAO;AACrB,QAAM,UAAU,MAAM,WAAW;AACjC,QAAM,IAAI,SAAS,OAAO,GAAG,QAAQ,KAAK,MAAM,CAAC,GAAG,aAAa,OAAO,CAAC;AAC1E;AAEA,KAAK,EAAE;AAAA,EACN,MAAM,QAAQ,KAAK,CAAC;AAAA,EACpB,CAAC,UAAU;AACV,YAAQ,MAAM,KAAK;AACnB,YAAQ,KAAK,CAAC;AAAA,EACf;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildCli(version: string): import("@stricli/core").Application<import("./context.js").LocalContext>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { buildApplication, buildRouteMap } from "@stricli/core";
|
|
2
|
+
import { buildInstallCommand, buildUninstallCommand } from "@stricli/auto-complete";
|
|
3
|
+
import { generateCommand } from "./commands/generate/command.js";
|
|
4
|
+
function buildCli(version) {
|
|
5
|
+
const routes = buildRouteMap({
|
|
6
|
+
routes: {
|
|
7
|
+
generate: generateCommand,
|
|
8
|
+
install: buildInstallCommand("haneul-ts-codegen", { bash: "__haneul-ts-codegen_bash_complete" }),
|
|
9
|
+
uninstall: buildUninstallCommand("haneul-ts-codegen", { bash: true })
|
|
10
|
+
},
|
|
11
|
+
docs: {
|
|
12
|
+
brief: "Generate TypeScript bindings for your Move code",
|
|
13
|
+
hideRoute: {
|
|
14
|
+
install: true,
|
|
15
|
+
uninstall: true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return buildApplication(routes, {
|
|
20
|
+
name: "haneul-ts-codegen",
|
|
21
|
+
versionInfo: {
|
|
22
|
+
currentVersion: version
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
buildCli
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cli/cli.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { buildApplication, buildRouteMap } from '@stricli/core';\nimport { buildInstallCommand, buildUninstallCommand } from '@stricli/auto-complete';\nimport { generateCommand } from './commands/generate/command.js';\n\nexport function buildCli(version: string) {\n\tconst routes = buildRouteMap({\n\t\troutes: {\n\t\t\tgenerate: generateCommand,\n\t\t\tinstall: buildInstallCommand('haneul-ts-codegen', { bash: '__haneul-ts-codegen_bash_complete' }),\n\t\t\tuninstall: buildUninstallCommand('haneul-ts-codegen', { bash: true }),\n\t\t},\n\t\tdocs: {\n\t\t\tbrief: 'Generate TypeScript bindings for your Move code',\n\t\t\thideRoute: {\n\t\t\t\tinstall: true,\n\t\t\t\tuninstall: true,\n\t\t\t},\n\t\t},\n\t});\n\n\treturn buildApplication(routes, {\n\t\tname: 'haneul-ts-codegen',\n\t\tversionInfo: {\n\t\t\tcurrentVersion: version,\n\t\t},\n\t});\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,qBAAqB,6BAA6B;AAC3D,SAAS,uBAAuB;AAEzB,SAAS,SAAS,SAAiB;AACzC,QAAM,SAAS,cAAc;AAAA,IAC5B,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,SAAS,oBAAoB,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAAA,MAC/F,WAAW,sBAAsB,qBAAqB,EAAE,MAAM,KAAK,CAAC;AAAA,IACrE;AAAA,IACA,MAAM;AAAA,MACL,OAAO;AAAA,MACP,WAAW;AAAA,QACV,SAAS;AAAA,QACT,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO,iBAAiB,QAAQ;AAAA,IAC/B,MAAM;AAAA,IACN,aAAa;AAAA,MACZ,gBAAgB;AAAA,IACjB;AAAA,EACD,CAAC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateCommand: import("@stricli/core").Command<import("../../context.js").LocalContext>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { buildCommand } from "@stricli/core";
|
|
2
|
+
const generateCommand = buildCommand({
|
|
3
|
+
loader: async () => (await import("./impl.js")).default,
|
|
4
|
+
parameters: {
|
|
5
|
+
positional: {
|
|
6
|
+
kind: "array",
|
|
7
|
+
parameter: {
|
|
8
|
+
parse: String,
|
|
9
|
+
brief: "package name, mvr name, or path to a move package"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
flags: {
|
|
13
|
+
outputDir: {
|
|
14
|
+
kind: "parsed",
|
|
15
|
+
parse: String,
|
|
16
|
+
brief: "Output directory",
|
|
17
|
+
optional: true
|
|
18
|
+
},
|
|
19
|
+
noPrune: {
|
|
20
|
+
kind: "parsed",
|
|
21
|
+
parse: Boolean,
|
|
22
|
+
optional: true,
|
|
23
|
+
brief: "generate all types and functions in dependencies"
|
|
24
|
+
},
|
|
25
|
+
noSummaries: {
|
|
26
|
+
kind: "parsed",
|
|
27
|
+
parse: Boolean,
|
|
28
|
+
optional: true,
|
|
29
|
+
brief: "Do not generate summaries for packages"
|
|
30
|
+
},
|
|
31
|
+
network: {
|
|
32
|
+
kind: "enum",
|
|
33
|
+
values: ["mainnet", "testnet"],
|
|
34
|
+
optional: true,
|
|
35
|
+
brief: "Network to generate for (default: testnet)"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
aliases: {
|
|
39
|
+
o: "outputDir",
|
|
40
|
+
n: "network"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
docs: {
|
|
44
|
+
brief: "Generate BCS and moveCall helpers from you Move code"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
generateCommand
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=command.js.map
|