@makano/rew 1.2.3 → 1.2.5
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/bin/rew +1 -0
- package/jsconfig.json +13 -0
- package/lib/rew/cli/cli.js +83 -39
- package/lib/rew/cli/log.js +5 -1
- package/lib/rew/cli/run.js +2 -2
- package/lib/rew/cli/utils.js +140 -65
- package/lib/rew/const/default.js +9 -0
- package/lib/rew/const/opt.js +1 -1
- package/lib/rew/functions/curl.js +1 -1
- package/lib/rew/functions/exec.js +2 -2
- package/lib/rew/functions/id.js +2 -2
- package/lib/rew/functions/import.js +19 -3
- package/lib/rew/functions/json.js +27 -0
- package/lib/rew/functions/require.js +34 -14
- package/lib/rew/modules/compiler.js +29 -2
- package/lib/rew/modules/context.js +16 -13
- package/lib/rew/modules/yaml.js +1 -1
- package/lib/rew/pkgs/conf.js +3 -2
- package/lib/rew/pkgs/rune.js +8 -1
- package/package.json +4 -1
- package/runtime.d.ts +371 -0
package/runtime.d.ts
ADDED
@@ -0,0 +1,371 @@
|
|
1
|
+
|
2
|
+
interface ImportOptions {
|
3
|
+
/**
|
4
|
+
* Determines how to import the given module
|
5
|
+
*/
|
6
|
+
type: 'js' | 'coffee' | 'yaml' | 'json' | 'qrew';
|
7
|
+
[key: string]: any;
|
8
|
+
}
|
9
|
+
|
10
|
+
interface ModuleConfOptionCenter {
|
11
|
+
/**
|
12
|
+
* Get a config key
|
13
|
+
* @param key The key of the config to get
|
14
|
+
* @param defaultValue The default value ig null
|
15
|
+
* @returns The value of the key or the defaultValue if it's null.
|
16
|
+
*/
|
17
|
+
get: <T = any>(key: string, defaultValue?: T) => T
|
18
|
+
/**
|
19
|
+
* Set a config key
|
20
|
+
* @param key The key of the config to set
|
21
|
+
* @param value The value to set it to
|
22
|
+
* @returns true if it was a success
|
23
|
+
*/
|
24
|
+
set: <T = any>(key: string, value: T) => boolean
|
25
|
+
/**
|
26
|
+
* Removes a key from the config
|
27
|
+
* @param key The key of the config to remove
|
28
|
+
* @returns true if it was a success
|
29
|
+
*/
|
30
|
+
remove: (key: string) => boolean
|
31
|
+
/**
|
32
|
+
* Resets the entire config option center to it's default value
|
33
|
+
*/
|
34
|
+
reset: () => boolean
|
35
|
+
/**
|
36
|
+
* Get all values in an option center
|
37
|
+
* @param str
|
38
|
+
* @returns
|
39
|
+
*/
|
40
|
+
getAll: (() => string) | ((str?: false) => Record<string, any>)
|
41
|
+
}
|
42
|
+
|
43
|
+
interface ModuleConf extends ModuleConfOptionCenter {
|
44
|
+
/**
|
45
|
+
* A separate options file for a related set of options
|
46
|
+
* @param name The option center full path
|
47
|
+
* @param defaults The default values
|
48
|
+
*
|
49
|
+
* @example
|
50
|
+
* conf = imp 'conf'
|
51
|
+
*
|
52
|
+
* animations = conf.optionCenter 'animations', enable: false, speed: '1x'
|
53
|
+
*
|
54
|
+
* if animations.get 'enable'
|
55
|
+
* animate animations.get 'speed'
|
56
|
+
*/
|
57
|
+
optionCenter: (name: string, defaults?: any) => ModuleConfOptionCenter;
|
58
|
+
/**
|
59
|
+
* Manage Static files
|
60
|
+
*/
|
61
|
+
staticFile: (name: string, defaults?: any) => {
|
62
|
+
write: (value: any, ifExists?: boolean) => this,
|
63
|
+
read: (to?: string | object) => string | object | Buffer,
|
64
|
+
fileRoot: string,
|
65
|
+
exists: boolean
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
interface ModuleEnv {
|
70
|
+
has: (key: string) => boolean,
|
71
|
+
get: (key: string) => string,
|
72
|
+
set: (key: string, value: string) => boolean,
|
73
|
+
rm: (key: string) => boolean,
|
74
|
+
is: (key: string, value: string) => boolean,
|
75
|
+
}
|
76
|
+
|
77
|
+
interface ModuleRuneDBCollcetion {
|
78
|
+
insert(record: object): any;
|
79
|
+
read(id: string | object, evaluate?: boolean): any;
|
80
|
+
update(caseRecord: string | object, newRecord: object): any;
|
81
|
+
remove(id: string | object): boolean;
|
82
|
+
find(criteria: string | object): any;
|
83
|
+
map(cb: (data: any[]) => any[], mutate?: boolean): any[];
|
84
|
+
transform(cb: (data: any[]) => any[], mutate?: boolean): any[];
|
85
|
+
filter(cb: (data: any[]) => boolean, mutate?: boolean): any[];
|
86
|
+
sort(cb: (a: any, b: any) => number, mutate?: boolean): any[];
|
87
|
+
list(): any[];
|
88
|
+
}
|
89
|
+
|
90
|
+
interface ModuleRuneDBMap {
|
91
|
+
set(key: string, value: any): void;
|
92
|
+
get(key: string): any | null;
|
93
|
+
remove(key: string): boolean;
|
94
|
+
transform(cb: (data: any) => any, mutate?: boolean): any;
|
95
|
+
list(): { [key: string]: any };
|
96
|
+
}
|
97
|
+
|
98
|
+
interface ModuleRuneDB {
|
99
|
+
collection: (name: string) => ModuleRuneDBCollcetion
|
100
|
+
map: (name: string) => ModuleRuneDBMap
|
101
|
+
findRef: (ref: string) => any
|
102
|
+
setData: (data: Record<string, any>) => void
|
103
|
+
getData: () => Record<string, any>
|
104
|
+
makeRef(value: object, props?: string): string | null;
|
105
|
+
}
|
106
|
+
|
107
|
+
interface ModuleRune {
|
108
|
+
db(dbname: string, data?: object, encryptionKey?: string): ModuleRuneDB;
|
109
|
+
genKey(secret: string): string;
|
110
|
+
push(...values: any[]): PushChange;
|
111
|
+
pop(...values: any[]): PopChange;
|
112
|
+
}
|
113
|
+
|
114
|
+
interface ModuleThreads {
|
115
|
+
thread: (cb: Function) => {
|
116
|
+
stopAll: () => void
|
117
|
+
start: (context: Record<string, any>) => {
|
118
|
+
on: (event: string, callback: (data) => void) => void;
|
119
|
+
off: (event: string, callback: (data) => void) => void;
|
120
|
+
emit: (event: string, data: any) => void;
|
121
|
+
get: () => Promise,
|
122
|
+
stop: () => void
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
declare function imp(path: "conf", options?: ImportOptions): ModuleConf;
|
128
|
+
declare function imp(path: "env", options?: ImportOptions): ModuleEnv;
|
129
|
+
declare function imp(path: "rune", options?: ImportOptions): ModuleRune;
|
130
|
+
declare function imp(path: "threads", options?: ImportOptions): ModuleThreads;
|
131
|
+
declare function imp(path: string, options?: ImportOptions): any;
|
132
|
+
|
133
|
+
declare const inc = imp;
|
134
|
+
|
135
|
+
declare function require(moduleName: string): any;
|
136
|
+
|
137
|
+
interface Module {
|
138
|
+
exports: any;
|
139
|
+
filepath: string;
|
140
|
+
main: boolean;
|
141
|
+
impots: string[];
|
142
|
+
compiled: string
|
143
|
+
}
|
144
|
+
|
145
|
+
declare const module: Module;
|
146
|
+
|
147
|
+
interface Imports {
|
148
|
+
meta: {},
|
149
|
+
assets: any
|
150
|
+
}
|
151
|
+
|
152
|
+
declare const imports: Imports;
|
153
|
+
|
154
|
+
declare const process: {
|
155
|
+
argv: string[],
|
156
|
+
target: ReturnType<typeof emitter>,
|
157
|
+
__execFile: string,
|
158
|
+
env: Record<string, any>,
|
159
|
+
cwd: () => string,
|
160
|
+
arch: string,
|
161
|
+
exit: () => void
|
162
|
+
};
|
163
|
+
|
164
|
+
interface AppConfig {
|
165
|
+
manifest: {
|
166
|
+
package: string
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
declare const app: {
|
171
|
+
path: string,
|
172
|
+
config: AppConfig
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
declare function read(filepath: string, options?: { encoding: string }): string;
|
177
|
+
|
178
|
+
declare function realpath(filepath: string, options?: { encoding: string }): string;
|
179
|
+
|
180
|
+
declare function write(filepath: string, content: any, options?: any): void;
|
181
|
+
|
182
|
+
declare function exists(filepath: string, options?: any): boolean;
|
183
|
+
|
184
|
+
declare function fstat(filepath: string, options?: any): any;
|
185
|
+
|
186
|
+
declare function rm(filepath: string, options?: any): void;
|
187
|
+
|
188
|
+
declare function chmod(filepath: string, mode: any, options?: any): void;
|
189
|
+
|
190
|
+
declare function mkdir(filepath: string, options?: any): void;
|
191
|
+
|
192
|
+
declare function ls(filepath: string, options?: any): string[];
|
193
|
+
|
194
|
+
declare function struct(template: { [key: string]: any }): (...args: any[]) => any;
|
195
|
+
|
196
|
+
declare function future(callback: (resolve: (data: any) => void, reject: (data: any) => void) => void, timeout?: number, defData?: any): {
|
197
|
+
pipe(callback: (data: any) => any): Promise<any>;
|
198
|
+
last(callback: (data: any) => any): Promise<any>;
|
199
|
+
catch(callback: (data: any) => any): Promise<any>;
|
200
|
+
resolve(data: any): void;
|
201
|
+
reject(data: any): void;
|
202
|
+
wait(): Promise<any>;
|
203
|
+
};
|
204
|
+
declare namespace future {
|
205
|
+
function promise(promse: Promise<any>, timeout?: number, defData?: any): ReturnType<typeof future>;
|
206
|
+
}
|
207
|
+
|
208
|
+
declare function emitter(): {
|
209
|
+
on(event: string | string[], callback: (...args: any[]) => void, props?: {}): ReturnType<typeof emitter>;
|
210
|
+
off(event: string | string[], callback: (...args: any[]) => void, removable?: (event: any) => void): ReturnType<typeof emitter>;
|
211
|
+
emit(event: string | string[], ...data: any[]): ReturnType<typeof emitter>;
|
212
|
+
};
|
213
|
+
declare function exec(command: string, options?: { output?: boolean }): any;
|
214
|
+
declare namespace exec {
|
215
|
+
function background(command: string, options?: any, callback?: (...args: any[]) => void): any;
|
216
|
+
}
|
217
|
+
declare function spawn(command: string, ...args: any[]): any;
|
218
|
+
|
219
|
+
declare function typedef(value: any, strict?: boolean): { strict: boolean; defaultValue: any; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
|
220
|
+
|
221
|
+
declare function typeis(obj: any, typeDef: any): boolean;
|
222
|
+
|
223
|
+
declare function typex(child: any, parent: any): boolean;
|
224
|
+
|
225
|
+
declare function typei(child: any, parent: any): boolean;
|
226
|
+
|
227
|
+
declare function int(str: string): number;
|
228
|
+
|
229
|
+
declare namespace int {
|
230
|
+
const type: { strict: boolean; defaultValue: number; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
|
231
|
+
}
|
232
|
+
declare function float(str: string): number;
|
233
|
+
declare namespace float {
|
234
|
+
const type: { strict: boolean; defaultValue: number; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
|
235
|
+
}
|
236
|
+
declare function num(str: string): number;
|
237
|
+
declare namespace num {
|
238
|
+
const type: { strict: boolean; defaultValue: number; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
|
239
|
+
}
|
240
|
+
declare function str(str: any): string;
|
241
|
+
declare namespace str {
|
242
|
+
const type: { strict: boolean; defaultValue: string; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
|
243
|
+
}
|
244
|
+
declare function bool(value: any): boolean;
|
245
|
+
declare namespace bool {
|
246
|
+
const type: { strict: boolean; defaultValue: boolean; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
|
247
|
+
}
|
248
|
+
declare function isEmpty(value: any): boolean;
|
249
|
+
declare function clone(value: any): any;
|
250
|
+
declare function deepClone(value: any): any;
|
251
|
+
declare function merge(obj1: any, obj2: any): any;
|
252
|
+
declare const uniqueId: () => string;
|
253
|
+
declare function filter(arr: any[], fn: (value: any) => boolean): any[];
|
254
|
+
declare function reduce(arr: any[], fn: (acc: any, value: any) => any, initial: any): any;
|
255
|
+
declare function compose(...fns: Function[]): (initialValue: any) => any;
|
256
|
+
declare function curry(fn: Function): (...args: any[]) => any;
|
257
|
+
declare function json(thing: string): any;
|
258
|
+
declare function jsons(thing: any): string;
|
259
|
+
declare function yaml(thing: any): any;
|
260
|
+
declare function yamls(thing: any): string;
|
261
|
+
|
262
|
+
|
263
|
+
/**
|
264
|
+
* Makes a HTTP request to the specified URL.
|
265
|
+
* @param url The URL to request.
|
266
|
+
* @param options The options for the request.
|
267
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
268
|
+
*/
|
269
|
+
declare function curl(url: string, options: {
|
270
|
+
/**
|
271
|
+
* Indicates whether to return a promise.
|
272
|
+
*/
|
273
|
+
a: true,
|
274
|
+
/**
|
275
|
+
* Indicates whether to return the response as plain text.
|
276
|
+
*/
|
277
|
+
text: true,
|
278
|
+
o?: string
|
279
|
+
}): Promise<string>;
|
280
|
+
/**
|
281
|
+
* Makes a HTTP request to the specified URL.
|
282
|
+
* @param url The URL to request.
|
283
|
+
* @param options The options for the request.
|
284
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
285
|
+
*/
|
286
|
+
declare function curl(url: string, options: {
|
287
|
+
/**
|
288
|
+
* Indicates whether to return a promise.
|
289
|
+
*/
|
290
|
+
a: true,
|
291
|
+
/**
|
292
|
+
* Indicates whether to return the response as JSON.
|
293
|
+
*/
|
294
|
+
json: true,
|
295
|
+
/**
|
296
|
+
* The file path to output the response.
|
297
|
+
*/
|
298
|
+
o?: string
|
299
|
+
}): Promise<object>;
|
300
|
+
/**
|
301
|
+
* Makes a HTTP request to the specified URL.
|
302
|
+
* @param url The URL to request.
|
303
|
+
* @param options The options for the request.
|
304
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
305
|
+
*/
|
306
|
+
declare function curl(url: string, options: {
|
307
|
+
/**
|
308
|
+
* Indicates whether to return a promise.
|
309
|
+
*/
|
310
|
+
a: true,
|
311
|
+
/**
|
312
|
+
* The file path to output the response.
|
313
|
+
*/
|
314
|
+
o?: string
|
315
|
+
}): Promise<Response>;
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Makes a HTTP request to the specified URL.
|
319
|
+
* @param url The URL to request.
|
320
|
+
* @param options The options for the request.
|
321
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
322
|
+
*/
|
323
|
+
declare function curl(url: string, options?: {
|
324
|
+
/**
|
325
|
+
* Indicates whether to return a promise.
|
326
|
+
*/
|
327
|
+
a?: boolean,
|
328
|
+
/**
|
329
|
+
* The file path to output the response.
|
330
|
+
*/
|
331
|
+
o?: string,
|
332
|
+
/**
|
333
|
+
* Indicates whether to return the response as JSON.
|
334
|
+
*/
|
335
|
+
json?: boolean,
|
336
|
+
/**
|
337
|
+
* Indicates whether to return the response as plain text.
|
338
|
+
*/
|
339
|
+
text?: boolean
|
340
|
+
}): ReturnType<typeof future>;
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
declare function print(...args: any[]): void;
|
346
|
+
declare namespace print {
|
347
|
+
const stdout: WriteStream;
|
348
|
+
const stdin: ReadStream;
|
349
|
+
};
|
350
|
+
|
351
|
+
declare function input(prompt: string): string;
|
352
|
+
|
353
|
+
|
354
|
+
declare const basename: (path: string) => string;
|
355
|
+
declare const dirname: (path: string) => string;
|
356
|
+
declare const extname: (path: string) => string;
|
357
|
+
declare const pjoin: (...paths: string[]) => string;
|
358
|
+
declare const presolve: (...paths: string[]) => string;
|
359
|
+
|
360
|
+
declare function exports(value: any) : any;
|
361
|
+
|
362
|
+
declare function pub(value: any) : any;
|
363
|
+
declare function pub(name: string, value: any) : any;
|
364
|
+
|
365
|
+
declare const opt: {
|
366
|
+
set: (key: string, value: any) => void;
|
367
|
+
get: (key: string) => any,
|
368
|
+
push: (key: string, value: any) => any,
|
369
|
+
pop: (key: string) => any,
|
370
|
+
}
|
371
|
+
|