@cosmwasm/ts-codegen 0.35.6 → 1.0.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/LICENSE-Apache +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +15 -7
- package/{types/src/builder → builder}/builder.d.ts +2 -2
- package/builder/builder.js +172 -0
- package/builder/index.js +17 -0
- package/bundler/bundler.d.ts +8 -0
- package/bundler/bundler.js +79 -0
- package/bundler/index.js +17 -0
- package/cli.d.ts +2 -0
- package/cli.js +24 -0
- package/cmds.d.ts +2 -0
- package/cmds.js +14 -0
- package/commands/create-boilerplate.d.ts +3 -0
- package/commands/create-boilerplate.js +132 -0
- package/commands/generate.d.ts +3 -0
- package/commands/generate.js +175 -0
- package/commands/install.d.ts +3 -0
- package/commands/install.js +107 -0
- package/{src/builder/builder.ts → esm/builder/builder.js} +39 -139
- package/esm/builder/index.js +1 -0
- package/esm/bundler/bundler.js +47 -0
- package/esm/bundler/index.js +1 -0
- package/esm/cli.js +20 -0
- package/{src → esm}/cmds.js +0 -1
- package/{src/commands/create-boilerplate.ts → esm/commands/create-boilerplate.js} +35 -70
- package/{src/commands/generate.ts → esm/commands/generate.js} +19 -24
- package/{src/commands/install.ts → esm/commands/install.js} +22 -35
- package/esm/file.js +18 -0
- package/esm/generators/client.js +67 -0
- package/esm/generators/create-helpers.js +36 -0
- package/esm/generators/message-composer.js +55 -0
- package/esm/generators/msg-builder.js +58 -0
- package/esm/generators/react-query.js +76 -0
- package/esm/generators/recoil.js +58 -0
- package/esm/generators/types.js +58 -0
- package/{src/index.ts → esm/index.js} +3 -6
- package/esm/plugins/client.js +59 -0
- package/esm/plugins/message-builder.js +52 -0
- package/esm/plugins/message-composer.js +46 -0
- package/esm/plugins/plugin-base.js +47 -0
- package/esm/plugins/provider-bundle.js +58 -0
- package/esm/plugins/provider.js +73 -0
- package/esm/plugins/react-query.js +69 -0
- package/esm/plugins/recoil.js +51 -0
- package/esm/plugins/types.js +38 -0
- package/{src → esm}/ts-codegen.js +1 -2
- package/{src/utils/clean.ts → esm/utils/clean.js} +7 -7
- package/{src/utils/cleanse.ts → esm/utils/cleanse.js} +18 -22
- package/esm/utils/files.js +42 -0
- package/{src/utils/parse.ts → esm/utils/parse.js} +4 -13
- package/esm/utils/prompt.js +59 -0
- package/{src/utils/schemas.ts → esm/utils/schemas.js} +16 -44
- package/esm/utils/unused.js +47 -0
- package/file.js +20 -0
- package/generators/client.js +95 -0
- package/generators/create-helpers.js +43 -0
- package/generators/message-composer.js +83 -0
- package/generators/msg-builder.js +86 -0
- package/generators/react-query.js +104 -0
- package/generators/recoil.js +86 -0
- package/generators/types.js +86 -0
- package/{module/helpers → helpers}/contractContextBase.js +5 -2
- package/{module/helpers → helpers}/contractContextBaseShortHandCtor.js +5 -2
- package/{module/helpers → helpers}/contractsContextTSX.js +5 -2
- package/{module/helpers/index.js → helpers/index.d.ts} +1 -1
- package/helpers/index.js +19 -0
- package/index.js +39 -0
- package/package.json +27 -51
- package/plugins/client.js +86 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +17 -0
- package/plugins/message-builder.js +79 -0
- package/plugins/message-composer.js +73 -0
- package/{types/src/plugins → plugins}/plugin-base.d.ts +1 -1
- package/plugins/plugin-base.js +77 -0
- package/plugins/provider-bundle.js +85 -0
- package/{types/src/plugins → plugins}/provider.d.ts +2 -2
- package/plugins/provider.js +102 -0
- package/plugins/react-query.js +96 -0
- package/plugins/recoil.js +78 -0
- package/plugins/types.js +65 -0
- package/ts-codegen.js +8 -0
- package/utils/clean.js +49 -0
- package/utils/cleanse.js +89 -0
- package/utils/files.js +73 -0
- package/utils/header.js +14 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +17 -0
- package/utils/parse.d.ts +1 -0
- package/utils/parse.js +43 -0
- package/utils/prompt.d.ts +3 -0
- package/utils/prompt.js +65 -0
- package/utils/schemas.d.ts +11 -0
- package/utils/schemas.js +81 -0
- package/utils/unused.js +73 -0
- package/main/builder/builder.js +0 -308
- package/main/builder/index.js +0 -16
- package/main/bundler/bundler.js +0 -61
- package/main/bundler/index.js +0 -16
- package/main/cli.js +0 -51
- package/main/cmds.js +0 -15
- package/main/commands/create-boilerplate.js +0 -166
- package/main/commands/generate.js +0 -196
- package/main/commands/install.js +0 -138
- package/main/file.js +0 -35
- package/main/generators/client.js +0 -90
- package/main/generators/create-helpers.js +0 -38
- package/main/generators/message-composer.js +0 -77
- package/main/generators/msg-builder.js +0 -84
- package/main/generators/react-query.js +0 -102
- package/main/generators/recoil.js +0 -81
- package/main/generators/types.js +0 -82
- package/main/helpers/contractContextBase.js +0 -8
- package/main/helpers/contractContextBaseShortHandCtor.js +0 -8
- package/main/helpers/contractsContextTSX.js +0 -8
- package/main/helpers/index.js +0 -38
- package/main/index.js +0 -119
- package/main/plugins/client.js +0 -112
- package/main/plugins/index.js +0 -16
- package/main/plugins/message-builder.js +0 -102
- package/main/plugins/message-composer.js +0 -98
- package/main/plugins/plugin-base.js +0 -103
- package/main/plugins/provider-bundle.js +0 -108
- package/main/plugins/provider.js +0 -126
- package/main/plugins/react-query.js +0 -120
- package/main/plugins/recoil.js +0 -108
- package/main/plugins/types.js +0 -89
- package/main/ts-codegen.js +0 -20
- package/main/utils/clean.js +0 -53
- package/main/utils/cleanse.js +0 -87
- package/main/utils/files.js +0 -57
- package/main/utils/header.js +0 -11
- package/main/utils/index.js +0 -16
- package/main/utils/parse.js +0 -44
- package/main/utils/prompt.js +0 -98
- package/main/utils/schemas.js +0 -144
- package/main/utils/unused.js +0 -57
- package/module/builder/builder.js +0 -143
- package/module/builder/index.js +0 -1
- package/module/bundler/bundler.js +0 -36
- package/module/bundler/index.js +0 -1
- package/module/cli.js +0 -19
- package/module/cmds.js +0 -8
- package/module/commands/create-boilerplate.js +0 -102
- package/module/commands/generate.js +0 -163
- package/module/commands/install.js +0 -98
- package/module/file.js +0 -18
- package/module/generators/client.js +0 -65
- package/module/generators/create-helpers.js +0 -33
- package/module/generators/message-composer.js +0 -52
- package/module/generators/msg-builder.js +0 -58
- package/module/generators/react-query.js +0 -75
- package/module/generators/recoil.js +0 -53
- package/module/generators/types.js +0 -55
- package/module/index.js +0 -14
- package/module/plugins/client.js +0 -63
- package/module/plugins/index.js +0 -1
- package/module/plugins/message-builder.js +0 -55
- package/module/plugins/message-composer.js +0 -49
- package/module/plugins/plugin-base.js +0 -66
- package/module/plugins/provider-bundle.js +0 -56
- package/module/plugins/provider.js +0 -68
- package/module/plugins/react-query.js +0 -72
- package/module/plugins/recoil.js +0 -57
- package/module/plugins/types.js +0 -42
- package/module/ts-codegen.js +0 -6
- package/module/utils/clean.js +0 -44
- package/module/utils/cleanse.js +0 -78
- package/module/utils/files.js +0 -40
- package/module/utils/header.js +0 -8
- package/module/utils/index.js +0 -1
- package/module/utils/parse.js +0 -35
- package/module/utils/prompt.js +0 -63
- package/module/utils/schemas.js +0 -85
- package/module/utils/unused.js +0 -43
- package/src/builder/index.ts +0 -1
- package/src/bundler/bundler.ts +0 -67
- package/src/bundler/index.ts +0 -1
- package/src/cli.js +0 -21
- package/src/file.js +0 -20
- package/src/generators/client.ts +0 -109
- package/src/generators/create-helpers.ts +0 -71
- package/src/generators/message-composer.ts +0 -86
- package/src/generators/msg-builder.ts +0 -78
- package/src/generators/react-query.ts +0 -102
- package/src/generators/recoil.ts +0 -92
- package/src/generators/types.ts +0 -94
- package/src/helpers/index.ts +0 -3
- package/src/plugins/client.ts +0 -124
- package/src/plugins/index.ts +0 -1
- package/src/plugins/message-builder.ts +0 -85
- package/src/plugins/message-composer.ts +0 -89
- package/src/plugins/plugin-base.ts +0 -122
- package/src/plugins/provider-bundle.ts +0 -98
- package/src/plugins/provider.ts +0 -115
- package/src/plugins/react-query.ts +0 -115
- package/src/plugins/recoil.ts +0 -89
- package/src/plugins/types.ts +0 -74
- package/src/utils/files.ts +0 -73
- package/src/utils/index.ts +0 -1
- package/src/utils/prompt.js +0 -65
- package/src/utils/unused.ts +0 -52
- package/types/src/bundler/bundler.d.ts +0 -4
- package/types/src/cli.d.ts +0 -1
- package/types/src/cmds.d.ts +0 -1
- package/types/src/commands/create-boilerplate.d.ts +0 -2
- package/types/src/commands/generate.d.ts +0 -2
- package/types/src/commands/install.d.ts +0 -2
- package/types/src/generators/msg-builder.ts +0 -5
- package/types/src/plugins/msg-builder.d.ts +0 -12
- package/types/src/plugins/use-contracts.d.ts +0 -12
- package/types/src/types.d.ts +0 -16
- package/types/src/utils/parse.d.ts +0 -1
- package/types/src/utils/prompt.d.ts +0 -3
- package/types/src/utils/schemas.d.ts +0 -10
- /package/{types/src/builder → builder}/index.d.ts +0 -0
- /package/{types/src/bundler → bundler}/index.d.ts +0 -0
- /package/{src/helpers/contractContextBase.ts → esm/helpers/contractContextBase.js} +0 -0
- /package/{src/helpers/contractContextBaseShortHandCtor.ts → esm/helpers/contractContextBaseShortHandCtor.js} +0 -0
- /package/{src/helpers/contractsContextTSX.ts → esm/helpers/contractsContextTSX.js} +0 -0
- /package/{types/src/helpers/index.d.ts → esm/helpers/index.js} +0 -0
- /package/{types/src/plugins/index.d.ts → esm/plugins/index.js} +0 -0
- /package/{src/utils/header.ts → esm/utils/header.js} +0 -0
- /package/{types/src/utils/index.d.ts → esm/utils/index.js} +0 -0
- /package/{types/src/file.d.ts → file.d.ts} +0 -0
- /package/{types/src/generators → generators}/client.d.ts +0 -0
- /package/{types/src/generators → generators}/create-helpers.d.ts +0 -0
- /package/{types/src/generators → generators}/message-composer.d.ts +0 -0
- /package/{types/src/generators → generators}/msg-builder.d.ts +0 -0
- /package/{types/src/generators → generators}/react-query.d.ts +0 -0
- /package/{types/src/generators → generators}/recoil.d.ts +0 -0
- /package/{types/src/generators → generators}/types.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractContextBase.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractContextBaseShortHandCtor.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractsContextTSX.d.ts +0 -0
- /package/{types/src/index.d.ts → index.d.ts} +0 -0
- /package/{types/src/plugins → plugins}/client.d.ts +0 -0
- /package/{types/src/plugins → plugins}/message-builder.d.ts +0 -0
- /package/{types/src/plugins → plugins}/message-composer.d.ts +0 -0
- /package/{types/src/plugins → plugins}/provider-bundle.d.ts +0 -0
- /package/{types/src/plugins → plugins}/react-query.d.ts +0 -0
- /package/{types/src/plugins → plugins}/recoil.d.ts +0 -0
- /package/{types/src/plugins → plugins}/types.d.ts +0 -0
- /package/{types/src/ts-codegen.d.ts → ts-codegen.d.ts} +0 -0
- /package/{types/src/utils → utils}/clean.d.ts +0 -0
- /package/{types/src/utils → utils}/cleanse.d.ts +0 -0
- /package/{types/src/utils → utils}/files.d.ts +0 -0
- /package/{types/src/utils → utils}/header.d.ts +0 -0
- /package/{types/src/utils → utils}/unused.d.ts +0 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
const shell = __importStar(require("shelljs"));
|
30
|
+
const prompt_1 = require("../utils/prompt");
|
31
|
+
const dargs_1 = __importDefault(require("dargs"));
|
32
|
+
const glob = require('glob').sync;
|
33
|
+
const fs = require('fs');
|
34
|
+
const path = require('path');
|
35
|
+
const repo = 'https://github.com/cosmology-tech/ts-codegen-module-boilerplate';
|
36
|
+
exports.default = async (argv) => {
|
37
|
+
if (!shell.which('git')) {
|
38
|
+
shell.echo('Sorry, this script requires git');
|
39
|
+
return shell.exit(1);
|
40
|
+
}
|
41
|
+
const { name } = await (0, prompt_1.prompt)([
|
42
|
+
{
|
43
|
+
type: 'string',
|
44
|
+
name: 'name',
|
45
|
+
message: 'Enter your new module name',
|
46
|
+
}
|
47
|
+
], argv);
|
48
|
+
shell.exec(`git clone ${repo} ${name}`);
|
49
|
+
shell.cd(name);
|
50
|
+
const questions = JSON.parse(fs.readFileSync(`.questions.json`));
|
51
|
+
const fullname = shell
|
52
|
+
.exec('git config --global user.name', { silent: true })
|
53
|
+
.trim();
|
54
|
+
const email = shell
|
55
|
+
.exec('git config --global user.email', { silent: true })
|
56
|
+
.trim();
|
57
|
+
// @__USERNAME__/__MODULENAME__
|
58
|
+
// __PACKAGE_IDENTIFIER__
|
59
|
+
const args = (0, dargs_1.default)({
|
60
|
+
_: [],
|
61
|
+
...argv,
|
62
|
+
__MODULENAME__: name,
|
63
|
+
__USERFULLNAME__: fullname,
|
64
|
+
__USEREMAIL__: email,
|
65
|
+
}, { allowCamelCase: true });
|
66
|
+
const results = await (0, prompt_1.prompt)(questions, args);
|
67
|
+
let scopedResults;
|
68
|
+
const license = await (0, prompt_1.prompt)([
|
69
|
+
{
|
70
|
+
name: '__LICENSE__',
|
71
|
+
message: 'Which license?',
|
72
|
+
choices: ['MIT', 'closed'],
|
73
|
+
type: 'list',
|
74
|
+
required: true,
|
75
|
+
},
|
76
|
+
], []);
|
77
|
+
if (results.__ACCESS__ === 'public') {
|
78
|
+
scopedResults = await (0, prompt_1.prompt)([
|
79
|
+
{
|
80
|
+
type: 'confirm',
|
81
|
+
name: 'scoped',
|
82
|
+
message: 'use npm scopes?',
|
83
|
+
required: true,
|
84
|
+
},
|
85
|
+
], []);
|
86
|
+
}
|
87
|
+
const files = []
|
88
|
+
.concat(glob(process.cwd() + '/**/.*'))
|
89
|
+
.concat(glob(process.cwd() + '/**/*'));
|
90
|
+
for (let i = 0; i < files.length; i++) {
|
91
|
+
const templateFile = files[i];
|
92
|
+
if (fs.lstatSync(templateFile).isDirectory())
|
93
|
+
continue;
|
94
|
+
let content = fs.readFileSync(templateFile).toString();
|
95
|
+
if (path.basename(templateFile) === 'LICENSE' &&
|
96
|
+
license.__LICENSE__ === 'closed') {
|
97
|
+
content = `Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> - All Rights Reserved
|
98
|
+
Unauthorized copying via any medium is strictly prohibited
|
99
|
+
Proprietary and confidential`;
|
100
|
+
}
|
101
|
+
Object.keys(results).forEach(key => {
|
102
|
+
if (/^__/.test(key)) {
|
103
|
+
content = content.replace(new RegExp(key, 'g'), results[key]);
|
104
|
+
}
|
105
|
+
});
|
106
|
+
if (results.__ACCESS__ === 'public') {
|
107
|
+
if (scopedResults.scoped) {
|
108
|
+
content = content.replace(/__PACKAGE_IDENTIFIER__/g, `@${results.__USERNAME__}/${results.__MODULENAME__}`);
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
content = content.replace(/__PACKAGE_IDENTIFIER__/g, `${results.__MODULENAME__}`);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
content = content.replace(/__PACKAGE_IDENTIFIER__/g, `@${results.__USERNAME__}/${results.__MODULENAME__}`);
|
116
|
+
}
|
117
|
+
// if (path.basename(templateFile) === 'README.md') {
|
118
|
+
// content = `# ${results.__MODULENAME__}`;
|
119
|
+
// }
|
120
|
+
fs.writeFileSync(templateFile, content);
|
121
|
+
}
|
122
|
+
shell.rm('-rf', '.git');
|
123
|
+
shell.rm('-rf', '.questions.json');
|
124
|
+
console.log(`
|
125
|
+
|
126
|
+
|||
|
127
|
+
(o o)
|
128
|
+
ooO--(_)--Ooo-
|
129
|
+
|
130
|
+
✨ Great work!
|
131
|
+
`);
|
132
|
+
};
|
@@ -0,0 +1,175 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
// @ts-nocheck
|
7
|
+
const prompt_1 = require("../utils/prompt");
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
9
|
+
exports.default = async (argv) => {
|
10
|
+
const questions = [
|
11
|
+
{
|
12
|
+
_: true,
|
13
|
+
type: 'path',
|
14
|
+
name: 'schema',
|
15
|
+
message: 'which directory contains the the Rust contracts?',
|
16
|
+
default: './schema'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
_: true,
|
20
|
+
type: 'path',
|
21
|
+
name: 'out',
|
22
|
+
message: 'where is the output directory?',
|
23
|
+
default: './ts'
|
24
|
+
},
|
25
|
+
{
|
26
|
+
_: true,
|
27
|
+
type: 'string',
|
28
|
+
name: 'name',
|
29
|
+
message: 'contract name?'
|
30
|
+
},
|
31
|
+
{
|
32
|
+
type: 'checkbox',
|
33
|
+
name: 'plugin',
|
34
|
+
message: 'which plugins?',
|
35
|
+
choices: [
|
36
|
+
'client',
|
37
|
+
'recoil',
|
38
|
+
'react-query',
|
39
|
+
'message-composer'
|
40
|
+
]
|
41
|
+
},
|
42
|
+
{
|
43
|
+
type: 'confirm',
|
44
|
+
name: 'bundle',
|
45
|
+
message: 'enable bundle?',
|
46
|
+
default: true
|
47
|
+
}
|
48
|
+
];
|
49
|
+
if (argv.typesOnly) {
|
50
|
+
argv.plugin = 'types';
|
51
|
+
}
|
52
|
+
let { schema, out, name, plugin, bundle } = await (0, prompt_1.prompt)(questions, argv);
|
53
|
+
if (!Array.isArray(plugin))
|
54
|
+
plugin = [plugin];
|
55
|
+
///////// REACT QUERY
|
56
|
+
const questions2 = [];
|
57
|
+
if (plugin.includes('react-query')) {
|
58
|
+
// @ts-ignore
|
59
|
+
[].push.apply(questions2, [
|
60
|
+
{
|
61
|
+
type: 'confirm',
|
62
|
+
name: 'optionalClient',
|
63
|
+
message: 'optionalClient?',
|
64
|
+
default: false
|
65
|
+
},
|
66
|
+
{
|
67
|
+
type: 'list',
|
68
|
+
name: 'version',
|
69
|
+
message: 'which react-query version?',
|
70
|
+
default: 'v4',
|
71
|
+
choices: ['v3', 'v4']
|
72
|
+
},
|
73
|
+
{
|
74
|
+
type: 'confirm',
|
75
|
+
name: 'queryKeys',
|
76
|
+
message: 'queryKeys?',
|
77
|
+
default: false
|
78
|
+
},
|
79
|
+
]);
|
80
|
+
}
|
81
|
+
;
|
82
|
+
const { optionalClient, version, queryKeys } = await (0, prompt_1.prompt)(questions2, argv);
|
83
|
+
const questions3 = [];
|
84
|
+
if (version === 'v4') {
|
85
|
+
[].push.apply(questions3, [
|
86
|
+
// currently we only support v4 for useMutation
|
87
|
+
{
|
88
|
+
type: 'confirm',
|
89
|
+
name: 'mutations',
|
90
|
+
message: 'Generate useMutation hooks?',
|
91
|
+
default: false
|
92
|
+
}
|
93
|
+
]);
|
94
|
+
}
|
95
|
+
;
|
96
|
+
const { mutations } = await (0, prompt_1.prompt)(questions3, argv);
|
97
|
+
const queryFactoryQuestions = [];
|
98
|
+
if (queryKeys) {
|
99
|
+
[].push.apply(queryFactoryQuestions, [
|
100
|
+
// Only can use queryFactory if queryKeys is enabled
|
101
|
+
{
|
102
|
+
type: 'confirm',
|
103
|
+
name: 'queryFactory',
|
104
|
+
message: 'queryFactory? ',
|
105
|
+
default: false
|
106
|
+
}
|
107
|
+
]);
|
108
|
+
}
|
109
|
+
;
|
110
|
+
const { queryFactory } = await (0, prompt_1.prompt)(queryFactoryQuestions, argv);
|
111
|
+
///////// END REACT QUERY
|
112
|
+
///////// BUNDLE
|
113
|
+
const questions4 = [];
|
114
|
+
if (bundle) {
|
115
|
+
[].push.apply(questions4, [
|
116
|
+
{
|
117
|
+
type: 'string',
|
118
|
+
name: 'bundleFile',
|
119
|
+
message: 'bundleFile?',
|
120
|
+
default: 'index.ts'
|
121
|
+
},
|
122
|
+
{
|
123
|
+
type: 'string',
|
124
|
+
name: 'bundleScope',
|
125
|
+
message: 'bundleScope?',
|
126
|
+
default: 'contracts'
|
127
|
+
}
|
128
|
+
]);
|
129
|
+
}
|
130
|
+
;
|
131
|
+
const { bundleFile, bundleScope } = await (0, prompt_1.prompt)(questions4, argv);
|
132
|
+
///////// END BUNDLE
|
133
|
+
const options = {
|
134
|
+
types: {
|
135
|
+
enabled: true
|
136
|
+
},
|
137
|
+
client: {
|
138
|
+
enabled: plugin.includes('client') ||
|
139
|
+
plugin.includes('recoil') ||
|
140
|
+
plugin.includes('react-query')
|
141
|
+
},
|
142
|
+
reactQuery: {
|
143
|
+
enabled: plugin.includes('react-query'),
|
144
|
+
optionalClient,
|
145
|
+
queryKeys,
|
146
|
+
version,
|
147
|
+
mutations,
|
148
|
+
queryFactory
|
149
|
+
},
|
150
|
+
recoil: {
|
151
|
+
enabled: plugin.includes('recoil'),
|
152
|
+
},
|
153
|
+
messageComposer: {
|
154
|
+
enabled: plugin.includes('message-composer')
|
155
|
+
},
|
156
|
+
messageBuilder: {
|
157
|
+
enabled: plugin.includes('message-builder')
|
158
|
+
},
|
159
|
+
bundle: {
|
160
|
+
enabled: bundle,
|
161
|
+
scope: bundleScope,
|
162
|
+
bundleFile
|
163
|
+
}
|
164
|
+
};
|
165
|
+
await (0, index_1.default)({
|
166
|
+
contracts: [
|
167
|
+
{
|
168
|
+
name,
|
169
|
+
dir: schema
|
170
|
+
}
|
171
|
+
],
|
172
|
+
outPath: out,
|
173
|
+
options
|
174
|
+
});
|
175
|
+
};
|
@@ -0,0 +1,107 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const path_1 = require("path");
|
4
|
+
const mkdirp_1 = require("mkdirp");
|
5
|
+
const glob_1 = require("glob");
|
6
|
+
const rimraf_1 = require("rimraf");
|
7
|
+
const shelljs_1 = require("shelljs");
|
8
|
+
const prompt_1 = require("../utils/prompt");
|
9
|
+
const parse_package_name_1 = require("parse-package-name");
|
10
|
+
const os_1 = require("os");
|
11
|
+
const fs_1 = require("fs");
|
12
|
+
const TMPDIR = (0, os_1.tmpdir)();
|
13
|
+
const rnd = () => Math.random().toString(36).substring(2, 15) +
|
14
|
+
Math.random().toString(36).substring(2, 15);
|
15
|
+
const getPackages = (names) => {
|
16
|
+
return names.map(pkg => {
|
17
|
+
const { name, version } = (0, parse_package_name_1.parse)(pkg);
|
18
|
+
return `${name}@${version}`;
|
19
|
+
}).join(' ');
|
20
|
+
};
|
21
|
+
exports.default = async (argv) => {
|
22
|
+
// don't prompt if we got this...
|
23
|
+
if (argv._.length) {
|
24
|
+
argv.pkg = argv._;
|
25
|
+
}
|
26
|
+
// current dir/package
|
27
|
+
const cur = process.cwd();
|
28
|
+
let thisPackage;
|
29
|
+
try {
|
30
|
+
thisPackage = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(cur, 'package.json'), 'utf-8'));
|
31
|
+
}
|
32
|
+
catch (e) {
|
33
|
+
throw new Error('make sure you are inside of a telescope package!');
|
34
|
+
}
|
35
|
+
// what are we installing?
|
36
|
+
let { pkg } = await (0, prompt_1.prompt)([
|
37
|
+
{
|
38
|
+
type: 'checkbox',
|
39
|
+
name: 'pkg',
|
40
|
+
message: 'which chain contracts do you want to support?',
|
41
|
+
choices: [
|
42
|
+
'stargaze-base-factory',
|
43
|
+
'stargaze-base-minter',
|
44
|
+
'stargaze-sg721-base',
|
45
|
+
'stargaze-sg721-metdata-onchain',
|
46
|
+
'stargaze-sg721-nt',
|
47
|
+
'stargaze-splits',
|
48
|
+
'stargaze-vending-factory',
|
49
|
+
'stargaze-vending-minter',
|
50
|
+
'stargaze-whitelist',
|
51
|
+
'wasmswap'
|
52
|
+
].map(name => {
|
53
|
+
return {
|
54
|
+
name,
|
55
|
+
value: `@cosmjson/${name}`
|
56
|
+
};
|
57
|
+
})
|
58
|
+
}
|
59
|
+
], argv);
|
60
|
+
// install
|
61
|
+
if (!Array.isArray(pkg))
|
62
|
+
pkg = [pkg];
|
63
|
+
const tmp = (0, path_1.join)(TMPDIR, rnd());
|
64
|
+
(0, mkdirp_1.sync)(tmp);
|
65
|
+
process.chdir(tmp);
|
66
|
+
(0, shelljs_1.exec)(`npm install ${getPackages(pkg)} --production --prefix ./smart-contracts`);
|
67
|
+
// protos
|
68
|
+
const pkgs = (0, glob_1.sync)('./smart-contracts/**/package.json');
|
69
|
+
const cmds = pkgs
|
70
|
+
.filter((f) => { return f !== './smart-contracts/package.json'; })
|
71
|
+
.map((f) => (0, path_1.resolve)((0, path_1.join)(tmp, f)))
|
72
|
+
.map((conf) => {
|
73
|
+
const extDir = (0, path_1.dirname)(conf);
|
74
|
+
const dir = extDir.split('node_modules/')[1];
|
75
|
+
const dst = (0, path_1.basename)(dir);
|
76
|
+
const files = (0, glob_1.sync)(`${extDir}/**/*`, { nodir: true });
|
77
|
+
files.forEach(f => {
|
78
|
+
if ((0, path_1.extname)(f) === '.json'
|
79
|
+
|| f === 'package.json'
|
80
|
+
|| /license/i.test(f)
|
81
|
+
|| /readme/i.test(f))
|
82
|
+
return;
|
83
|
+
(0, rimraf_1.sync)(f);
|
84
|
+
});
|
85
|
+
return [extDir, (0, path_1.resolve)((0, path_1.join)(cur, 'contracts', dst)), dir];
|
86
|
+
});
|
87
|
+
// move protos
|
88
|
+
for (const [src, dst, pkg] of cmds) {
|
89
|
+
(0, rimraf_1.sync)(dst);
|
90
|
+
console.log(`installing ${pkg}...`);
|
91
|
+
(0, mkdirp_1.sync)((0, path_1.dirname)(dst));
|
92
|
+
(0, shelljs_1.exec)(`mv ${src} ${dst}`);
|
93
|
+
}
|
94
|
+
// package
|
95
|
+
const packageInfo = JSON.parse((0, fs_1.readFileSync)('./smart-contracts/package.json', 'utf-8'));
|
96
|
+
const deps = packageInfo.dependencies ?? {};
|
97
|
+
thisPackage.devDependencies = thisPackage.devDependencies ?? {};
|
98
|
+
thisPackage.devDependencies = {
|
99
|
+
...thisPackage.devDependencies,
|
100
|
+
...deps
|
101
|
+
};
|
102
|
+
thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
|
103
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cur, 'package.json'), JSON.stringify(thisPackage, null, 2));
|
104
|
+
// cleanup
|
105
|
+
(0, rimraf_1.sync)(tmp);
|
106
|
+
process.chdir(cur);
|
107
|
+
};
|