@cosmwasm/ts-codegen 0.34.2 → 0.35.1
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 +83 -20
- package/main/builder/builder.js +145 -247
- package/main/builder/index.js +0 -2
- package/main/bundler/bundler.js +3 -16
- package/main/bundler/index.js +0 -2
- package/main/cli.js +20 -38
- package/main/cmds.js +0 -5
- package/main/commands/create-boilerplate.js +132 -160
- package/main/commands/generate.js +168 -192
- package/main/commands/install.js +89 -123
- package/main/file.js +13 -25
- package/main/generators/client.js +55 -81
- package/main/generators/create-helpers.js +0 -14
- package/main/generators/message-composer.js +42 -68
- package/main/generators/msg-builder.js +49 -78
- package/main/generators/react-query.js +68 -92
- package/main/generators/recoil.js +47 -71
- package/main/generators/types.js +45 -73
- package/main/helpers/index.js +0 -6
- package/main/index.js +8 -30
- package/main/plugins/client.js +56 -90
- package/main/plugins/index.js +0 -2
- package/main/plugins/{msg-builder.js → message-builder.js} +56 -93
- package/main/plugins/message-composer.js +42 -76
- package/main/plugins/plugin-base.js +40 -70
- package/main/plugins/provider-bundle.js +42 -81
- package/main/plugins/provider.js +58 -103
- package/main/plugins/react-query.js +67 -99
- package/main/plugins/recoil.js +45 -82
- package/main/plugins/types.js +34 -68
- package/main/ts-codegen.js +7 -15
- package/main/utils/clean.js +8 -17
- package/main/utils/cleanse.js +10 -25
- package/main/utils/files.js +2 -22
- package/main/utils/header.js +0 -3
- package/main/utils/index.js +0 -2
- package/main/utils/parse.js +2 -7
- package/main/utils/prompt.js +16 -36
- package/main/utils/schemas.js +86 -133
- package/main/utils/unused.js +4 -15
- package/module/builder/builder.js +12 -33
- package/module/bundler/bundler.js +3 -3
- package/module/cli.js +0 -1
- package/module/commands/create-boilerplate.js +6 -19
- package/module/commands/generate.js +14 -19
- package/module/commands/install.js +14 -17
- package/module/file.js +0 -3
- package/module/generators/client.js +6 -7
- package/module/generators/create-helpers.js +0 -4
- package/module/generators/message-composer.js +4 -5
- package/module/generators/msg-builder.js +10 -14
- package/module/generators/react-query.js +8 -9
- package/module/generators/recoil.js +2 -3
- package/module/generators/types.js +4 -6
- package/module/plugins/client.js +4 -10
- package/module/plugins/{msg-builder.js → message-builder.js} +10 -18
- package/module/plugins/message-composer.js +4 -10
- package/module/plugins/plugin-base.js +10 -10
- package/module/plugins/provider-bundle.js +0 -10
- package/module/plugins/provider.js +0 -14
- package/module/plugins/react-query.js +8 -13
- package/module/plugins/recoil.js +2 -9
- package/module/plugins/types.js +4 -7
- package/module/ts-codegen.js +0 -2
- package/module/utils/clean.js +8 -13
- package/module/utils/cleanse.js +10 -21
- package/module/utils/files.js +2 -6
- package/module/utils/parse.js +2 -4
- package/module/utils/prompt.js +0 -5
- package/module/utils/schemas.js +2 -13
- package/module/utils/unused.js +4 -6
- package/package.json +3 -3
- package/src/builder/builder.ts +7 -6
- package/src/commands/generate.ts +14 -13
- package/src/generators/msg-builder.ts +7 -9
- package/src/plugins/{msg-builder.ts → message-builder.ts} +6 -6
- package/src/plugins/message-composer.ts +2 -2
- package/types/src/builder/builder.d.ts +3 -2
- package/types/src/generators/msg-builder.d.ts +2 -2
- package/types/src/generators/msg-builder.ts +2 -2
- package/types/src/plugins/message-builder.d.ts +12 -0
- package/types/src/plugins/msg-builder.d.ts +1 -1
@@ -1,220 +1,196 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports["default"] = void 0;
|
9
|
-
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
-
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
13
|
-
|
14
10
|
var _prompt = require("../utils/prompt");
|
15
|
-
|
16
11
|
var _index = _interopRequireDefault(require("../index"));
|
17
|
-
|
18
12
|
var _default = /*#__PURE__*/function () {
|
19
13
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(argv) {
|
20
14
|
var questions, _yield$prompt, schema, out, name, plugin, bundle, questions2, _yield$prompt2, optionalClient, version, queryKeys, questions3, _yield$prompt3, mutations, queryFactoryQuestions, _yield$prompt4, queryFactory, questions4, _yield$prompt5, bundleFile, bundleScope, options;
|
21
|
-
|
22
15
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
23
|
-
while (1) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
16
|
+
while (1) switch (_context.prev = _context.next) {
|
17
|
+
case 0:
|
18
|
+
questions = [{
|
19
|
+
_: true,
|
20
|
+
type: 'path',
|
21
|
+
name: 'schema',
|
22
|
+
message: 'which directory contains the the Rust contracts?',
|
23
|
+
"default": './schema'
|
24
|
+
}, {
|
25
|
+
_: true,
|
26
|
+
type: 'path',
|
27
|
+
name: 'out',
|
28
|
+
message: 'where is the output directory?',
|
29
|
+
"default": './ts'
|
30
|
+
}, {
|
31
|
+
_: true,
|
32
|
+
type: 'string',
|
33
|
+
name: 'name',
|
34
|
+
message: 'contract name?'
|
35
|
+
}, {
|
36
|
+
type: 'checkbox',
|
37
|
+
name: 'plugin',
|
38
|
+
message: 'which plugins?',
|
39
|
+
choices: ['client', 'recoil', 'react-query', 'message-composer']
|
40
|
+
}, {
|
41
|
+
type: 'confirm',
|
42
|
+
name: 'bundle',
|
43
|
+
message: 'enable bundle?',
|
44
|
+
"default": true
|
45
|
+
}];
|
46
|
+
if (argv.typesOnly) {
|
47
|
+
argv.plugin = 'types';
|
48
|
+
}
|
49
|
+
_context.next = 4;
|
50
|
+
return (0, _prompt.prompt)(questions, argv);
|
51
|
+
case 4:
|
52
|
+
_yield$prompt = _context.sent;
|
53
|
+
schema = _yield$prompt.schema;
|
54
|
+
out = _yield$prompt.out;
|
55
|
+
name = _yield$prompt.name;
|
56
|
+
plugin = _yield$prompt.plugin;
|
57
|
+
bundle = _yield$prompt.bundle;
|
58
|
+
if (!Array.isArray(plugin)) plugin = [plugin];
|
59
|
+
|
60
|
+
///////// REACT QUERY
|
61
|
+
questions2 = [];
|
62
|
+
if (plugin.includes('react-query')) {
|
63
|
+
[].push.apply(questions2, [{
|
64
|
+
type: 'confirm',
|
65
|
+
name: 'optionalClient',
|
66
|
+
message: 'optionalClient?',
|
67
|
+
"default": false
|
32
68
|
}, {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
69
|
+
type: 'list',
|
70
|
+
name: 'version',
|
71
|
+
message: 'which react-query version?',
|
72
|
+
"default": 'v4',
|
73
|
+
choices: ['v3', 'v4']
|
38
74
|
}, {
|
39
|
-
|
75
|
+
type: 'confirm',
|
76
|
+
name: 'queryKeys',
|
77
|
+
message: 'queryKeys?',
|
78
|
+
"default": false
|
79
|
+
}]);
|
80
|
+
}
|
81
|
+
;
|
82
|
+
_context.next = 16;
|
83
|
+
return (0, _prompt.prompt)(questions2, argv);
|
84
|
+
case 16:
|
85
|
+
_yield$prompt2 = _context.sent;
|
86
|
+
optionalClient = _yield$prompt2.optionalClient;
|
87
|
+
version = _yield$prompt2.version;
|
88
|
+
queryKeys = _yield$prompt2.queryKeys;
|
89
|
+
questions3 = [];
|
90
|
+
if (version === 'v4') {
|
91
|
+
[].push.apply(questions3, [
|
92
|
+
// currently we only support v4 for useMutation
|
93
|
+
{
|
94
|
+
type: 'confirm',
|
95
|
+
name: 'mutations',
|
96
|
+
message: 'Generate useMutation hooks?',
|
97
|
+
"default": false
|
98
|
+
}]);
|
99
|
+
}
|
100
|
+
;
|
101
|
+
_context.next = 25;
|
102
|
+
return (0, _prompt.prompt)(questions3, argv);
|
103
|
+
case 25:
|
104
|
+
_yield$prompt3 = _context.sent;
|
105
|
+
mutations = _yield$prompt3.mutations;
|
106
|
+
queryFactoryQuestions = [];
|
107
|
+
if (queryKeys) {
|
108
|
+
[].push.apply(queryFactoryQuestions, [
|
109
|
+
// Only can use queryFactory if queryKeys is enabled
|
110
|
+
{
|
111
|
+
type: 'confirm',
|
112
|
+
name: 'queryFactory',
|
113
|
+
message: 'queryFactory? ',
|
114
|
+
"default": false
|
115
|
+
}]);
|
116
|
+
}
|
117
|
+
;
|
118
|
+
_context.next = 32;
|
119
|
+
return (0, _prompt.prompt)(queryFactoryQuestions, argv);
|
120
|
+
case 32:
|
121
|
+
_yield$prompt4 = _context.sent;
|
122
|
+
queryFactory = _yield$prompt4.queryFactory;
|
123
|
+
///////// END REACT QUERY
|
124
|
+
///////// BUNDLE
|
125
|
+
questions4 = [];
|
126
|
+
if (bundle) {
|
127
|
+
[].push.apply(questions4, [{
|
40
128
|
type: 'string',
|
41
|
-
name: '
|
42
|
-
message: '
|
43
|
-
|
44
|
-
type: 'checkbox',
|
45
|
-
name: 'plugin',
|
46
|
-
message: 'which plugins?',
|
47
|
-
choices: ['client', 'recoil', 'react-query', 'message-composer']
|
129
|
+
name: 'bundleFile',
|
130
|
+
message: 'bundleFile?',
|
131
|
+
"default": 'index.ts'
|
48
132
|
}, {
|
49
|
-
type: '
|
50
|
-
name: '
|
51
|
-
message: '
|
52
|
-
"default":
|
53
|
-
}];
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
;
|
94
|
-
_context.next = 16;
|
95
|
-
return (0, _prompt.prompt)(questions2, argv);
|
96
|
-
|
97
|
-
case 16:
|
98
|
-
_yield$prompt2 = _context.sent;
|
99
|
-
optionalClient = _yield$prompt2.optionalClient;
|
100
|
-
version = _yield$prompt2.version;
|
101
|
-
queryKeys = _yield$prompt2.queryKeys;
|
102
|
-
questions3 = [];
|
103
|
-
|
104
|
-
if (version === 'v4') {
|
105
|
-
[].push.apply(questions3, [// currently we only support v4 for useMutation
|
106
|
-
{
|
107
|
-
type: 'confirm',
|
108
|
-
name: 'mutations',
|
109
|
-
message: 'Generate useMutation hooks?',
|
110
|
-
"default": false
|
111
|
-
}]);
|
112
|
-
}
|
113
|
-
|
114
|
-
;
|
115
|
-
_context.next = 25;
|
116
|
-
return (0, _prompt.prompt)(questions3, argv);
|
117
|
-
|
118
|
-
case 25:
|
119
|
-
_yield$prompt3 = _context.sent;
|
120
|
-
mutations = _yield$prompt3.mutations;
|
121
|
-
queryFactoryQuestions = [];
|
122
|
-
|
123
|
-
if (queryKeys) {
|
124
|
-
[].push.apply(queryFactoryQuestions, [// Only can use queryFactory if queryKeys is enabled
|
125
|
-
{
|
126
|
-
type: 'confirm',
|
127
|
-
name: 'queryFactory',
|
128
|
-
message: 'queryFactory? ',
|
129
|
-
"default": false
|
130
|
-
}]);
|
131
|
-
}
|
132
|
-
|
133
|
-
;
|
134
|
-
_context.next = 32;
|
135
|
-
return (0, _prompt.prompt)(queryFactoryQuestions, argv);
|
136
|
-
|
137
|
-
case 32:
|
138
|
-
_yield$prompt4 = _context.sent;
|
139
|
-
queryFactory = _yield$prompt4.queryFactory;
|
140
|
-
///////// END REACT QUERY
|
141
|
-
///////// BUNDLE
|
142
|
-
questions4 = [];
|
143
|
-
|
144
|
-
if (bundle) {
|
145
|
-
[].push.apply(questions4, [{
|
146
|
-
type: 'string',
|
147
|
-
name: 'bundleFile',
|
148
|
-
message: 'bundleFile?',
|
149
|
-
"default": 'index.ts'
|
150
|
-
}, {
|
151
|
-
type: 'string',
|
152
|
-
name: 'bundleScope',
|
153
|
-
message: 'bundleScope?',
|
154
|
-
"default": 'contracts'
|
155
|
-
}]);
|
133
|
+
type: 'string',
|
134
|
+
name: 'bundleScope',
|
135
|
+
message: 'bundleScope?',
|
136
|
+
"default": 'contracts'
|
137
|
+
}]);
|
138
|
+
}
|
139
|
+
;
|
140
|
+
_context.next = 39;
|
141
|
+
return (0, _prompt.prompt)(questions4, argv);
|
142
|
+
case 39:
|
143
|
+
_yield$prompt5 = _context.sent;
|
144
|
+
bundleFile = _yield$prompt5.bundleFile;
|
145
|
+
bundleScope = _yield$prompt5.bundleScope;
|
146
|
+
///////// END BUNDLE
|
147
|
+
options = {
|
148
|
+
types: {
|
149
|
+
enabled: true
|
150
|
+
},
|
151
|
+
client: {
|
152
|
+
enabled: plugin.includes('client') || plugin.includes('recoil') || plugin.includes('react-query')
|
153
|
+
},
|
154
|
+
reactQuery: {
|
155
|
+
enabled: plugin.includes('react-query'),
|
156
|
+
optionalClient: optionalClient,
|
157
|
+
queryKeys: queryKeys,
|
158
|
+
version: version,
|
159
|
+
mutations: mutations,
|
160
|
+
queryFactory: queryFactory
|
161
|
+
},
|
162
|
+
recoil: {
|
163
|
+
enabled: plugin.includes('recoil')
|
164
|
+
},
|
165
|
+
messageComposer: {
|
166
|
+
enabled: plugin.includes('message-composer')
|
167
|
+
},
|
168
|
+
messageBuilder: {
|
169
|
+
enabled: plugin.includes('message-builder')
|
170
|
+
},
|
171
|
+
bundle: {
|
172
|
+
enabled: bundle,
|
173
|
+
scope: bundleScope,
|
174
|
+
bundleFile: bundleFile
|
156
175
|
}
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
},
|
171
|
-
client: {
|
172
|
-
enabled: plugin.includes('client') || plugin.includes('recoil') || plugin.includes('react-query')
|
173
|
-
},
|
174
|
-
reactQuery: {
|
175
|
-
enabled: plugin.includes('react-query'),
|
176
|
-
optionalClient: optionalClient,
|
177
|
-
queryKeys: queryKeys,
|
178
|
-
version: version,
|
179
|
-
mutations: mutations,
|
180
|
-
queryFactory: queryFactory
|
181
|
-
},
|
182
|
-
recoil: {
|
183
|
-
enabled: plugin.includes('recoil')
|
184
|
-
},
|
185
|
-
messageComposer: {
|
186
|
-
enabled: plugin.includes('message-composer')
|
187
|
-
},
|
188
|
-
msgBuilder: {
|
189
|
-
enabled: plugin.includes('msg-builder')
|
190
|
-
},
|
191
|
-
bundle: {
|
192
|
-
enabled: bundle,
|
193
|
-
scope: bundleScope,
|
194
|
-
bundleFile: bundleFile
|
195
|
-
}
|
196
|
-
};
|
197
|
-
_context.next = 45;
|
198
|
-
return (0, _index["default"])({
|
199
|
-
contracts: [{
|
200
|
-
name: name,
|
201
|
-
dir: schema
|
202
|
-
}],
|
203
|
-
outPath: out,
|
204
|
-
options: options
|
205
|
-
});
|
206
|
-
|
207
|
-
case 45:
|
208
|
-
case "end":
|
209
|
-
return _context.stop();
|
210
|
-
}
|
176
|
+
};
|
177
|
+
_context.next = 45;
|
178
|
+
return (0, _index["default"])({
|
179
|
+
contracts: [{
|
180
|
+
name: name,
|
181
|
+
dir: schema
|
182
|
+
}],
|
183
|
+
outPath: out,
|
184
|
+
options: options
|
185
|
+
});
|
186
|
+
case 45:
|
187
|
+
case "end":
|
188
|
+
return _context.stop();
|
211
189
|
}
|
212
190
|
}, _callee);
|
213
191
|
}));
|
214
|
-
|
215
192
|
return function (_x) {
|
216
193
|
return _ref.apply(this, arguments);
|
217
194
|
};
|
218
195
|
}();
|
219
|
-
|
220
196
|
exports["default"] = _default;
|
package/main/commands/install.js
CHANGED
@@ -1,172 +1,138 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports["default"] = void 0;
|
9
|
-
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
-
|
12
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
-
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
-
|
16
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
17
|
-
|
18
12
|
var _path = require("path");
|
19
|
-
|
20
13
|
var _mkdirp = require("mkdirp");
|
21
|
-
|
22
14
|
var _glob = require("glob");
|
23
|
-
|
24
15
|
var _rimraf = require("rimraf");
|
25
|
-
|
26
16
|
var _shelljs = require("shelljs");
|
27
|
-
|
28
17
|
var _prompt = require("../utils/prompt");
|
29
|
-
|
30
18
|
var _parsePackageName = require("parse-package-name");
|
31
|
-
|
32
19
|
var _os = require("os");
|
33
|
-
|
34
20
|
var _fs = require("fs");
|
35
|
-
|
36
21
|
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
22
|
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
23
|
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
24
|
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
|
-
|
25
|
+
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; }
|
46
26
|
var TMPDIR = (0, _os.tmpdir)();
|
47
|
-
|
48
27
|
var rnd = function rnd() {
|
49
28
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
50
29
|
};
|
51
|
-
|
52
30
|
var getPackages = function getPackages(names) {
|
53
31
|
return names.map(function (pkg) {
|
54
32
|
var _parse = (0, _parsePackageName.parse)(pkg),
|
55
|
-
|
56
|
-
|
57
|
-
|
33
|
+
name = _parse.name,
|
34
|
+
version = _parse.version;
|
58
35
|
return "".concat(name, "@").concat(version);
|
59
36
|
}).join(' ');
|
60
37
|
};
|
61
|
-
|
62
38
|
var _default = /*#__PURE__*/function () {
|
63
39
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(argv) {
|
64
40
|
var _packageInfo$dependen, _thisPackage$devDepen;
|
65
|
-
|
66
41
|
var cur, thisPackage, _yield$prompt, pkg, tmp, pkgs, cmds, _iterator, _step, _step$value, src, dst, _pkg, packageInfo, deps;
|
67
|
-
|
68
42
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
69
|
-
while (1) {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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();
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
44
|
+
case 0:
|
45
|
+
// don't prompt if we got this...
|
46
|
+
if (argv._.length) {
|
47
|
+
argv.pkg = argv._;
|
48
|
+
}
|
49
|
+
|
50
|
+
// current dir/package
|
51
|
+
cur = process.cwd();
|
52
|
+
_context.prev = 2;
|
53
|
+
thisPackage = JSON.parse((0, _fs.readFileSync)((0, _path.join)(cur, 'package.json'), 'utf-8'));
|
54
|
+
_context.next = 9;
|
55
|
+
break;
|
56
|
+
case 6:
|
57
|
+
_context.prev = 6;
|
58
|
+
_context.t0 = _context["catch"](2);
|
59
|
+
throw new Error('make sure you are inside of a telescope package!');
|
60
|
+
case 9:
|
61
|
+
_context.next = 11;
|
62
|
+
return (0, _prompt.prompt)([{
|
63
|
+
type: 'checkbox',
|
64
|
+
name: 'pkg',
|
65
|
+
message: 'which chain contracts do you want to support?',
|
66
|
+
choices: ['stargaze-base-factory', 'stargaze-base-minter', 'stargaze-sg721-base', 'stargaze-sg721-metdata-onchain', 'stargaze-sg721-nt', 'stargaze-splits', 'stargaze-vending-factory', 'stargaze-vending-minter', 'stargaze-whitelist', 'wasmswap'].map(function (name) {
|
67
|
+
return {
|
68
|
+
name: name,
|
69
|
+
value: "@cosmjson/".concat(name)
|
70
|
+
};
|
71
|
+
})
|
72
|
+
}], argv);
|
73
|
+
case 11:
|
74
|
+
_yield$prompt = _context.sent;
|
75
|
+
pkg = _yield$prompt.pkg;
|
76
|
+
// install
|
77
|
+
if (!Array.isArray(pkg)) pkg = [pkg];
|
78
|
+
tmp = (0, _path.join)(TMPDIR, rnd());
|
79
|
+
(0, _mkdirp.sync)(tmp);
|
80
|
+
process.chdir(tmp);
|
81
|
+
(0, _shelljs.exec)("npm install ".concat(getPackages(pkg), " --production --prefix ./smart-contracts"));
|
82
|
+
|
83
|
+
// protos
|
84
|
+
pkgs = (0, _glob.sync)('./smart-contracts/**/package.json');
|
85
|
+
cmds = pkgs.filter(function (f) {
|
86
|
+
return f !== './smart-contracts/package.json';
|
87
|
+
}).map(function (f) {
|
88
|
+
return (0, _path.resolve)((0, _path.join)(tmp, f));
|
89
|
+
}).map(function (conf) {
|
90
|
+
var extDir = (0, _path.dirname)(conf);
|
91
|
+
var dir = extDir.split('node_modules/')[1];
|
92
|
+
var dst = (0, _path.basename)(dir);
|
93
|
+
var files = (0, _glob.sync)("".concat(extDir, "/**/*"), {
|
94
|
+
nodir: true
|
95
|
+
});
|
96
|
+
files.forEach(function (f) {
|
97
|
+
if ((0, _path.extname)(f) === '.json' || f === 'package.json' || /license/i.test(f) || /readme/i.test(f)) return;
|
98
|
+
(0, _rimraf.sync)(f);
|
99
|
+
});
|
100
|
+
return [extDir, (0, _path.resolve)((0, _path.join)(cur, 'contracts', dst)), dir];
|
101
|
+
}); // move protos
|
102
|
+
_iterator = _createForOfIteratorHelper(cmds);
|
103
|
+
try {
|
104
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
105
|
+
_step$value = (0, _slicedToArray2["default"])(_step.value, 3), src = _step$value[0], dst = _step$value[1], _pkg = _step$value[2];
|
106
|
+
(0, _rimraf.sync)(dst);
|
107
|
+
console.log("installing ".concat(_pkg, "..."));
|
108
|
+
(0, _mkdirp.sync)((0, _path.dirname)(dst));
|
109
|
+
(0, _shelljs.exec)("mv ".concat(src, " ").concat(dst));
|
147
110
|
}
|
148
111
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
112
|
+
// package
|
113
|
+
} catch (err) {
|
114
|
+
_iterator.e(err);
|
115
|
+
} finally {
|
116
|
+
_iterator.f();
|
117
|
+
}
|
118
|
+
packageInfo = JSON.parse((0, _fs.readFileSync)('./smart-contracts/package.json', 'utf-8'));
|
119
|
+
deps = (_packageInfo$dependen = packageInfo.dependencies) !== null && _packageInfo$dependen !== void 0 ? _packageInfo$dependen : {};
|
120
|
+
thisPackage.devDependencies = (_thisPackage$devDepen = thisPackage.devDependencies) !== null && _thisPackage$devDepen !== void 0 ? _thisPackage$devDepen : {};
|
121
|
+
thisPackage.devDependencies = _objectSpread(_objectSpread({}, thisPackage.devDependencies), deps);
|
122
|
+
thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
|
123
|
+
(0, _fs.writeFileSync)((0, _path.join)(cur, 'package.json'), JSON.stringify(thisPackage, null, 2));
|
124
|
+
|
125
|
+
// cleanup
|
126
|
+
(0, _rimraf.sync)(tmp);
|
127
|
+
process.chdir(cur);
|
128
|
+
case 30:
|
129
|
+
case "end":
|
130
|
+
return _context.stop();
|
163
131
|
}
|
164
132
|
}, _callee, null, [[2, 6]]);
|
165
133
|
}));
|
166
|
-
|
167
134
|
return function (_x) {
|
168
135
|
return _ref.apply(this, arguments);
|
169
136
|
};
|
170
137
|
}();
|
171
|
-
|
172
138
|
exports["default"] = _default;
|