@cosmwasm/ts-codegen 0.8.2 → 0.9.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/README.md +52 -52
- package/main/cmds.js +4 -1
- package/main/commands/install.js +172 -0
- package/module/cmds.js +2 -0
- package/module/commands/install.js +101 -0
- package/package.json +2 -2
package/README.md
CHANGED
@@ -77,55 +77,51 @@ For production usage, we recommend setting up a build script that uses the main
|
|
77
77
|
```ts
|
78
78
|
import codegen from '@cosmwasm/ts-codegen';
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
dir: './path/to/Minter/schema'
|
90
|
-
}
|
91
|
-
],
|
92
|
-
outPath: './path/to/code/src/',
|
93
|
-
options: {
|
94
|
-
bundle: {
|
95
|
-
bundleFile: 'index.ts',
|
96
|
-
scope: 'contracts'
|
97
|
-
},
|
98
|
-
types: {
|
99
|
-
enabled: true
|
100
|
-
},
|
101
|
-
client: {
|
102
|
-
enabled: true
|
103
|
-
},
|
104
|
-
reactQuery: {
|
105
|
-
enabled: true,
|
106
|
-
optionalClient: true,
|
107
|
-
version: 'v4',
|
108
|
-
mutations: true
|
109
|
-
},
|
110
|
-
recoil: {
|
111
|
-
enabled: false
|
112
|
-
},
|
113
|
-
messageComposer: {
|
114
|
-
enabled: false
|
115
|
-
}
|
80
|
+
codegen({
|
81
|
+
contracts: [
|
82
|
+
{
|
83
|
+
name: 'SG721',
|
84
|
+
dir: './path/to/sg721/schema'
|
85
|
+
},
|
86
|
+
{
|
87
|
+
name: 'Minter',
|
88
|
+
dir: './path/to/Minter/schema'
|
116
89
|
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
90
|
+
],
|
91
|
+
outPath: './path/to/code/src/',
|
92
|
+
options: {
|
93
|
+
bundle: {
|
94
|
+
bundleFile: 'index.ts',
|
95
|
+
scope: 'contracts'
|
96
|
+
},
|
97
|
+
types: {
|
98
|
+
enabled: true
|
99
|
+
},
|
100
|
+
client: {
|
101
|
+
enabled: true
|
102
|
+
},
|
103
|
+
reactQuery: {
|
104
|
+
enabled: true,
|
105
|
+
optionalClient: true,
|
106
|
+
version: 'v4',
|
107
|
+
mutations: true
|
108
|
+
},
|
109
|
+
recoil: {
|
110
|
+
enabled: false
|
111
|
+
},
|
112
|
+
messageComposer: {
|
113
|
+
enabled: false
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}).then(() => {
|
117
|
+
console.log('✨ all done!');
|
122
118
|
});
|
123
119
|
```
|
124
120
|
#### Types
|
125
121
|
|
126
122
|
Typescript types and interfaces are generated in separate files so they can be imported into various generated plugins.
|
127
123
|
|
128
|
-
[see example output code](https://gist.github.com/pyramation/
|
124
|
+
[see example output code](https://gist.github.com/pyramation/107d4e8e30dc5eb3ffc07bc3000f4dd0)
|
129
125
|
|
130
126
|
#### Types Options
|
131
127
|
|
@@ -138,7 +134,7 @@ Typescript types and interfaces are generated in separate files so they can be i
|
|
138
134
|
|
139
135
|
The `client` plugin will generate TS client classes for your contracts. This option generates a `QueryClient` for queries as well as a `Client` for queries and mutations.
|
140
136
|
|
141
|
-
[see example output code](https://gist.github.com/pyramation/
|
137
|
+
[see example output code](https://gist.github.com/pyramation/30508678b7563e286f06ccc5ac384817)
|
142
138
|
|
143
139
|
#### Client Options
|
144
140
|
|
@@ -159,7 +155,7 @@ cosmwasm-ts-codegen generate \
|
|
159
155
|
|
160
156
|
Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query v4](https://tanstack.com/query/v4/) bindings for your contracts with the `react-query` command.
|
161
157
|
|
162
|
-
[see example output code](https://gist.github.com/pyramation/
|
158
|
+
[see example output code](https://gist.github.com/pyramation/70aef28fd3af0ee164f7711704d3dfc0)
|
163
159
|
|
164
160
|
#### React Query Options
|
165
161
|
|
@@ -205,7 +201,7 @@ cosmwasm-ts-codegen generate \
|
|
205
201
|
|
206
202
|
Generate [recoil](https://recoiljs.org/) bindings for your contracts with the `recoil` command.
|
207
203
|
|
208
|
-
[see example output code](https://gist.github.com/pyramation/
|
204
|
+
[see example output code](https://gist.github.com/pyramation/a9520ccf131177b1841e02a97d7d3731)
|
209
205
|
|
210
206
|
#### Recoil via CLI
|
211
207
|
|
@@ -227,7 +223,7 @@ cosmwasm-ts-codegen generate \
|
|
227
223
|
|
228
224
|
Generate pure message objects with the proper `utf8` encoding and `typeUrl` configured that you can broadcast yourself via `cosmjs` with the `message-composer` command.
|
229
225
|
|
230
|
-
[see example output code](https://gist.github.com/pyramation/
|
226
|
+
[see example output code](https://gist.github.com/pyramation/43320e8b952751a0bd5a77dbc5b601f4)
|
231
227
|
|
232
228
|
#### Message Composer via CLI
|
233
229
|
|
@@ -361,21 +357,25 @@ import {
|
|
361
357
|
```
|
362
358
|
### Example Output
|
363
359
|
|
364
|
-
- `cosmwasm-ts-codegen generate --
|
360
|
+
- `cosmwasm-ts-codegen generate --typesOnly`
|
365
361
|
|
366
|
-
https://gist.github.com/pyramation/
|
362
|
+
https://gist.github.com/pyramation/107d4e8e30dc5eb3ffc07bc3000f4dd0
|
367
363
|
|
368
|
-
- `cosmwasm-ts-codegen generate --plugin
|
364
|
+
- `cosmwasm-ts-codegen generate --plugin client`
|
369
365
|
|
370
|
-
https://gist.github.com/pyramation/
|
366
|
+
https://gist.github.com/pyramation/30508678b7563e286f06ccc5ac384817
|
371
367
|
|
372
368
|
- `cosmwasm-ts-codegen generate --plugin react-query`
|
373
369
|
|
374
|
-
https://gist.github.com/pyramation/
|
370
|
+
https://gist.github.com/pyramation/70aef28fd3af0ee164f7711704d3dfc0
|
375
371
|
|
376
372
|
- `cosmwasm-ts-codegen generate --plugin recoil`
|
377
373
|
|
378
|
-
https://gist.github.com/pyramation/
|
374
|
+
https://gist.github.com/pyramation/a9520ccf131177b1841e02a97d7d3731
|
375
|
+
|
376
|
+
- `cosmwasm-ts-codegen generate --plugin message-composer`
|
377
|
+
|
378
|
+
https://gist.github.com/pyramation/43320e8b952751a0bd5a77dbc5b601f4
|
379
379
|
|
380
380
|
|
381
381
|
### JSON Schema
|
package/main/cmds.js
CHANGED
@@ -11,7 +11,10 @@ var _createBoilerplate = _interopRequireDefault(require("./commands/create-boile
|
|
11
11
|
|
12
12
|
var _generate2 = _interopRequireDefault(require("./commands/generate"));
|
13
13
|
|
14
|
+
var _install2 = _interopRequireDefault(require("./commands/install"));
|
15
|
+
|
14
16
|
var Commands = {};
|
15
17
|
exports.Commands = Commands;
|
16
18
|
Commands['create-boilerplate'] = _createBoilerplate["default"];
|
17
|
-
Commands['generate'] = _generate2["default"];
|
19
|
+
Commands['generate'] = _generate2["default"];
|
20
|
+
Commands['install'] = _install2["default"];
|
@@ -0,0 +1,172 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports["default"] = void 0;
|
9
|
+
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
+
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
+
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
+
|
16
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
17
|
+
|
18
|
+
var _path = require("path");
|
19
|
+
|
20
|
+
var _mkdirp = require("mkdirp");
|
21
|
+
|
22
|
+
var _glob = require("glob");
|
23
|
+
|
24
|
+
var _rimraf = require("rimraf");
|
25
|
+
|
26
|
+
var _shelljs = require("shelljs");
|
27
|
+
|
28
|
+
var _prompt = require("../utils/prompt");
|
29
|
+
|
30
|
+
var _parsePackageName = require("parse-package-name");
|
31
|
+
|
32
|
+
var _os = require("os");
|
33
|
+
|
34
|
+
var _fs = require("fs");
|
35
|
+
|
36
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
37
|
+
|
38
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
39
|
+
|
40
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
41
|
+
|
42
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
43
|
+
|
44
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
45
|
+
|
46
|
+
var TMPDIR = (0, _os.tmpdir)();
|
47
|
+
|
48
|
+
var rnd = function rnd() {
|
49
|
+
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
50
|
+
};
|
51
|
+
|
52
|
+
var getPackages = function getPackages(names) {
|
53
|
+
return names.map(function (pkg) {
|
54
|
+
var _parse = (0, _parsePackageName.parse)(pkg),
|
55
|
+
name = _parse.name,
|
56
|
+
version = _parse.version;
|
57
|
+
|
58
|
+
return "".concat(name, "@").concat(version);
|
59
|
+
}).join(' ');
|
60
|
+
};
|
61
|
+
|
62
|
+
var _default = /*#__PURE__*/function () {
|
63
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(argv) {
|
64
|
+
var _packageInfo$dependen, _thisPackage$devDepen;
|
65
|
+
|
66
|
+
var cur, thisPackage, _yield$prompt, pkg, tmp, pkgs, cmds, _iterator, _step, _step$value, src, dst, _pkg, packageInfo, deps;
|
67
|
+
|
68
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
69
|
+
while (1) {
|
70
|
+
switch (_context.prev = _context.next) {
|
71
|
+
case 0:
|
72
|
+
// don't prompt if we got this...
|
73
|
+
if (argv._.length) {
|
74
|
+
argv.pkg = argv._;
|
75
|
+
} // current dir/package
|
76
|
+
|
77
|
+
|
78
|
+
cur = process.cwd();
|
79
|
+
_context.prev = 2;
|
80
|
+
thisPackage = JSON.parse((0, _fs.readFileSync)((0, _path.join)(cur, 'package.json'), 'utf-8'));
|
81
|
+
_context.next = 9;
|
82
|
+
break;
|
83
|
+
|
84
|
+
case 6:
|
85
|
+
_context.prev = 6;
|
86
|
+
_context.t0 = _context["catch"](2);
|
87
|
+
throw new Error('make sure you are inside of a telescope package!');
|
88
|
+
|
89
|
+
case 9:
|
90
|
+
_context.next = 11;
|
91
|
+
return (0, _prompt.prompt)([{
|
92
|
+
type: 'checkbox',
|
93
|
+
name: 'pkg',
|
94
|
+
message: 'which chain contracts do you want to support?',
|
95
|
+
choices: ['stargaze-claim', 'stargaze-ics721', 'stargaze-minter', 'stargaze-royalty-group', 'stargaze-sg721', 'stargaze-whitelist'].map(function (name) {
|
96
|
+
return {
|
97
|
+
name: name,
|
98
|
+
value: "@cosmjson/".concat(name)
|
99
|
+
};
|
100
|
+
})
|
101
|
+
}], argv);
|
102
|
+
|
103
|
+
case 11:
|
104
|
+
_yield$prompt = _context.sent;
|
105
|
+
pkg = _yield$prompt.pkg;
|
106
|
+
// install
|
107
|
+
if (!Array.isArray(pkg)) pkg = [pkg];
|
108
|
+
tmp = (0, _path.join)(TMPDIR, rnd());
|
109
|
+
(0, _mkdirp.sync)(tmp);
|
110
|
+
process.chdir(tmp);
|
111
|
+
(0, _shelljs.exec)("npm install ".concat(getPackages(pkg), " --production --prefix ./smart-contracts")); // protos
|
112
|
+
|
113
|
+
pkgs = (0, _glob.sync)('./smart-contracts/**/package.json');
|
114
|
+
cmds = pkgs.filter(function (f) {
|
115
|
+
return f !== './smart-contracts/package.json';
|
116
|
+
}).map(function (f) {
|
117
|
+
return (0, _path.resolve)((0, _path.join)(tmp, f));
|
118
|
+
}).map(function (conf) {
|
119
|
+
var extDir = (0, _path.dirname)(conf);
|
120
|
+
var dir = extDir.split('node_modules/')[1];
|
121
|
+
var dst = (0, _path.basename)(dir);
|
122
|
+
var files = (0, _glob.sync)("".concat(extDir, "/**/*"), {
|
123
|
+
nodir: true
|
124
|
+
});
|
125
|
+
files.forEach(function (f) {
|
126
|
+
if ((0, _path.extname)(f) === '.json' || f === 'package.json' || /license/i.test(f) || /readme/i.test(f)) return;
|
127
|
+
(0, _rimraf.sync)(f);
|
128
|
+
});
|
129
|
+
return [extDir, (0, _path.resolve)((0, _path.join)(cur, 'contracts', dst)), dir];
|
130
|
+
}); // move protos
|
131
|
+
|
132
|
+
_iterator = _createForOfIteratorHelper(cmds);
|
133
|
+
|
134
|
+
try {
|
135
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
136
|
+
_step$value = (0, _slicedToArray2["default"])(_step.value, 3), src = _step$value[0], dst = _step$value[1], _pkg = _step$value[2];
|
137
|
+
(0, _rimraf.sync)(dst);
|
138
|
+
console.log("installing ".concat(_pkg, "..."));
|
139
|
+
(0, _mkdirp.sync)((0, _path.dirname)(dst));
|
140
|
+
(0, _shelljs.exec)("mv ".concat(src, " ").concat(dst));
|
141
|
+
} // package
|
142
|
+
|
143
|
+
} catch (err) {
|
144
|
+
_iterator.e(err);
|
145
|
+
} finally {
|
146
|
+
_iterator.f();
|
147
|
+
}
|
148
|
+
|
149
|
+
packageInfo = JSON.parse((0, _fs.readFileSync)('./smart-contracts/package.json', 'utf-8'));
|
150
|
+
deps = (_packageInfo$dependen = packageInfo.dependencies) !== null && _packageInfo$dependen !== void 0 ? _packageInfo$dependen : {};
|
151
|
+
thisPackage.devDependencies = (_thisPackage$devDepen = thisPackage.devDependencies) !== null && _thisPackage$devDepen !== void 0 ? _thisPackage$devDepen : {};
|
152
|
+
thisPackage.devDependencies = _objectSpread(_objectSpread({}, thisPackage.devDependencies), deps);
|
153
|
+
thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
|
154
|
+
(0, _fs.writeFileSync)((0, _path.join)(cur, 'package.json'), JSON.stringify(thisPackage, null, 2)); // cleanup
|
155
|
+
|
156
|
+
(0, _rimraf.sync)(tmp);
|
157
|
+
process.chdir(cur);
|
158
|
+
|
159
|
+
case 30:
|
160
|
+
case "end":
|
161
|
+
return _context.stop();
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}, _callee, null, [[2, 6]]);
|
165
|
+
}));
|
166
|
+
|
167
|
+
return function (_x) {
|
168
|
+
return _ref.apply(this, arguments);
|
169
|
+
};
|
170
|
+
}();
|
171
|
+
|
172
|
+
exports["default"] = _default;
|
package/module/cmds.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import _create_boilerplate from './commands/create-boilerplate';
|
2
2
|
import _generate from './commands/generate';
|
3
|
+
import _install from './commands/install';
|
3
4
|
const Commands = {};
|
4
5
|
Commands['create-boilerplate'] = _create_boilerplate;
|
5
6
|
Commands['generate'] = _generate;
|
7
|
+
Commands['install'] = _install;
|
6
8
|
export { Commands };
|
@@ -0,0 +1,101 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
|
+
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
|
+
|
7
|
+
import { resolve, join, dirname, basename, extname } from 'path';
|
8
|
+
import { sync as mkdirp } from 'mkdirp';
|
9
|
+
import { sync as glob } from 'glob';
|
10
|
+
import { sync as rimraf } from 'rimraf';
|
11
|
+
import { exec } from 'shelljs';
|
12
|
+
import { prompt } from '../utils/prompt';
|
13
|
+
import { parse } from 'parse-package-name';
|
14
|
+
import { tmpdir } from 'os';
|
15
|
+
import { readFileSync, writeFileSync } from 'fs';
|
16
|
+
const TMPDIR = tmpdir();
|
17
|
+
|
18
|
+
const rnd = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
19
|
+
|
20
|
+
const getPackages = names => {
|
21
|
+
return names.map(pkg => {
|
22
|
+
const {
|
23
|
+
name,
|
24
|
+
version
|
25
|
+
} = parse(pkg);
|
26
|
+
return `${name}@${version}`;
|
27
|
+
}).join(' ');
|
28
|
+
};
|
29
|
+
|
30
|
+
export default (async argv => {
|
31
|
+
// don't prompt if we got this...
|
32
|
+
if (argv._.length) {
|
33
|
+
argv.pkg = argv._;
|
34
|
+
} // current dir/package
|
35
|
+
|
36
|
+
|
37
|
+
const cur = process.cwd();
|
38
|
+
let thisPackage;
|
39
|
+
|
40
|
+
try {
|
41
|
+
thisPackage = JSON.parse(readFileSync(join(cur, 'package.json'), 'utf-8'));
|
42
|
+
} catch (e) {
|
43
|
+
throw new Error('make sure you are inside of a telescope package!');
|
44
|
+
} // what are we installing?
|
45
|
+
|
46
|
+
|
47
|
+
let {
|
48
|
+
pkg
|
49
|
+
} = await prompt([{
|
50
|
+
type: 'checkbox',
|
51
|
+
name: 'pkg',
|
52
|
+
message: 'which chain contracts do you want to support?',
|
53
|
+
choices: ['stargaze-claim', 'stargaze-ics721', 'stargaze-minter', 'stargaze-royalty-group', 'stargaze-sg721', 'stargaze-whitelist'].map(name => {
|
54
|
+
return {
|
55
|
+
name,
|
56
|
+
value: `@cosmjson/${name}`
|
57
|
+
};
|
58
|
+
})
|
59
|
+
}], argv); // install
|
60
|
+
|
61
|
+
if (!Array.isArray(pkg)) pkg = [pkg];
|
62
|
+
const tmp = join(TMPDIR, rnd());
|
63
|
+
mkdirp(tmp);
|
64
|
+
process.chdir(tmp);
|
65
|
+
exec(`npm install ${getPackages(pkg)} --production --prefix ./smart-contracts`); // protos
|
66
|
+
|
67
|
+
const pkgs = glob('./smart-contracts/**/package.json');
|
68
|
+
const cmds = pkgs.filter(f => {
|
69
|
+
return f !== './smart-contracts/package.json';
|
70
|
+
}).map(f => resolve(join(tmp, f))).map(conf => {
|
71
|
+
const extDir = dirname(conf);
|
72
|
+
const dir = extDir.split('node_modules/')[1];
|
73
|
+
const dst = basename(dir);
|
74
|
+
const files = glob(`${extDir}/**/*`, {
|
75
|
+
nodir: true
|
76
|
+
});
|
77
|
+
files.forEach(f => {
|
78
|
+
if (extname(f) === '.json' || f === 'package.json' || /license/i.test(f) || /readme/i.test(f)) return;
|
79
|
+
rimraf(f);
|
80
|
+
});
|
81
|
+
return [extDir, resolve(join(cur, 'contracts', dst)), dir];
|
82
|
+
}); // move protos
|
83
|
+
|
84
|
+
for (const [src, dst, pkg] of cmds) {
|
85
|
+
rimraf(dst);
|
86
|
+
console.log(`installing ${pkg}...`);
|
87
|
+
mkdirp(dirname(dst));
|
88
|
+
exec(`mv ${src} ${dst}`);
|
89
|
+
} // package
|
90
|
+
|
91
|
+
|
92
|
+
const packageInfo = JSON.parse(readFileSync('./smart-contracts/package.json', 'utf-8'));
|
93
|
+
const deps = packageInfo.dependencies ?? {};
|
94
|
+
thisPackage.devDependencies = thisPackage.devDependencies ?? {};
|
95
|
+
thisPackage.devDependencies = _objectSpread(_objectSpread({}, thisPackage.devDependencies), deps);
|
96
|
+
thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
|
97
|
+
writeFileSync(join(cur, 'package.json'), JSON.stringify(thisPackage, null, 2)); // cleanup
|
98
|
+
|
99
|
+
rimraf(tmp);
|
100
|
+
process.chdir(cur);
|
101
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cosmwasm/ts-codegen",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.9.0",
|
4
4
|
"description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
6
6
|
"homepage": "https://github.com/cosmwasm/ts-codegen",
|
@@ -94,5 +94,5 @@
|
|
94
94
|
"shelljs": "0.8.5",
|
95
95
|
"wasm-ast-types": "^0.7.0"
|
96
96
|
},
|
97
|
-
"gitHead": "
|
97
|
+
"gitHead": "5fec84e69c9fea584d0180701844eaca183ea76b"
|
98
98
|
}
|