@hyperweb/telescope 2.0.0 → 2.0.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.
Files changed (42) hide show
  1. package/README.md +4 -26
  2. package/main/builder.js +0 -10
  3. package/main/cli.js +0 -19
  4. package/main/cmds.js +1 -13
  5. package/main/helpers/helper-func-types-interface.js +7 -7
  6. package/main/helpers/helper-func-types.js +7 -7
  7. package/main/helpers/types-helper.js +38 -4
  8. package/module/builder.js +0 -10
  9. package/module/cli.js +0 -19
  10. package/module/cmds.js +0 -12
  11. package/module/helpers/helper-func-types-interface.js +7 -7
  12. package/module/helpers/helper-func-types.js +7 -7
  13. package/module/helpers/types-helper.js +38 -4
  14. package/module/telescope.js +0 -0
  15. package/package.json +6 -7
  16. package/src/builder.ts +2 -12
  17. package/src/cli.js +1 -21
  18. package/src/cmds.js +0 -14
  19. package/src/helpers/helper-func-types-interface.ts +7 -7
  20. package/src/helpers/helper-func-types.ts +7 -7
  21. package/src/helpers/types-helper.ts +38 -4
  22. package/types/cmds.d.ts +0 -1
  23. package/main/generators/create-combined-stargate-clients.js +0 -99
  24. package/main/helpers/generated-type.js +0 -24
  25. package/main/helpers/internalForBigInt.js +0 -248
  26. package/main/helpers/types.js +0 -24
  27. package/main/helpers/vue-query.js +0 -91
  28. package/main/protod/proto-download.js +0 -57
  29. package/module/generators/create-combined-stargate-clients.js +0 -95
  30. package/module/helpers/generated-type.js +0 -21
  31. package/module/helpers/internalForBigInt.js +0 -245
  32. package/module/helpers/types.js +0 -21
  33. package/module/helpers/vue-query.js +0 -87
  34. package/module/protod/proto-download.js +0 -55
  35. package/src/contracts/generate.ts +0 -33
  36. package/src/contracts/install.ts +0 -118
  37. package/src/contracts/message-composer.ts +0 -34
  38. package/src/contracts/react-query.ts +0 -33
  39. package/src/contracts/recoil.ts +0 -32
  40. package/src/generators/create-cosmwasm-bundle.ts +0 -17
  41. package/src/utils/contracts.ts +0 -37
  42. package/types/codegen/cosmos/orm/module/v1alpha1/module.d.ts +0 -43
@@ -13,9 +13,9 @@ import { HttpEndpoint } from "${
13
13
  }";
14
14
  ${options.useInterchainJs ? `
15
15
 
16
- import { Event, Attribute } from "@interchainjs/types";
17
-
16
+ import { DeliverTxResponse, Event, Attribute } from "@interchainjs/types";
18
17
 
18
+ export type { DeliverTxResponse }
19
19
 
20
20
  ` : ''}
21
21
  export type ProtoMsg = Omit<Any, "typeUrl"> & { typeUrl: any };
@@ -110,7 +110,41 @@ export interface Event {
110
110
  attributes: readonly Attribute[];
111
111
  }
112
112
 
113
-
113
+ /**
114
+ * The response after successfully broadcasting a transaction.
115
+ * Success or failure refer to the execution result.
116
+ */
117
+ export interface DeliverTxResponse {
118
+ height: number;
119
+ /** The position of the transaction within the block. This is a 0-based index. */
120
+ txIndex: number;
121
+ /** Error code. The transaction suceeded if and only if code is 0. */
122
+ code: number;
123
+ transactionHash: string;
124
+ events: readonly Event[];
125
+ /**
126
+ * A string-based log document.
127
+ *
128
+ * This currently seems to merge attributes of multiple events into one event per type
129
+ * (https://github.com/tendermint/tendermint/issues/9595). You might want to use the \`events\`
130
+ * field instead.
131
+ */
132
+ rawLog?: string;
133
+ /** @deprecated Use \`msgResponses\` instead. */
134
+ data?: readonly MsgData[];
135
+ /**
136
+ * The message responses of the [TxMsgData](https://github.com/cosmos/cosmos-sdk/blob/v0.46.3/proto/cosmos/base/abci/v1beta1/abci.proto#L128-L140)
137
+ * as \`Any\`s.
138
+ * This field is an empty list for chains running Cosmos SDK < 0.46.
139
+ */
140
+ msgResponses: Array<{
141
+ typeUrl: string;
142
+ value: Uint8Array;
143
+ }>;
144
+ gasUsed: bigint;
145
+ gasWanted: bigint;
146
+ origin?: any;
147
+ }
114
148
  `}
115
149
  export interface TxRpc {
116
150
  request(
@@ -123,7 +157,7 @@ export interface TxRpc {
123
157
  messages: EncodeObject[],
124
158
  fee: StdFee | "auto" | number,
125
159
  memo: string
126
- ): Promise<any>;
160
+ ): Promise<DeliverTxResponse>;
127
161
  }
128
162
  ${options.useInterchainJs ? '' : `
