@dedot/cli 0.0.1-next.fecbe32d.13 → 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.
@@ -4,6 +4,7 @@ type Args = {
4
4
  output?: string;
5
5
  chain?: string;
6
6
  dts?: boolean;
7
+ subpath?: boolean;
7
8
  };
8
9
  export declare const chaintypes: CommandModule<Args, Args>;
9
10
  export {};
@@ -29,15 +29,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.chaintypes = void 0;
30
30
  const static_substrate_1 = require("@polkadot/types-support/metadata/static-substrate");
31
31
  const substrate_hex_1 = __importDefault(require("@polkadot/types-support/metadata/v15/substrate-hex"));
32
+ const api_1 = require("@dedot/api");
32
33
  const codecs_1 = require("@dedot/codecs");
33
34
  const codegen_1 = require("@dedot/codegen");
34
- const dedot_1 = require("dedot");
35
35
  const path = __importStar(require("path"));
36
36
  exports.chaintypes = {
37
37
  command: 'chaintypes',
38
38
  describe: 'Generate chain types & APIs for a Substrate-based blockchain',
39
39
  handler: async (yargs) => {
40
- const { wsUrl, output = '', chain = '', dts = true } = yargs;
40
+ const { wsUrl, output = '', chain = '', dts = true, subpath = true } = yargs;
41
41
  const outDir = path.resolve(output);
42
42
  const extension = dts ? 'd.ts' : 'ts';
43
43
  if (wsUrl === 'substrate') {
@@ -50,11 +50,11 @@ exports.chaintypes = {
50
50
  acc[name] = version;
51
51
  return acc;
52
52
  }, {});
53
- await (0, codegen_1.generateTypes)('substrate', metadata.latest, rpcMethods, runtimeApis, outDir, extension);
53
+ await (0, codegen_1.generateTypes)('substrate', metadata.latest, rpcMethods, runtimeApis, outDir, extension, subpath);
54
54
  }
55
55
  else {
56
56
  console.log(`- Generating chaintypes via endpoint ${wsUrl}`);
57
- await (0, codegen_1.generateTypesFromEndpoint)(chain, wsUrl, outDir, extension);
57
+ await (0, codegen_1.generateTypesFromEndpoint)(chain, wsUrl, outDir, extension, subpath);
58
58
  }
59
59
  console.log(`- DONE! Output: ${outDir}`);
60
60
  },
@@ -82,12 +82,18 @@ exports.chaintypes = {
82
82
  describe: 'Generate d.ts files',
83
83
  alias: 'd',
84
84
  default: true,
85
+ })
86
+ .option('subpath', {
87
+ type: 'boolean',
88
+ describe: 'Using subpath for shared packages',
89
+ alias: 's',
90
+ default: true,
85
91
  })); // TODO check to verify inputs
86
92
  },
87
93
  };
