@cosmwasm/ts-codegen 0.6.1 → 0.7.2
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 +198 -17
- package/main/cli.js +1 -1
- package/main/cmds.js +0 -3
- package/main/commands/from-partial.js +9 -5
- package/main/commands/generate.js +10 -6
- package/main/commands/react-query.js +9 -5
- package/main/commands/recoil.js +9 -5
- package/main/file.js +1 -1
- package/main/{from-partial.js → generators/from-partial.js} +8 -7
- package/main/{react-query.js → generators/react-query.js} +16 -12
- package/main/{recoil.js → generators/recoil.js} +8 -7
- package/main/{generate.js → generators/ts-client.js} +12 -11
- package/main/index.js +12 -12
- package/main/{clean.js → utils/clean.js} +0 -0
- package/main/{cleanse.js → utils/cleanse.js} +0 -0
- package/main/{header.js → utils/header.js} +1 -1
- package/main/{imports.js → utils/imports.js} +0 -0
- package/main/utils/index.js +18 -0
- package/main/{parse.js → utils/parse.js} +0 -0
- package/main/{prompt.js → utils/prompt.js} +0 -0
- package/main/utils/schemas.js +167 -0
- package/module/cli.js +1 -1
- package/module/cmds.js +0 -2
- package/module/commands/from-partial.js +3 -3
- package/module/commands/generate.js +4 -4
- package/module/commands/react-query.js +3 -3
- package/module/commands/recoil.js +3 -3
- package/module/file.js +1 -1
- package/module/{from-partial.js → generators/from-partial.js} +7 -5
- package/module/{react-query.js → generators/react-query.js} +13 -8
- package/module/{recoil.js → generators/recoil.js} +7 -5
- package/module/{generate.js → generators/ts-client.js} +11 -9
- package/module/index.js +5 -5
- package/module/{clean.js → utils/clean.js} +0 -0
- package/module/{cleanse.js → utils/cleanse.js} +0 -0
- package/module/{header.js → utils/header.js} +1 -1
- package/module/{imports.js → utils/imports.js} +0 -0
- package/module/utils/index.js +1 -0
- package/module/{parse.js → utils/parse.js} +0 -0
- package/module/{prompt.js → utils/prompt.js} +0 -0
- package/module/{utils.js → utils/schemas.js} +18 -1
- package/package.json +4 -4
- package/types/cleanse.d.ts +1 -0
- package/types/generators/from-partial.d.ts +2 -0
- package/types/generators/react-query.d.ts +2 -0
- package/types/generators/recoil.d.ts +2 -0
- package/types/generators/ts-client.d.ts +2 -0
- package/types/imports.d.ts +1 -0
- package/types/index.d.ts +5 -5
- package/types/react-query.d.ts +1 -1
- package/types/ts-codegen.d.ts +2 -0
- package/types/utils/clean.d.ts +1 -0
- package/types/utils/cleanse.d.ts +1 -0
- package/types/utils/header.d.ts +1 -0
- package/types/utils/imports.d.ts +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/parse.d.ts +1 -0
- package/types/utils/prompt.d.ts +3 -0
- package/types/utils/schemas.d.ts +10 -0
- package/types/utils.d.ts +8 -2
- package/main/commands/boilerplate.js +0 -195
- package/main/utils.js +0 -123
- package/module/commands/boilerplate.js +0 -116
@@ -1,9 +1,15 @@
|
|
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
|
+
|
1
7
|
import { sync as glob } from 'glob';
|
2
8
|
import { readFileSync } from 'fs';
|
3
9
|
import { cleanse } from './cleanse';
|
4
10
|
import { compile } from 'json-schema-to-typescript';
|
5
11
|
import { parser } from './parse';
|
6
|
-
export const readSchemas = ({
|
12
|
+
export const readSchemas = async ({
|
7
13
|
schemaDir,
|
8
14
|
argv,
|
9
15
|
clean = true
|
@@ -49,4 +55,15 @@ export const findAndParseTypes = async schemas => {
|
|
49
55
|
|
50
56
|
const typeHash = parser(allTypes);
|
51
57
|
return typeHash;
|
58
|
+
};
|
59
|
+
export const getDefinitionSchema = schemas => {
|
60
|
+
const aggregateSchema = {
|
61
|
+
definitions: {//
|
62
|
+
}
|
63
|
+
};
|
64
|
+
schemas.forEach(schema => {
|
65
|
+
schema.definitions = schema.definitions || {};
|
66
|
+
aggregateSchema.definitions = _objectSpread(_objectSpread({}, aggregateSchema.definitions), schema.definitions);
|
67
|
+
});
|
68
|
+
return aggregateSchema;
|
52
69
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cosmwasm/ts-codegen",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.7.2",
|
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",
|
@@ -85,12 +85,12 @@
|
|
85
85
|
"fuzzy": "0.1.3",
|
86
86
|
"glob": "8.0.3",
|
87
87
|
"inquirerer": "0.1.3",
|
88
|
-
"json-schema-to-typescript": "
|
88
|
+
"json-schema-to-typescript": "11.0.1",
|
89
89
|
"long": "^5.2.0",
|
90
90
|
"minimist": "1.2.6",
|
91
91
|
"mkdirp": "1.0.4",
|
92
92
|
"shelljs": "0.8.5",
|
93
|
-
"wasm-ast-types": "^0.
|
93
|
+
"wasm-ast-types": "^0.6.1"
|
94
94
|
},
|
95
|
-
"gitHead": "
|
95
|
+
"gitHead": "8c35eebc33e7109da33ecb5f5bdeffc9a1b0d9af"
|
96
96
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const cleanse: (obj: any) => any;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const cosmjsAminoImportStatements: (typeHash: any) => any;
|
package/types/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
export { default as
|
3
|
-
export { default as
|
4
|
-
export { default as
|
5
|
-
export { default as recoil } from './recoil';
|
1
|
+
export { default as tsClient } from './generators/ts-client';
|
2
|
+
export { default as fromPartial } from './generators/from-partial';
|
3
|
+
export { default as reactQuery } from './generators/react-query';
|
4
|
+
export { default as recoil } from './generators/recoil';
|
6
5
|
export * from './utils';
|
6
|
+
export * from './utils/imports';
|
package/types/react-query.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default: (
|
1
|
+
declare const _default: (contractName: string, schemas: any[], outPath: string, reactQueryOptions?: ReactQueryOptions) => Promise<void>;
|
2
2
|
export default _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const clean: (obj: any) => any;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const cleanse: (obj: any) => any;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const header: string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const cosmjsAminoImportStatements: (typeHash: any) => any;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './schemas';
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const parser: (codes: any) => {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { JSONSchema } from 'wasm-ast-types';
|
2
|
+
export declare const readSchemas: ({ schemaDir, argv, clean }: {
|
3
|
+
schemaDir: any;
|
4
|
+
argv: any;
|
5
|
+
clean?: boolean;
|
6
|
+
}) => Promise<any>;
|
7
|
+
export declare const findQueryMsg: (schemas: any) => any;
|
8
|
+
export declare const findExecuteMsg: (schemas: any) => any;
|
9
|
+
export declare const findAndParseTypes: (schemas: any) => Promise<{}>;
|
10
|
+
export declare const getDefinitionSchema: (schemas: JSONSchema[]) => JSONSchema;
|
package/types/utils.d.ts
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
import { JSONSchema } from 'wasm-ast-types';
|
2
|
+
export declare const readSchemas: ({ schemaDir, argv, clean }: {
|
2
3
|
schemaDir: any;
|
3
4
|
argv: any;
|
4
|
-
|
5
|
+
clean?: boolean;
|
6
|
+
}) => Promise<any>;
|
7
|
+
export declare const findQueryMsg: (schemas: any) => any;
|
8
|
+
export declare const findExecuteMsg: (schemas: any) => any;
|
9
|
+
export declare const findAndParseTypes: (schemas: any) => Promise<{}>;
|
10
|
+
export declare const getDefinitionSchema: (schemas: JSONSchema[]) => JSONSchema;
|
@@ -1,195 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
-
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
8
|
-
value: true
|
9
|
-
});
|
10
|
-
exports["default"] = void 0;
|
11
|
-
|
12
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
13
|
-
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
-
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
17
|
-
|
18
|
-
var shell = _interopRequireWildcard(require("shelljs"));
|
19
|
-
|
20
|
-
var _prompt = require("../prompt");
|
21
|
-
|
22
|
-
var _dargs = _interopRequireDefault(require("dargs"));
|
23
|
-
|
24
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25
|
-
|
26
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
27
|
-
|
28
|
-
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; }
|
29
|
-
|
30
|
-
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; }
|
31
|
-
|
32
|
-
var glob = require('glob').sync;
|
33
|
-
|
34
|
-
var fs = require('fs');
|
35
|
-
|
36
|
-
var path = require('path');
|
37
|
-
|
38
|
-
var repo = 'git@github.com:pyramation/tmpl-cosmwasm-module.git';
|
39
|
-
|
40
|
-
var _default = /*#__PURE__*/function () {
|
41
|
-
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(argv) {
|
42
|
-
var _yield$prompt, name, questions, fullname, email, args, results, scopedResults, license, files, _loop, i, _ret;
|
43
|
-
|
44
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
45
|
-
while (1) {
|
46
|
-
switch (_context.prev = _context.next) {
|
47
|
-
case 0:
|
48
|
-
if (shell.which('git')) {
|
49
|
-
_context.next = 3;
|
50
|
-
break;
|
51
|
-
}
|
52
|
-
|
53
|
-
shell.echo('Sorry, this script requires git');
|
54
|
-
return _context.abrupt("return", shell.exit(1));
|
55
|
-
|
56
|
-
case 3:
|
57
|
-
_context.next = 5;
|
58
|
-
return (0, _prompt.prompt)([{
|
59
|
-
type: 'string',
|
60
|
-
name: 'name',
|
61
|
-
message: 'Enter your new module name'
|
62
|
-
}], argv);
|
63
|
-
|
64
|
-
case 5:
|
65
|
-
_yield$prompt = _context.sent;
|
66
|
-
name = _yield$prompt.name;
|
67
|
-
shell.exec("git clone ".concat(repo, " ").concat(name));
|
68
|
-
shell.cd(name);
|
69
|
-
questions = JSON.parse(fs.readFileSync(".questions.json"));
|
70
|
-
fullname = shell.exec('git config --global user.name', {
|
71
|
-
silent: true
|
72
|
-
}).trim();
|
73
|
-
email = shell.exec('git config --global user.email', {
|
74
|
-
silent: true
|
75
|
-
}).trim(); // @__USERNAME__/__MODULENAME__
|
76
|
-
// __PACKAGE_IDENTIFIER__
|
77
|
-
|
78
|
-
args = (0, _dargs["default"])(_objectSpread(_objectSpread({
|
79
|
-
_: []
|
80
|
-
}, argv), {}, {
|
81
|
-
__MODULENAME__: name,
|
82
|
-
__USERFULLNAME__: fullname,
|
83
|
-
__USEREMAIL__: email
|
84
|
-
}), {
|
85
|
-
allowCamelCase: true
|
86
|
-
});
|
87
|
-
_context.next = 15;
|
88
|
-
return (0, _prompt.prompt)(questions, args);
|
89
|
-
|
90
|
-
case 15:
|
91
|
-
results = _context.sent;
|
92
|
-
_context.next = 18;
|
93
|
-
return (0, _prompt.prompt)([{
|
94
|
-
name: '__LICENSE__',
|
95
|
-
message: 'Which license?',
|
96
|
-
choices: ['MIT', 'closed'],
|
97
|
-
type: 'list',
|
98
|
-
required: true
|
99
|
-
}], []);
|
100
|
-
|
101
|
-
case 18:
|
102
|
-
license = _context.sent;
|
103
|
-
|
104
|
-
if (!(results.__ACCESS__ === 'public')) {
|
105
|
-
_context.next = 23;
|
106
|
-
break;
|
107
|
-
}
|
108
|
-
|
109
|
-
_context.next = 22;
|
110
|
-
return (0, _prompt.prompt)([{
|
111
|
-
type: 'confirm',
|
112
|
-
name: 'scoped',
|
113
|
-
message: 'use npm scopes?',
|
114
|
-
required: true
|
115
|
-
}], []);
|
116
|
-
|
117
|
-
case 22:
|
118
|
-
scopedResults = _context.sent;
|
119
|
-
|
120
|
-
case 23:
|
121
|
-
files = [].concat(glob(process.cwd() + '/**/.*')).concat(glob(process.cwd() + '/**/*'));
|
122
|
-
|
123
|
-
_loop = function _loop(i) {
|
124
|
-
var templateFile = files[i];
|
125
|
-
if (fs.lstatSync(templateFile).isDirectory()) return "continue";
|
126
|
-
var content = fs.readFileSync(templateFile).toString();
|
127
|
-
|
128
|
-
if (path.basename(templateFile) === 'LICENSE' && license.__LICENSE__ === 'closed') {
|
129
|
-
content = "Copyright (c) 2022 __USERFULLNAME__ <__USEREMAIL__> - All Rights Reserved\nUnauthorized copying via any medium is strictly prohibited\nProprietary and confidential";
|
130
|
-
}
|
131
|
-
|
132
|
-
Object.keys(results).forEach(function (key) {
|
133
|
-
if (/^__/.test(key)) {
|
134
|
-
content = content.replace(new RegExp(key, 'g'), results[key]);
|
135
|
-
}
|
136
|
-
});
|
137
|
-
|
138
|
-
if (results.__ACCESS__ === 'public') {
|
139
|
-
if (scopedResults.scoped) {
|
140
|
-
content = content.replace(/__PACKAGE_IDENTIFIER__/g, "@".concat(results.__USERNAME__, "/").concat(results.__MODULENAME__));
|
141
|
-
} else {
|
142
|
-
content = content.replace(/__PACKAGE_IDENTIFIER__/g, "".concat(results.__MODULENAME__));
|
143
|
-
}
|
144
|
-
} else {
|
145
|
-
content = content.replace(/__PACKAGE_IDENTIFIER__/g, "@".concat(results.__USERNAME__, "/").concat(results.__MODULENAME__));
|
146
|
-
}
|
147
|
-
|
148
|
-
if (path.basename(templateFile) === 'README.md') {
|
149
|
-
content = "# ".concat(results.__MODULENAME__);
|
150
|
-
}
|
151
|
-
|
152
|
-
fs.writeFileSync(templateFile, content);
|
153
|
-
};
|
154
|
-
|
155
|
-
i = 0;
|
156
|
-
|
157
|
-
case 26:
|
158
|
-
if (!(i < files.length)) {
|
159
|
-
_context.next = 33;
|
160
|
-
break;
|
161
|
-
}
|
162
|
-
|
163
|
-
_ret = _loop(i);
|
164
|
-
|
165
|
-
if (!(_ret === "continue")) {
|
166
|
-
_context.next = 30;
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
|
170
|
-
return _context.abrupt("continue", 30);
|
171
|
-
|
172
|
-
case 30:
|
173
|
-
i++;
|
174
|
-
_context.next = 26;
|
175
|
-
break;
|
176
|
-
|
177
|
-
case 33:
|
178
|
-
shell.rm('-rf', '.git');
|
179
|
-
shell.rm('-rf', '.questions.json');
|
180
|
-
console.log("\n\n |||\n (o o)\n ooO--(_)--Ooo-\n\n \u2728 Great work!\n ");
|
181
|
-
|
182
|
-
case 36:
|
183
|
-
case "end":
|
184
|
-
return _context.stop();
|
185
|
-
}
|
186
|
-
}
|
187
|
-
}, _callee);
|
188
|
-
}));
|
189
|
-
|
190
|
-
return function (_x) {
|
191
|
-
return _ref.apply(this, arguments);
|
192
|
-
};
|
193
|
-
}();
|
194
|
-
|
195
|
-
exports["default"] = _default;
|
package/main/utils.js
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
exports.readSchemas = exports.findQueryMsg = exports.findExecuteMsg = exports.findAndParseTypes = void 0;
|
9
|
-
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
-
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
13
|
-
|
14
|
-
var _glob = require("glob");
|
15
|
-
|
16
|
-
var _fs = require("fs");
|
17
|
-
|
18
|
-
var _cleanse = require("./cleanse");
|
19
|
-
|
20
|
-
var _jsonSchemaToTypescript = require("json-schema-to-typescript");
|
21
|
-
|
22
|
-
var _parse = require("./parse");
|
23
|
-
|
24
|
-
var readSchemas = function readSchemas(_ref) {
|
25
|
-
var schemaDir = _ref.schemaDir,
|
26
|
-
argv = _ref.argv,
|
27
|
-
_ref$clean = _ref.clean,
|
28
|
-
clean = _ref$clean === void 0 ? true : _ref$clean;
|
29
|
-
var fn = clean ? _cleanse.cleanse : function (str) {
|
30
|
-
return str;
|
31
|
-
};
|
32
|
-
var files = (0, _glob.sync)(schemaDir + '/**/*.json');
|
33
|
-
var schemas = files.map(function (file) {
|
34
|
-
return JSON.parse((0, _fs.readFileSync)(file, 'utf-8'));
|
35
|
-
});
|
36
|
-
|
37
|
-
if (argv.packed) {
|
38
|
-
if (schemas.length !== 1) {
|
39
|
-
throw new Error('packed option only supports one file');
|
40
|
-
}
|
41
|
-
|
42
|
-
return Object.values(fn(schemas[0]));
|
43
|
-
}
|
44
|
-
|
45
|
-
return fn(schemas);
|
46
|
-
};
|
47
|
-
|
48
|
-
exports.readSchemas = readSchemas;
|
49
|
-
|
50
|
-
var findQueryMsg = function findQueryMsg(schemas) {
|
51
|
-
var QueryMsg = schemas.find(function (schema) {
|
52
|
-
return schema.title === 'QueryMsg';
|
53
|
-
});
|
54
|
-
return QueryMsg;
|
55
|
-
};
|
56
|
-
|
57
|
-
exports.findQueryMsg = findQueryMsg;
|
58
|
-
|
59
|
-
var findExecuteMsg = function findExecuteMsg(schemas) {
|
60
|
-
var ExecuteMsg = schemas.find(function (schema) {
|
61
|
-
return schema.title === 'ExecuteMsg' || schema.title === 'ExecuteMsg_for_Empty' || // if cleanse is used, this is never
|
62
|
-
schema.title === 'ExecuteMsgForEmpty';
|
63
|
-
});
|
64
|
-
return ExecuteMsg;
|
65
|
-
};
|
66
|
-
|
67
|
-
exports.findExecuteMsg = findExecuteMsg;
|
68
|
-
|
69
|
-
var findAndParseTypes = /*#__PURE__*/function () {
|
70
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(schemas) {
|
71
|
-
var Types, allTypes, typ, _i, _Object$keys, key, result, typeHash;
|
72
|
-
|
73
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
74
|
-
while (1) {
|
75
|
-
switch (_context.prev = _context.next) {
|
76
|
-
case 0:
|
77
|
-
Types = schemas;
|
78
|
-
allTypes = [];
|
79
|
-
_context.t0 = _regenerator["default"].keys(Types);
|
80
|
-
|
81
|
-
case 3:
|
82
|
-
if ((_context.t1 = _context.t0()).done) {
|
83
|
-
_context.next = 12;
|
84
|
-
break;
|
85
|
-
}
|
86
|
-
|
87
|
-
typ = _context.t1.value;
|
88
|
-
|
89
|
-
if (Types[typ].definitions) {
|
90
|
-
for (_i = 0, _Object$keys = Object.keys(Types[typ].definitions); _i < _Object$keys.length; _i++) {
|
91
|
-
key = _Object$keys[_i];
|
92
|
-
// set title
|
93
|
-
Types[typ].definitions[key].title = key;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
_context.next = 8;
|
98
|
-
return (0, _jsonSchemaToTypescript.compile)(Types[typ], Types[typ].title);
|
99
|
-
|
100
|
-
case 8:
|
101
|
-
result = _context.sent;
|
102
|
-
allTypes.push(result);
|
103
|
-
_context.next = 3;
|
104
|
-
break;
|
105
|
-
|
106
|
-
case 12:
|
107
|
-
typeHash = (0, _parse.parser)(allTypes);
|
108
|
-
return _context.abrupt("return", typeHash);
|
109
|
-
|
110
|
-
case 14:
|
111
|
-
case "end":
|
112
|
-
return _context.stop();
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}, _callee);
|
116
|
-
}));
|
117
|
-
|
118
|
-
return function findAndParseTypes(_x) {
|
119
|
-
return _ref2.apply(this, arguments);
|
120
|
-
};
|
121
|
-
}();
|
122
|
-
|
123
|
-
exports.findAndParseTypes = findAndParseTypes;
|
@@ -1,116 +0,0 @@
|
|
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 * as shell from 'shelljs';
|
8
|
-
import { prompt } from '../prompt';
|
9
|
-
import dargs from 'dargs';
|
10
|
-
|
11
|
-
const glob = require('glob').sync;
|
12
|
-
|
13
|
-
const fs = require('fs');
|
14
|
-
|
15
|
-
const path = require('path');
|
16
|
-
|
17
|
-
const repo = 'git@github.com:pyramation/tmpl-cosmwasm-module.git';
|
18
|
-
export default (async argv => {
|
19
|
-
if (!shell.which('git')) {
|
20
|
-
shell.echo('Sorry, this script requires git');
|
21
|
-
return shell.exit(1);
|
22
|
-
}
|
23
|
-
|
24
|
-
const {
|
25
|
-
name
|
26
|
-
} = await prompt([{
|
27
|
-
type: 'string',
|
28
|
-
name: 'name',
|
29
|
-
message: 'Enter your new module name'
|
30
|
-
}], argv);
|
31
|
-
shell.exec(`git clone ${repo} ${name}`);
|
32
|
-
shell.cd(name);
|
33
|
-
const questions = JSON.parse(fs.readFileSync(`.questions.json`));
|
34
|
-
const fullname = shell.exec('git config --global user.name', {
|
35
|
-
silent: true
|
36
|
-
}).trim();
|
37
|
-
const email = shell.exec('git config --global user.email', {
|
38
|
-
silent: true
|
39
|
-
}).trim(); // @__USERNAME__/__MODULENAME__
|
40
|
-
// __PACKAGE_IDENTIFIER__
|
41
|
-
|
42
|
-
const args = dargs(_objectSpread(_objectSpread({
|
43
|
-
_: []
|
44
|
-
}, argv), {}, {
|
45
|
-
__MODULENAME__: name,
|
46
|
-
__USERFULLNAME__: fullname,
|
47
|
-
__USEREMAIL__: email
|
48
|
-
}), {
|
49
|
-
allowCamelCase: true
|
50
|
-
});
|
51
|
-
const results = await prompt(questions, args);
|
52
|
-
let scopedResults;
|
53
|
-
const license = await prompt([{
|
54
|
-
name: '__LICENSE__',
|
55
|
-
message: 'Which license?',
|
56
|
-
choices: ['MIT', 'closed'],
|
57
|
-
type: 'list',
|
58
|
-
required: true
|
59
|
-
}], []);
|
60
|
-
|
61
|
-
if (results.__ACCESS__ === 'public') {
|
62
|
-
scopedResults = await prompt([{
|
63
|
-
type: 'confirm',
|
64
|
-
name: 'scoped',
|
65
|
-
message: 'use npm scopes?',
|
66
|
-
required: true
|
67
|
-
}], []);
|
68
|
-
}
|
69
|
-
|
70
|
-
const files = [].concat(glob(process.cwd() + '/**/.*')).concat(glob(process.cwd() + '/**/*'));
|
71
|
-
|
72
|
-
for (let i = 0; i < files.length; i++) {
|
73
|
-
const templateFile = files[i];
|
74
|
-
if (fs.lstatSync(templateFile).isDirectory()) continue;
|
75
|
-
let content = fs.readFileSync(templateFile).toString();
|
76
|
-
|
77
|
-
if (path.basename(templateFile) === 'LICENSE' && license.__LICENSE__ === 'closed') {
|
78
|
-
content = `Copyright (c) 2022 __USERFULLNAME__ <__USEREMAIL__> - All Rights Reserved
|
79
|
-
Unauthorized copying via any medium is strictly prohibited
|
80
|
-
Proprietary and confidential`;
|
81
|
-
}
|
82
|
-
|
83
|
-
Object.keys(results).forEach(key => {
|
84
|
-
if (/^__/.test(key)) {
|
85
|
-
content = content.replace(new RegExp(key, 'g'), results[key]);
|
86
|
-
}
|
87
|
-
});
|
88
|
-
|
89
|
-
if (results.__ACCESS__ === 'public') {
|
90
|
-
if (scopedResults.scoped) {
|
91
|
-
content = content.replace(/__PACKAGE_IDENTIFIER__/g, `@${results.__USERNAME__}/${results.__MODULENAME__}`);
|
92
|
-
} else {
|
93
|
-
content = content.replace(/__PACKAGE_IDENTIFIER__/g, `${results.__MODULENAME__}`);
|
94
|
-
}
|
95
|
-
} else {
|
96
|
-
content = content.replace(/__PACKAGE_IDENTIFIER__/g, `@${results.__USERNAME__}/${results.__MODULENAME__}`);
|
97
|
-
}
|
98
|
-
|
99
|
-
if (path.basename(templateFile) === 'README.md') {
|
100
|
-
content = `# ${results.__MODULENAME__}`;
|
101
|
-
}
|
102
|
-
|
103
|
-
fs.writeFileSync(templateFile, content);
|
104
|
-
}
|
105
|
-
|
106
|
-
shell.rm('-rf', '.git');
|
107
|
-
shell.rm('-rf', '.questions.json');
|
108
|
-
console.log(`
|
109
|
-
|
110
|
-
|||
|
111
|
-
(o o)
|
112
|
-
ooO--(_)--Ooo-
|
113
|
-
|
114
|
-
✨ Great work!
|
115
|
-
`);
|
116
|
-
});
|