129
163
  export interface SigningClientParams {
package/types/cmds.d.ts CHANGED
@@ -4,7 +4,6 @@ export namespace Commands {
4
4
  export { _commands_download as download };
5
5
  export { _commands_transpile as transpile };
6
6
  }
7
- export const Contracts: typeof Contracts;
8
7
  import _commands_generate from './commands/generate';
9
8
  import _commands_install from './commands/install';
10
9
  import _commands_download from './commands/download';
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.plugin = void 0;
4
- const path_1 = require("path");
5
- const ast_1 = require("@cosmology/ast");
6
- const case_1 = require("case");
7
- const utils_1 = require("@cosmology/utils");
8
- const imports_1 = require("../imports");
9
- const files_1 = require("../utils/files");
10
- const plugin = (builder, allRegistries, allConverters) => {
11
- builder.options.rpcClients.combinedClient.map((currentClient) => {
12
- if (!allRegistries || !allRegistries.length) {
13
- return;
14
- }
15
- const registryImports = [];
16
- const converterImports = [];
17
- const clientFile = currentClient.fileName;
18
- const ctxRef = {
19
- absolute: '/',
20
- filename: '/',
21
- proto: {
22
- imports: [],
23
- package: currentClient.name,
24
- root: {},
25
- }
26
- };
27
- const ctx = new ast_1.GenericParseContext(ctxRef, null, builder.options);
28
- const registryVariables = [];
29
- const converterVariables = [];
30
- const filteredRegistries = allRegistries.filter(item => (0, utils_1.isPackageIncluded)(item.package, currentClient.include.patterns));
31
- filteredRegistries.forEach(registry => {
32
- let rel = (0, path_1.relative)((0, path_1.dirname)(clientFile), registry.localname);
33
- if (!rel.startsWith('.'))
34
- rel = `./${rel}`;
35
- rel = (0, utils_1.toPosixPath)(rel);
36
- const variable = (0, utils_1.variableSlug)(registry.localname);
37
- registryVariables.push(variable);
38
- registryImports.push((0, ast_1.importNamespace)(variable, rel));
39
- });
40
- const filteredConverters = allConverters.filter(item => (0, utils_1.isPackageIncluded)(item.package, currentClient.include.patterns));
41
- filteredConverters.forEach(converter => {
42
- let rel = (0, path_1.relative)((0, path_1.dirname)(clientFile), converter.localname);
43
- if (!rel.startsWith('.'))
44
- rel = `./${rel}`;
45
- rel = (0, utils_1.toPosixPath)(rel);
46
- const variable = (0, utils_1.variableSlug)(converter.localname);
47
- converterVariables.push(variable);
48
- converterImports.push((0, ast_1.importNamespace)(variable, rel));
49
- });
50
- const name = 'get' + (0, case_1.pascal)(currentClient.name + 'SigningClient');
51
- const txRpcName = 'get' + (0, case_1.pascal)(currentClient.name + 'SigningTxRpc');
52
- const prefix = (0, case_1.camel)(currentClient.name);
53
- const aminos = (0, ast_1.createStargateClientAminoRegistry)({
54
- context: ctx,
55
- aminos: converterVariables,
56
- aminoConverters: prefix + 'AminoConverters'
57
- });
58
- const protos = (0, ast_1.createStargateClientProtoRegistry)({
59
- context: ctx,
60
- registries: registryVariables,
61
- protoTypeRegistry: prefix + 'ProtoRegistry'
62
- });
63
- const clientOptions = (0, ast_1.createStargateClientOptions)({
64
- context: ctx,
65
- name: name + 'Options',
66
- protoTypeRegistry: prefix + 'ProtoRegistry',
67
- aminoConverters: prefix + 'AminoConverters'
68
- });
69
- const clientBody = (0, ast_1.createStargateClient)({
70
- context: ctx,
71
- name,
72
- options: name + 'Options',
73
- });
74
- let getTxRpc;
75
- if (ctx.pluginValue("stargateClients.addGetTxRpc")) {
76
- getTxRpc = (0, ast_1.createGetTxRpc)(ctx, txRpcName, name);
77
- }
78
- const imports = (0, imports_1.buildAllImportsFromGenericContext)(ctx, clientFile);
79
- let importDecls = [...imports, ...registryImports, ...converterImports];
80
- importDecls = (0, utils_1.duplicateImportPathsWithExt)(importDecls, builder.options.restoreImportExtension);
81
- let cProg = importDecls
82
- .concat(aminos)
83
- .concat(protos)
84
- .concat(clientOptions)
85
- .concat(clientBody);
86
- // replace all backslash path for windows
87
- for (let i = 0; i < cProg.length; i++) {
88
- if (cProg[i].source?.value) {
89
- cProg[i].source.value = (0, utils_1.toPosixPath)(cProg[i].source?.value);
90
- }
91
- }
92
- if (getTxRpc) {
93
- cProg = cProg.concat(getTxRpc);
94
- }
95
- const clientOutFile = (0, path_1.join)(builder.outPath, clientFile);
96
- (0, files_1.writeAstToFile)(builder.outPath, builder.options, cProg, clientOutFile);
97
- });
98
- };
99
- exports.plugin = plugin;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generatedType = void 0;
4
- exports.generatedType = `import { BinaryReader, BinaryWriter } from "../../../binary";
5
-
6
- /**
7
- * A type generated by Telescope 1.0.
8
- */
9
- export interface TelescopeGeneratedType {
10
- readonly typeUrl: string;
11
- readonly encode: (
12
- message:
13
- | any
14
- | {
15
- [k: string]: any;
16
- },
17
- writer?: BinaryWriter
18
- ) => BinaryWriter;
19
- readonly decode: (input: BinaryReader | Uint8Array, length?: number) => any;
20
- readonly fromPartial: (object: any) => any;
21
- }
22
-
23
- export type GeneratedType = TelescopeGeneratedType;
24
- `;
@@ -1,248 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.internalForBigInt = void 0;
4
- exports.internalForBigInt = `
5
- declare var self: any | undefined;
6
- declare var window: any | undefined;
7
- declare var global: any | undefined;
8
- var globalThis: any = (() => {
9
- if (typeof globalThis !== 'undefined') return globalThis;
10
- if (typeof self !== 'undefined') return self;
11
- if (typeof window !== 'undefined') return window;
12
- if (typeof global !== 'undefined') return global;
13
- throw 'Unable to locate global object';
14
- })();
15
-
16
- const atob: (b64: string) => string =
17
- globalThis.atob ||
18
- ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
19
-
20
- export function bytesFromBase64(b64: string): Uint8Array {
21
- const bin = atob(b64);
22
- const arr = new Uint8Array(bin.length);
23
- for (let i = 0; i < bin.length; ++i) {
24
- arr[i] = bin.charCodeAt(i);
25
- }
26
- return arr;
27
- }
28
-
29
- const btoa: (bin: string) => string =
30
- globalThis.btoa ||
31
- ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
32
-
33
- export function base64FromBytes(arr: Uint8Array): string {
34
- const bin: string[] = [];
35
- arr.forEach((byte) => {
36
- bin.push(String.fromCharCode(byte));
37
- });
38
- return btoa(bin.join(''));
39
- }
40
-
41
- export interface AminoHeight {
42
- readonly revision_number?: string;
43
- readonly revision_height?: string;
44
- }
45
-
46
- export function omitDefault<T extends string | number | bigint>(
47
- input: T
48
- ): T | undefined {
49
- if (typeof input === 'string') {
50
- return input === '' ? undefined : input;
51
- }
52
-
53
- if (typeof input === 'number') {
54
- return input === 0 ? undefined : input;
55
- }
56
-
57
- if (typeof input === 'bigint') {
58
- return input === BigInt(0) ? undefined : input;
59
- }
60
-
61
- throw new Error(\`Got unsupported type \${typeof input}\`);
62
- }
63
-
64
- interface Duration {
65
- /**
66
- * Signed seconds of the span of time. Must be from -315,576,000,000
67
- * to +315,576,000,000 inclusive. Note: these bounds are computed from:
68
- * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
69
- */
70
- seconds: bigint;
71
- /**
72
- * Signed fractions of a second at nanosecond resolution of the span
73
- * of time. Durations less than one second are represented with a 0
74
- * \`seconds\` field and a positive or negative \`nanos\` field. For durations
75
- * of one second or more, a non-zero value for the \`nanos\` field must be
76
- * of the same sign as the \`seconds\` field. Must be from -999,999,999
77
- * to +999,999,999 inclusive.
78
- */
79
-
80
- nanos: number;
81
- }
82
-
83
- export function toDuration(duration: string): Duration {
84
- return {
85
- seconds: BigInt(Math.floor(parseInt(duration) / 1000000000)),
86
- nanos: parseInt(duration) % 1000000000
87
- };
88
- }
89
-
90
- export function fromDuration(duration: Duration): string {
91
- return (
92
- parseInt(duration.seconds.toString()) * 1000000000 +
93
- duration.nanos
94
- ).toString();
95
- }
96
-
97
- export function isSet(value: any): boolean {
98
- return value !== null && value !== undefined;
99
- }
100
-
101
- export function isObject(value: any): boolean {
102
- return typeof value === 'object' && value !== null;
103
- }
104
-
105
- export interface PageRequest {
106
- key: Uint8Array;
107
- offset: bigint;
108
- limit: bigint;
109
- countTotal: boolean;
110
- reverse: boolean;
111
- }
112
-
113
- export interface PageRequestParams {
114
- 'pagination.key'?: string;
115
- 'pagination.offset'?: string;
116
- 'pagination.limit'?: string;
117
- 'pagination.count_total'?: boolean;
118
- 'pagination.reverse'?: boolean;
119
- }
120
-
121
- export interface Params {
122
- params: PageRequestParams;
123
- }
124
-
125
- export const setPaginationParams = (
126
- options: Params,
127
- pagination?: PageRequest
128
- ) => {
129
- if (!pagination) {
130
- return options;
131
- }
132
-
133
- if (typeof pagination?.countTotal !== 'undefined') {
134
- options.params['pagination.count_total'] = pagination.countTotal;
135
- }
136
- if (typeof pagination?.key !== 'undefined') {
137
- // String to Uint8Array
138
- // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
139
-
140
- // Uint8Array to String
141
- options.params['pagination.key'] = Buffer.from(pagination.key).toString(
142
- 'base64'
143
- );
144
- }
145
- if (typeof pagination?.limit !== 'undefined') {
146
- options.params['pagination.limit'] = pagination.limit.toString();
147
- }
148
- if (typeof pagination?.offset !== 'undefined') {
149
- options.params['pagination.offset'] = pagination.offset.toString();
150
- }
151
- if (typeof pagination?.reverse !== 'undefined') {
152
- options.params['pagination.reverse'] = pagination.reverse;
153
- }
154
-
155
- return options;
156
- };
157
-
158
- type Builtin =
159
- | Date
160
- | Function
161
- | Uint8Array
162
- | string
163
- | number
164
- | bigint
165
- | boolean
166
- | undefined;
167
-
168
- export type DeepPartial<T> = T extends Builtin
169
- ? T
170
- : T extends Array<infer U>
171
- ? Array<DeepPartial<U>>
172
- : T extends ReadonlyArray<infer U>
173
- ? ReadonlyArray<DeepPartial<U>>
174
- : T extends {}
175
- ? { [K in keyof T]?: DeepPartial<T[K]> }
176
- : Partial<T>;
177
-
178
- type KeysOfUnion<T> = T extends T ? keyof T : never;
179
- export type Exact<P, I extends P> = P extends Builtin
180
- ? P
181
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
182
- Exclude<keyof I, KeysOfUnion<P>>,
183
- never
184
- >;
185
-
186
- export interface Rpc {
187
- request(
188
- service: string,
189
- method: string,
190
- data: Uint8Array
191
- ): Promise<Uint8Array>;
192
- }
193
-
194
- interface Timestamp {
195
- /**
196
- * Represents seconds of UTC time since Unix epoch
197
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
198
- * 9999-12-31T23:59:59Z inclusive.
199
- */
200
- seconds: bigint;
201
- /**
202
- * Non-negative fractions of a second at nanosecond resolution. Negative
203
- * second values with fractions must still have non-negative nanos values
204
- * that count forward in time. Must be from 0 to 999,999,999
205
- * inclusive.
206
- */
207
-
208
- nanos: number;
209
- }
210
-
211
- export function toTimestamp(date: Date): Timestamp {
212
- const seconds = numberToLong(date.getTime() / 1_000);
213
- const nanos = (date.getTime() % 1000) * 1000000;
214
- return {
215
- seconds,
216
- nanos
217
- };
218
- }
219
-
220
- export function fromTimestamp(t: Timestamp): Date {
221
- let millis = Number(t.seconds) * 1000;
222
- millis += t.nanos / 1000000;
223
- return new Date(millis);
224
- }
225
-
226
- const timestampFromJSON = (object: any): Timestamp => {
227
- return {
228
- seconds: isSet(object.seconds)
229
- ? BigInt(object.seconds.toString())
230
- : BigInt(0),
231
- nanos: isSet(object.nanos) ? Number(object.nanos) : 0
232
- };
233
- };
234
-
235
- export function fromJsonTimestamp(o: any): Timestamp {
236
- if (o instanceof Date) {
237
- return toTimestamp(o);
238
- } else if (typeof o === 'string') {
239
- return toTimestamp(new Date(o));
240
- } else {
241
- return timestampFromJSON(o);
242
- }
243
- }
244
-
245
- function numberToLong(number: number) {
246
- return BigInt(Math.trunc(number));
247
- }
248
- `;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.types = void 0;
4
- exports.types = `import { BinaryReader, BinaryWriter } from "../../../binary";
5
-
6
- /**
7
- * A type generated by Telescope 1.0.
8
- */
9
- export interface TelescopeGeneratedType {
10
- readonly typeUrl: string;
11
- readonly encode: (
12
- message:
13
- | any
14
- | {
15
- [k: string]: any;
16
- },
17
- writer?: BinaryWriter
18
- ) => BinaryWriter;
19
- readonly decode: (input: BinaryReader | Uint8Array, length?: number) => any;
20
- readonly fromPartial: (object: any) => any;
21
- }
22
-
23
- export type GeneratedType = TelescopeGeneratedType;
24
- `;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVueQueryHelper = void 0;
4
- const getVueQueryHelper = (options) => {
5
- return `import { getRpcClient } from './extern${options.restoreImportExtension ?? ""}'
6
- import {
7
- useQuery,
8
- UseQueryOptions,
9
- } from '@tanstack/vue-query';
10
- import { Ref, isRef } from 'vue'
11
-
12
- import { HttpEndpoint, ProtobufRpcClient } from '@cosmjs/stargate';
13
- ${options.rpcClients.useConnectComet
14
- ? "import { CometClient, connectComet, Tendermint34Client, Tendermint37Client } from '@cosmjs/tendermint-rpc';"
15
- : "import { Tendermint34Client } from '@cosmjs/tendermint-rpc';"}
16
-
17
- export interface VueQueryParams<TResponse, TData = TResponse> {
18
- options?: Omit<UseQueryOptions<TData, Error, TData>, 'queryKey'>;
19
- }
20
-
21
- export interface UseRpcClientQuery<TData> extends VueQueryParams<ProtobufRpcClient, TData> {
22
- rpcEndpoint: Ref<string | HttpEndpoint>;
23
- }
24
-
25
- export interface UseRpcEndpointQuery<TData> extends VueQueryParams<string | HttpEndpoint, TData> {
26
- getter: () => Promise<string | HttpEndpoint>;
27
- }
28
-
29
- export const useRpcEndpoint = <TData = string | HttpEndpoint>({
30
- getter,
31
- options,
32
- }: UseRpcEndpointQuery<TData>) => {
33
- return useQuery<string | HttpEndpoint, Error, TData>({
34
- queryKey: ['rpcEndpoint', getter],
35
- queryFn: async () => {
36
- return await getter();
37
- },
38
- ...options
39
- })
40
- };
41
-
42
- export const useRpcClient = <TData = ProtobufRpcClient>({
43
- rpcEndpoint,
44
- options,
45
- }: UseRpcClientQuery<TData>) => {
46
- let params = {
47
- queryKey: ['rpcClient', rpcEndpoint],
48
- queryFn: async () => {
49
- return await getRpcClient(rpcEndpoint.value);
50
- },
51
- };
52
- if (options && !isRef(options)) {
53
- params = {
54
- ...options,
55
- ...params,
56
- };
57
- }
58
- return useQuery<ProtobufRpcClient | undefined, Error, TData>(params);
59
- };
60
-
61
- ${options.rpcClients.useConnectComet
62
- ? "interface UseTendermintClient extends VueQueryParams<Tendermint34Client | Tendermint37Client | CometClient> {"
63
- : "interface UseTendermintClient extends VueQueryParams<Tendermint34Client> {"}
64
- rpcEndpoint: Ref<string | HttpEndpoint>;
65
- }
66
-
67
- /**
68
- * Hook that uses vue-query to cache a connected tendermint client.
69
- */
70
- export const useTendermintClient = ({
71
- rpcEndpoint,
72
- options,
73
- }: UseTendermintClient) => {
74
- ${options.rpcClients.useConnectComet
75
- ? " const { data: client } = useQuery<Tendermint34Client | Tendermint37Client | CometClient, Error, Tendermint34Client | Tendermint37Client | CometClient>("
76
- : " const { data: client } = useQuery<Tendermint34Client, Error, Tendermint34Client>({"}
77
- queryKey: ['client', 'tendermint', rpcEndpoint],
78
- queryFn: () => ${options.rpcClients.useConnectComet
79
- ? "connectComet(rpcEndpoint.value),"
80
- : "Tendermint34Client.connect(rpcEndpoint.value),"}
81
- // allow overriding
82
- throwOnError: (e) => {
83
- throw new Error(\`Failed to connect to \${rpcEndpoint}\` + '\\n' + e)
84
- },
85
- ...options,
86
- })
87
- return { client }
88
- };
89
- `;
90
- };
91
- exports.getVueQueryHelper = getVueQueryHelper;
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const recursive_1 = require("./recursive");
5
- const utils_1 = require("./utils");
6
- async function run() {
7
- const argv = process.argv.slice(2);
8
- const gitRepoIndex = argv.findIndex((arg) => arg === "--git-repo");
9
- if (gitRepoIndex === -1) {
10
- process.stderr.write("`git-repo` is not specified");
11
- process.exit(1);
12
- }
13
- const [owner, repo] = argv[gitRepoIndex + 1]?.split("/");
14
- if (!owner || !repo) {
15
- process.stderr.write("wrong `git-repo` format (i.e. <owner>/<repository>).");
16
- process.exit(1);
17
- }
18
- const targetsIndex = argv.findIndex((arg) => arg === "--targets");
19
- if (targetsIndex === -1) {
20
- process.stdout.write("`targets` is not specified");
21
- process.exit(1);
22
- }
23
- const targets = argv[targetsIndex + 1]?.split(",");
24
- if (!targets || targets.length === 0) {
25
- process.stderr.write("wrong `targets` format (i.e. <**/*.proto>,<**/*.proto>,<**/*.proto>).");
26
- process.exit(1);
27
- }
28
- const outDirIndex = argv.findIndex((arg) => arg === "--out");
29
- if (outDirIndex === -1) {
30
- process.stdout.write("`out` is not specified, downloading to `proto` folder by default.\n");
31
- }
32
- const outDir = outDirIndex !== -1 ? argv[outDirIndex + 1] : "./proto";
33
- const omitCloneIndex = argv.findIndex((arg) => arg === "--omit-clone");
34
- let omitClone = false;
35
- if (omitCloneIndex !== -1 && argv[omitCloneIndex + 1] === "true") {
36
- omitClone = true;
37
- }
38
- if (omitCloneIndex !== -1 &&
39
- typeof argv[omitCloneIndex + 1] === "undefined") {
40
- omitClone = true;
41
- }
42
- (0, utils_1.removeFolder)("git-modules");
43
- const result = await (0, recursive_1.clone)({
44
- owner,
45
- repo,
46
- outDir: "./git-modules",
47
- });
48
- if (result) {
49
- (0, utils_1.removeFolder)(outDir);
50
- (0, recursive_1.extractProto)({
51
- sources: result,
52
- targets,
53
- outDir,
54
- });
55
- }
56
- }
57
- run();