88
94
  const getRuntimeVersion = (metadata) => {
89
95
  const registry = new codecs_1.PortableRegistry(metadata.latest);
90
- const executor = new dedot_1.ConstantExecutor({
96
+ const executor = new api_1.ConstantExecutor({
91
97
  registry,
92
98
  metadata,
93
99
  });
@@ -1 +1,2 @@
1
1
  export * from './chaintypes.js';
2
+ export * from './typink.js';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./chaintypes.js"), exports);
18
+ __exportStar(require("./typink.js"), exports);
@@ -0,0 +1,10 @@
1
+ import { CommandModule } from 'yargs';
2
+ type Args = {
3
+ contract?: string;
4
+ output?: string;
5
+ metadata?: string;
6
+ dts?: boolean;
7
+ subpath?: boolean;
8
+ };
9
+ export declare const typink: CommandModule<Args, Args>;
10
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.typink = void 0;
27
+ const codegen_1 = require("@dedot/codegen");
28
+ const utils_1 = require("@dedot/utils");
29
+ const fs = __importStar(require("node:fs"));
30
+ const path = __importStar(require("path"));
31
+ exports.typink = {
32
+ command: 'typink',
33
+ describe: 'Generate types & APIs for a ink! smart contracts',
34
+ handler: async (yargs) => {
35
+ const { contract, output = '', metadata, dts = true, subpath = true } = yargs;
36
+ (0, utils_1.assert)(metadata, 'Metadata file is required, -h or --help to known more about the command');
37
+ const outDir = path.resolve(output);
38
+ const metadataFile = path.resolve(metadata);
39
+ const extension = dts ? 'd.ts' : 'ts';
40
+ const rawMetadata = fs.readFileSync(metadataFile, 'utf-8');
41
+ console.log(`- Generating contract types via metadata ${metadata}`);
42
+ await (0, codegen_1.generateContractTypes)(rawMetadata, contract, outDir, extension, subpath);
43
+ console.log(`- DONE! Output: ${outDir}`);
44
+ },
45
+ builder: (yargs) => {
46
+ return yargs
47
+ .option('metadata', {
48
+ type: 'string',
49
+ describe: 'Path to contract metadata file (.json, .contract)',
50
+ alias: 'm',
51
+ demandOption: true,
52
+ })
53
+ .option('output', {
54
+ type: 'string',
55
+ describe: 'Output folder to put generated files',
56
+ alias: 'o',
57
+ })
58
+ .option('contract', {
59
+ type: 'string',
60
+ describe: 'Contract name',
61
+ alias: 'c',
62
+ })
63
+ .option('dts', {
64
+ type: 'boolean',
65
+ describe: 'Generate d.ts files',
66
+ alias: 'd',
67
+ default: true,
68
+ })
69
+ .option('subpath', {
70
+ type: 'boolean',
71
+ describe: 'Using subpath for shared packages',
72
+ alias: 's',
73
+ default: true,
74
+ });
75
+ },
76
+ };
package/cjs/dedot.js CHANGED
@@ -12,6 +12,7 @@ const dedot = () => {
12
12
  .scriptName('dedot')
13
13
  .showHelpOnFail(true)
14
14
  .command(index_js_1.chaintypes)
15
+ .command(index_js_1.typink)
15
16
  .help('help', 'Show help instructions')
16
17
  .alias('h', 'help')
17
18
  .alias('v', 'version')
package/package.json CHANGED
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "name": "@dedot/cli",
3
- "version": "0.0.1-next.fecbe32d.13+fecbe32",
3
+ "version": "0.1.0",
4
4
  "author": "Thang X. Vu <thang@coongcrafts.io>",
5
+ "homepage": "https://github.com/dedotdev/dedot/tree/main/packages/cli",
6
+ "repository": {
7
+ "directory": "packages/cli",
8
+ "type": "git",
9
+ "url": "https://github.com/dedotdev/dedot.git"
10
+ },
5
11
  "bin": {
6
12
  "dedot": "./bin/dedot",
7
13
  "djs": "./bin/dedot"
@@ -14,8 +20,10 @@
14
20
  "start": "ts-node src/index.ts"
15
21
  },
16
22
  "dependencies": {
17
- "@dedot/codegen": "0.0.1-next.fecbe32d.13+fecbe32",
18
- "@polkadot/types-support": "^10.12.4",
23
+ "@dedot/api": "0.1.0",
24
+ "@dedot/codecs": "0.1.0",
25
+ "@dedot/codegen": "0.1.0",
26
+ "@polkadot/types-support": "^12.2.1",
19
27
  "yargs": "^17.7.2"
20
28
  },
21
29
  "devDependencies": {
@@ -26,5 +34,5 @@
26
34
  "directory": "dist"
27
35
  },
28
36
  "license": "Apache-2.0",
29
- "gitHead": "fecbe32d9d4b04cdb6802bf0ac604222f54b8331"
37
+ "gitHead": "c8220a4ab4b171fe04adb49759318bde865d7c17"
30
38
  }