@hypequery/cli 0.0.5 → 0.0.7
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 +201 -0
- package/package.json +11 -11
- package/dist/bin/cli.d.ts +0 -3
- package/dist/bin/cli.d.ts.map +0 -1
- package/dist/bin/cli.js +0 -86
- package/dist/cli.d.ts +0 -4
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -162
- package/dist/commands/create-api-types.d.ts +0 -6
- package/dist/commands/create-api-types.d.ts.map +0 -1
- package/dist/commands/create-api-types.js +0 -149
- package/dist/commands/dev.d.ts +0 -12
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -249
- package/dist/commands/generate.d.ts +0 -8
- package/dist/commands/generate.d.ts.map +0 -1
- package/dist/commands/generate.js +0 -175
- package/dist/commands/init.d.ts +0 -9
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -362
- package/dist/commands/toolkit.d.ts +0 -6
- package/dist/commands/toolkit.d.ts.map +0 -1
- package/dist/commands/toolkit.js +0 -159
- package/dist/generators/clickhouse.d.ts +0 -7
- package/dist/generators/clickhouse.d.ts.map +0 -1
- package/dist/generators/clickhouse.js +0 -229
- package/dist/generators/index.d.ts +0 -7
- package/dist/generators/index.d.ts.map +0 -1
- package/dist/generators/index.js +0 -13
- package/dist/templates/client.d.ts +0 -5
- package/dist/templates/client.d.ts.map +0 -1
- package/dist/templates/client.js +0 -6
- package/dist/templates/env.d.ts +0 -14
- package/dist/templates/env.d.ts.map +0 -1
- package/dist/templates/env.js +0 -37
- package/dist/templates/gitignore.d.ts +0 -13
- package/dist/templates/gitignore.d.ts.map +0 -1
- package/dist/templates/gitignore.js +0 -22
- package/dist/templates/queries.d.ts +0 -8
- package/dist/templates/queries.d.ts.map +0 -1
- package/dist/templates/queries.js +0 -27
- package/dist/test-utils.d.ts +0 -86
- package/dist/test-utils.d.ts.map +0 -1
- package/dist/test-utils.js +0 -153
- package/dist/utils/clickhouse-client.d.ts +0 -11
- package/dist/utils/clickhouse-client.d.ts.map +0 -1
- package/dist/utils/clickhouse-client.js +0 -86
- package/dist/utils/detect-database.d.ts +0 -21
- package/dist/utils/detect-database.d.ts.map +0 -1
- package/dist/utils/detect-database.js +0 -224
- package/dist/utils/ensure-ts-runtime.d.ts +0 -4
- package/dist/utils/ensure-ts-runtime.d.ts.map +0 -1
- package/dist/utils/ensure-ts-runtime.js +0 -66
- package/dist/utils/error-messages.d.ts +0 -6
- package/dist/utils/error-messages.d.ts.map +0 -1
- package/dist/utils/error-messages.js +0 -19
- package/dist/utils/find-files.d.ts +0 -21
- package/dist/utils/find-files.d.ts.map +0 -1
- package/dist/utils/find-files.js +0 -183
- package/dist/utils/load-api.d.ts +0 -2
- package/dist/utils/load-api.d.ts.map +0 -1
- package/dist/utils/load-api.js +0 -308
- package/dist/utils/logger.d.ts +0 -54
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -122
- package/dist/utils/prompts.d.ts +0 -39
- package/dist/utils/prompts.d.ts.map +0 -1
- package/dist/utils/prompts.js +0 -282
package/dist/utils/prompts.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
-
if (ar || !(i in from)) {
|
|
40
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
-
ar[i] = from[i];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
-
};
|
|
46
|
-
import prompts from 'prompts';
|
|
47
|
-
import { logger } from './logger.js';
|
|
48
|
-
// Configure prompts to not exit on cancel
|
|
49
|
-
prompts.override({ onCancel: function () { } });
|
|
50
|
-
/**
|
|
51
|
-
* Prompt for database type selection
|
|
52
|
-
*/
|
|
53
|
-
export function promptDatabaseType() {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var response;
|
|
56
|
-
return __generator(this, function (_a) {
|
|
57
|
-
switch (_a.label) {
|
|
58
|
-
case 0: return [4 /*yield*/, prompts({
|
|
59
|
-
type: 'select',
|
|
60
|
-
name: 'database',
|
|
61
|
-
message: 'Which database are you using?',
|
|
62
|
-
choices: [
|
|
63
|
-
{ title: 'ClickHouse', value: 'clickhouse' },
|
|
64
|
-
{ title: 'BigQuery (coming soon)', value: 'bigquery', disabled: true },
|
|
65
|
-
],
|
|
66
|
-
initial: 0,
|
|
67
|
-
})];
|
|
68
|
-
case 1:
|
|
69
|
-
response = _a.sent();
|
|
70
|
-
return [2 /*return*/, response.database || null];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Prompt for ClickHouse connection details
|
|
77
|
-
*/
|
|
78
|
-
export function promptClickHouseConnection() {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
var response;
|
|
81
|
-
var _a, _b, _c, _d;
|
|
82
|
-
return __generator(this, function (_e) {
|
|
83
|
-
switch (_e.label) {
|
|
84
|
-
case 0: return [4 /*yield*/, prompts([
|
|
85
|
-
{
|
|
86
|
-
type: 'text',
|
|
87
|
-
name: 'host',
|
|
88
|
-
message: 'ClickHouse host (or skip to configure later):',
|
|
89
|
-
initial: (_a = process.env.CLICKHOUSE_HOST) !== null && _a !== void 0 ? _a : '',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
type: 'text',
|
|
93
|
-
name: 'database',
|
|
94
|
-
message: 'Database:',
|
|
95
|
-
initial: (_b = process.env.CLICKHOUSE_DATABASE) !== null && _b !== void 0 ? _b : '',
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
type: 'text',
|
|
99
|
-
name: 'username',
|
|
100
|
-
message: 'Username:',
|
|
101
|
-
initial: (_c = process.env.CLICKHOUSE_USERNAME) !== null && _c !== void 0 ? _c : '',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
type: 'password',
|
|
105
|
-
name: 'password',
|
|
106
|
-
message: 'Password:',
|
|
107
|
-
initial: (_d = process.env.CLICKHOUSE_PASSWORD) !== null && _d !== void 0 ? _d : '',
|
|
108
|
-
},
|
|
109
|
-
])];
|
|
110
|
-
case 1:
|
|
111
|
-
response = _e.sent();
|
|
112
|
-
// If user cancelled or skipped
|
|
113
|
-
if (!response.host) {
|
|
114
|
-
return [2 /*return*/, null];
|
|
115
|
-
}
|
|
116
|
-
return [2 /*return*/, response];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Prompt for output directory
|
|
123
|
-
*/
|
|
124
|
-
export function promptOutputDirectory() {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var response, customResponse;
|
|
127
|
-
return __generator(this, function (_a) {
|
|
128
|
-
switch (_a.label) {
|
|
129
|
-
case 0: return [4 /*yield*/, prompts({
|
|
130
|
-
type: 'select',
|
|
131
|
-
name: 'directory',
|
|
132
|
-
message: 'Where should we create your analytics files?',
|
|
133
|
-
choices: [
|
|
134
|
-
{ title: 'analytics/ (recommended)', value: 'analytics' },
|
|
135
|
-
{ title: 'src/analytics/', value: 'src/analytics' },
|
|
136
|
-
{ title: 'Custom path...', value: 'custom' },
|
|
137
|
-
],
|
|
138
|
-
initial: 0,
|
|
139
|
-
})];
|
|
140
|
-
case 1:
|
|
141
|
-
response = _a.sent();
|
|
142
|
-
if (!response.directory) {
|
|
143
|
-
return [2 /*return*/, 'analytics']; // Default fallback
|
|
144
|
-
}
|
|
145
|
-
if (!(response.directory === 'custom')) return [3 /*break*/, 3];
|
|
146
|
-
return [4 /*yield*/, prompts({
|
|
147
|
-
type: 'text',
|
|
148
|
-
name: 'path',
|
|
149
|
-
message: 'Enter custom path:',
|
|
150
|
-
initial: 'analytics',
|
|
151
|
-
})];
|
|
152
|
-
case 2:
|
|
153
|
-
customResponse = _a.sent();
|
|
154
|
-
return [2 /*return*/, customResponse.path || 'analytics'];
|
|
155
|
-
case 3: return [2 /*return*/, response.directory];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Prompt for example query generation
|
|
162
|
-
*/
|
|
163
|
-
export function promptGenerateExample() {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var response;
|
|
166
|
-
var _a;
|
|
167
|
-
return __generator(this, function (_b) {
|
|
168
|
-
switch (_b.label) {
|
|
169
|
-
case 0: return [4 /*yield*/, prompts({
|
|
170
|
-
type: 'confirm',
|
|
171
|
-
name: 'generate',
|
|
172
|
-
message: 'Generate an example query?',
|
|
173
|
-
initial: true,
|
|
174
|
-
})];
|
|
175
|
-
case 1:
|
|
176
|
-
response = _b.sent();
|
|
177
|
-
return [2 /*return*/, (_a = response.generate) !== null && _a !== void 0 ? _a : false];
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Prompt for table selection (for example query)
|
|
184
|
-
*/
|
|
185
|
-
export function promptTableSelection(tables) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
-
var choices, response;
|
|
188
|
-
return __generator(this, function (_a) {
|
|
189
|
-
switch (_a.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
if (tables.length === 0) {
|
|
192
|
-
return [2 /*return*/, null];
|
|
193
|
-
}
|
|
194
|
-
// Warn if showing truncated list
|
|
195
|
-
if (tables.length > 10) {
|
|
196
|
-
logger.warn("Showing first 10 of ".concat(tables.length, " tables"));
|
|
197
|
-
logger.indent('You can select a different table by editing the generated file');
|
|
198
|
-
logger.newline();
|
|
199
|
-
}
|
|
200
|
-
choices = __spreadArray(__spreadArray([], tables.slice(0, 10).map(function (table) { return ({ title: table, value: table }); }), true), [
|
|
201
|
-
{ title: 'Skip example', value: null },
|
|
202
|
-
], false);
|
|
203
|
-
return [4 /*yield*/, prompts({
|
|
204
|
-
type: 'select',
|
|
205
|
-
name: 'table',
|
|
206
|
-
message: 'Which table should we use for the example?',
|
|
207
|
-
choices: choices,
|
|
208
|
-
initial: 0,
|
|
209
|
-
})];
|
|
210
|
-
case 1:
|
|
211
|
-
response = _a.sent();
|
|
212
|
-
return [2 /*return*/, response.table];
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Confirm overwrite of existing files
|
|
219
|
-
*/
|
|
220
|
-
export function confirmOverwrite(files) {
|
|
221
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
var response;
|
|
223
|
-
var _a;
|
|
224
|
-
return __generator(this, function (_b) {
|
|
225
|
-
switch (_b.label) {
|
|
226
|
-
case 0: return [4 /*yield*/, prompts({
|
|
227
|
-
type: 'confirm',
|
|
228
|
-
name: 'overwrite',
|
|
229
|
-
message: "The following files will be overwritten:\n".concat(files.map(function (f) { return " \u2022 ".concat(f); }).join('\n'), "\n\nContinue?"),
|
|
230
|
-
initial: false,
|
|
231
|
-
})];
|
|
232
|
-
case 1:
|
|
233
|
-
response = _b.sent();
|
|
234
|
-
return [2 /*return*/, (_a = response.overwrite) !== null && _a !== void 0 ? _a : false];
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Retry prompt for failed operations
|
|
241
|
-
*/
|
|
242
|
-
export function promptRetry(message) {
|
|
243
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
244
|
-
var response;
|
|
245
|
-
var _a;
|
|
246
|
-
return __generator(this, function (_b) {
|
|
247
|
-
switch (_b.label) {
|
|
248
|
-
case 0: return [4 /*yield*/, prompts({
|
|
249
|
-
type: 'confirm',
|
|
250
|
-
name: 'retry',
|
|
251
|
-
message: message,
|
|
252
|
-
initial: true,
|
|
253
|
-
})];
|
|
254
|
-
case 1:
|
|
255
|
-
response = _b.sent();
|
|
256
|
-
return [2 /*return*/, (_a = response.retry) !== null && _a !== void 0 ? _a : false];
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Ask if user wants to continue without DB connection
|
|
263
|
-
*/
|
|
264
|
-
export function promptContinueWithoutDb() {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
-
var response;
|
|
267
|
-
var _a;
|
|
268
|
-
return __generator(this, function (_b) {
|
|
269
|
-
switch (_b.label) {
|
|
270
|
-
case 0: return [4 /*yield*/, prompts({
|
|
271
|
-
type: 'confirm',
|
|
272
|
-
name: 'continue',
|
|
273
|
-
message: 'Continue setup without database connection?',
|
|
274
|
-
initial: true,
|
|
275
|
-
})];
|
|
276
|
-
case 1:
|
|
277
|
-
response = _b.sent();
|
|
278
|
-
return [2 /*return*/, (_a = response.continue) !== null && _a !== void 0 ? _a : false];
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
}
|