@dedot/cli 0.0.1-alpha.33 → 0.0.1-alpha.35

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.
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/cli",
3
- "version": "0.0.1-alpha.33",
3
+ "version": "0.0.1-alpha.35",
4
4
  "author": "Thang X. Vu <thang@coongcrafts.io>",
5
5
  "bin": {
6
6
  "dedot": "./bin/dedot",
@@ -14,10 +14,10 @@
14
14
  "start": "ts-node src/index.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@dedot/api": "0.0.1-alpha.33",
18
- "@dedot/codecs": "0.0.1-alpha.33",
19
- "@dedot/codegen": "0.0.1-alpha.33",
20
- "@polkadot/types-support": "^11.2.1",
17
+ "@dedot/api": "0.0.1-alpha.35",
18
+ "@dedot/codecs": "0.0.1-alpha.35",
19
+ "@dedot/codegen": "0.0.1-alpha.35",
20
+ "@polkadot/types-support": "^12.0.1",
21
21
  "yargs": "^17.7.2"
22
22
  },
23
23
  "devDependencies": {
@@ -28,5 +28,5 @@
28
28
  "directory": "dist"
29
29
  },
30
30
  "license": "Apache-2.0",
31
- "gitHead": "36b30a0cec2d8652915e3660329b78f1c6e4221f"
31
+ "gitHead": "bf954b82ac4c8a8e1d989c0c708a099269eb4262"
32
32
  }