@cosmwasm/ts-codegen 0.34.2 → 0.35.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.
Files changed (82) hide show
  1. package/README.md +83 -20
  2. package/main/builder/builder.js +145 -247
  3. package/main/builder/index.js +0 -2
  4. package/main/bundler/bundler.js +3 -16
  5. package/main/bundler/index.js +0 -2
  6. package/main/cli.js +20 -38
  7. package/main/cmds.js +0 -5
  8. package/main/commands/create-boilerplate.js +132 -160
  9. package/main/commands/generate.js +168 -192
  10. package/main/commands/install.js +89 -123
  11. package/main/file.js +13 -25
  12. package/main/generators/client.js +55 -81
  13. package/main/generators/create-helpers.js +0 -14
  14. package/main/generators/message-composer.js +42 -68
  15. package/main/generators/msg-builder.js +49 -78
  16. package/main/generators/react-query.js +68 -92
  17. package/main/generators/recoil.js +47 -71
  18. package/main/generators/types.js +45 -73
  19. package/main/helpers/index.js +0 -6
  20. package/main/index.js +8 -30
  21. package/main/plugins/client.js +56 -90
  22. package/main/plugins/index.js +0 -2
  23. package/main/plugins/{msg-builder.js → message-builder.js} +56 -93
  24. package/main/plugins/message-composer.js +42 -76
  25. package/main/plugins/plugin-base.js +40 -70
  26. package/main/plugins/provider-bundle.js +42 -81
  27. package/main/plugins/provider.js +58 -103
  28. package/main/plugins/react-query.js +67 -99
  29. package/main/plugins/recoil.js +45 -82
  30. package/main/plugins/types.js +34 -68
  31. package/main/ts-codegen.js +7 -15
  32. package/main/utils/clean.js +8 -17
  33. package/main/utils/cleanse.js +10 -25
  34. package/main/utils/files.js +2 -22
  35. package/main/utils/header.js +0 -3
  36. package/main/utils/index.js +0 -2
  37. package/main/utils/parse.js +2 -7
  38. package/main/utils/prompt.js +16 -36
  39. package/main/utils/schemas.js +86 -133
  40. package/main/utils/unused.js +4 -15
  41. package/module/builder/builder.js +12 -33
  42. package/module/bundler/bundler.js +3 -3
  43. package/module/cli.js +0 -1
  44. package/module/commands/create-boilerplate.js +6 -19
  45. package/module/commands/generate.js +13 -18
  46. package/module/commands/install.js +14 -17
  47. package/module/file.js +0 -3
  48. package/module/generators/client.js +6 -7
  49. package/module/generators/create-helpers.js +0 -4
  50. package/module/generators/message-composer.js +4 -5
  51. package/module/generators/msg-builder.js +10 -14
  52. package/module/generators/react-query.js +8 -9
  53. package/module/generators/recoil.js +2 -3
  54. package/module/generators/types.js +4 -6
  55. package/module/plugins/client.js +4 -10
  56. package/module/plugins/{msg-builder.js → message-builder.js} +10 -18
  57. package/module/plugins/message-composer.js +4 -10
  58. package/module/plugins/plugin-base.js +10 -10
  59. package/module/plugins/provider-bundle.js +0 -10
  60. package/module/plugins/provider.js +0 -14
  61. package/module/plugins/react-query.js +8 -13
  62. package/module/plugins/recoil.js +2 -9
  63. package/module/plugins/types.js +4 -7
  64. package/module/ts-codegen.js +0 -2
  65. package/module/utils/clean.js +8 -13
  66. package/module/utils/cleanse.js +10 -21
  67. package/module/utils/files.js +2 -6
  68. package/module/utils/parse.js +2 -4
  69. package/module/utils/prompt.js +0 -5
  70. package/module/utils/schemas.js +2 -13
  71. package/module/utils/unused.js +4 -6
  72. package/package.json +3 -3
  73. package/src/builder/builder.ts +7 -6
  74. package/src/commands/generate.ts +13 -12
  75. package/src/generators/msg-builder.ts +7 -9
  76. package/src/plugins/{msg-builder.ts → message-builder.ts} +6 -6
  77. package/src/plugins/message-composer.ts +2 -2
  78. package/types/src/builder/builder.d.ts +3 -2
  79. package/types/src/generators/msg-builder.d.ts +2 -2
  80. package/types/src/generators/msg-builder.ts +2 -2
  81. package/types/src/plugins/message-builder.d.ts +12 -0
  82. 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
- switch (_context.prev = _context.next) {
25
- case 0:
26
- questions = [{
27
- _: true,
28
- type: 'path',
29
- name: 'schema',
30
- message: 'which directory contains the the Rust contracts?',
31
- "default": './schema'
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
- _: true,
34
- type: 'path',
35
- name: 'out',
36
- message: 'where is the output directory?',
37
- "default": './ts'
69
+ type: 'list',
70
+ name: 'version',
71
+ message: 'which react-query version?',
72
+ "default": 'v3',
73
+ choices: ['v3', 'v4']
38
74
  }, {
39
- _: true,
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: 'name',
42
- message: 'contract name?'
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: 'confirm',
50
- name: 'bundle',
51
- message: 'enable bundle?',
52
- "default": true
53
- }];
54
-
55
- if (argv.typesOnly) {
56
- argv.plugin = 'types';
57
- }
58
-
59
- _context.next = 4;
60
- return (0, _prompt.prompt)(questions, argv);
61
-
62
- case 4:
63
- _yield$prompt = _context.sent;
64
- schema = _yield$prompt.schema;
65
- out = _yield$prompt.out;
66
- name = _yield$prompt.name;
67
- plugin = _yield$prompt.plugin;
68
- bundle = _yield$prompt.bundle;
69
- if (!Array.isArray(plugin)) plugin = [plugin]; ///////// REACT QUERY
70
-
71
- questions2 = [];
72
-
73
- if (plugin.includes('react-query')) {
74
- [].push.apply(questions2, [{
75
- type: 'confirm',
76
- name: 'optionalClient',
77
- message: 'optionalClient?',
78
- "default": false
79
- }, {
80
- type: 'list',
81
- name: 'version',
82
- message: 'which react-query version?',
83
- "default": 'v3',
84
- choices: ['v3', 'v4']
85
- }, {
86
- type: 'confirm',
87
- name: 'queryKeys',
88
- message: 'queryKeys?',
89
- "default": false
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
- _context.next = 39;
160
- return (0, _prompt.prompt)(questions4, argv);
161
-
162
- case 39:
163
- _yield$prompt5 = _context.sent;
164
- bundleFile = _yield$prompt5.bundleFile;
165
- bundleScope = _yield$prompt5.bundleScope;
166
- ///////// END BUNDLE
167
- options = {
168
- types: {
169
- enabled: true
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;
@@ -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
- name = _parse.name,
56
- version = _parse.version;
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
- 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-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) {
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();
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
- 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
- }
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;