@flowscripter/example-cli-plugin 1.0.0 → 1.1.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/dist/index.js +322 -17
- package/dist/src/command/HelloCommand.d.ts.map +1 -1
- package/dist/src/plugin.d.ts +2 -3
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/service/DefaultDemoService.d.ts +1 -1
- package/dist/src/service/DefaultDemoService.d.ts.map +1 -1
- package/dist/src/service/DemoService.d.ts +1 -1
- package/dist/src/service/DemoService.d.ts.map +1 -1
- package/dist/tests/plugin.test.d.ts +2 -0
- package/dist/tests/plugin.test.d.ts.map +1 -0
- package/package.json +9 -3
- package/src/command/HelloCommand.ts +9 -4
- package/src/plugin.ts +5 -19
- package/src/service/DefaultDemoService.ts +3 -2
- package/src/service/DemoService.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,81 @@
|
|
|
3
3
|
var DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT = "DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY";
|
|
4
4
|
// node_modules/@flowscripter/dynamic-cli-framework/src/api/plugin/ServiceProviderFactory.ts
|
|
5
5
|
var DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT = "DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY";
|
|
6
|
+
// node_modules/@flowscripter/dynamic-cli-framework/src/api/plugin/createCLIPlugin.ts
|
|
7
|
+
function createCLIPlugin(options) {
|
|
8
|
+
const extensionDescriptors = [];
|
|
9
|
+
if (options.commandFactory) {
|
|
10
|
+
const commandFactory = options.commandFactory;
|
|
11
|
+
extensionDescriptors.push({
|
|
12
|
+
extensionPoint: DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT,
|
|
13
|
+
factory: {
|
|
14
|
+
create: async () => typeof commandFactory === "function" ? commandFactory() : commandFactory
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (options.serviceProviderFactory) {
|
|
19
|
+
const serviceProviderFactory = options.serviceProviderFactory;
|
|
20
|
+
extensionDescriptors.push({
|
|
21
|
+
extensionPoint: DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
|
|
22
|
+
factory: {
|
|
23
|
+
create: async () => typeof serviceProviderFactory === "function" ? serviceProviderFactory() : serviceProviderFactory
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return { extensionDescriptors, pluginData: options.pluginData };
|
|
28
|
+
}
|
|
29
|
+
// node_modules/@flowscripter/dynamic-cli-framework/src/api/service/core/PrinterService.ts
|
|
30
|
+
var PRINTER_SERVICE_ID = "@flowscripter/dynamic-cli-framework/printer-service";
|
|
31
|
+
// node_modules/@flowscripter/dynamic-cli-framework/src/api/service/core/Table.ts
|
|
32
|
+
class Table {
|
|
33
|
+
rowCount;
|
|
34
|
+
columnCount;
|
|
35
|
+
options;
|
|
36
|
+
#columnOptions = new Map;
|
|
37
|
+
#rowOptions = new Map;
|
|
38
|
+
#cells = new Map;
|
|
39
|
+
constructor(rowCount, columnCount, options) {
|
|
40
|
+
this.rowCount = rowCount;
|
|
41
|
+
this.columnCount = columnCount;
|
|
42
|
+
this.options = options ?? {};
|
|
43
|
+
}
|
|
44
|
+
row(rowIndex, rowOptions) {
|
|
45
|
+
if (rowIndex < 0 || rowIndex >= this.rowCount) {
|
|
46
|
+
throw new Error(`Row index ${rowIndex} out of bounds [0, ${this.rowCount})`);
|
|
47
|
+
}
|
|
48
|
+
this.#rowOptions.set(rowIndex, rowOptions);
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
column(columnIndex, columnOptions) {
|
|
52
|
+
if (columnIndex < 0 || columnIndex >= this.columnCount) {
|
|
53
|
+
throw new Error(`Column index ${columnIndex} out of bounds [0, ${this.columnCount})`);
|
|
54
|
+
}
|
|
55
|
+
this.#columnOptions.set(columnIndex, columnOptions);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
cell(rowIndex, columnIndex, contents, cellOptions) {
|
|
59
|
+
if (rowIndex < 0 || rowIndex >= this.rowCount) {
|
|
60
|
+
throw new Error(`Row index ${rowIndex} out of bounds [0, ${this.rowCount})`);
|
|
61
|
+
}
|
|
62
|
+
if (columnIndex < 0 || columnIndex >= this.columnCount) {
|
|
63
|
+
throw new Error(`Column index ${columnIndex} out of bounds [0, ${this.columnCount})`);
|
|
64
|
+
}
|
|
65
|
+
this.#cells.set(`${rowIndex},${columnIndex}`, {
|
|
66
|
+
contents,
|
|
67
|
+
options: cellOptions
|
|
68
|
+
});
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
getColumnOptions(columnIndex) {
|
|
72
|
+
return this.#columnOptions.get(columnIndex);
|
|
73
|
+
}
|
|
74
|
+
getRowOptions(rowIndex) {
|
|
75
|
+
return this.#rowOptions.get(rowIndex);
|
|
76
|
+
}
|
|
77
|
+
getCell(rowIndex, columnIndex) {
|
|
78
|
+
return this.#cells.get(`${rowIndex},${columnIndex}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
6
81
|
// src/service/DemoService.ts
|
|
7
82
|
var DEMO_SERVICE_ID = "DEMO_SERVICE";
|
|
8
83
|
|
|
@@ -22,9 +97,10 @@ var helloCommand = {
|
|
|
22
97
|
],
|
|
23
98
|
execute: async (context, argumentValues) => {
|
|
24
99
|
const demoService = context.getServiceById(DEMO_SERVICE_ID);
|
|
100
|
+
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
25
101
|
const name = argumentValues["name"] ?? "World";
|
|
26
|
-
const greeting = demoService
|
|
27
|
-
|
|
102
|
+
const greeting = demoService.cowsay(name);
|
|
103
|
+
await printerService?.print(greeting);
|
|
28
104
|
}
|
|
29
105
|
};
|
|
30
106
|
var HelloCommand_default = helloCommand;
|
|
@@ -36,10 +112,248 @@ class DemoCommandFactory {
|
|
|
36
112
|
}
|
|
37
113
|
}
|
|
38
114
|
|
|
115
|
+
// node_modules/cowsay/build/cowsay.es.js
|
|
116
|
+
var ansiRegex = () => {
|
|
117
|
+
const pattern = [
|
|
118
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[a-zA-Z\\d]*)*)?\\u0007)",
|
|
119
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
120
|
+
].join("|");
|
|
121
|
+
return new RegExp(pattern, "g");
|
|
122
|
+
};
|
|
123
|
+
var stripAnsi = (input) => typeof input === "string" ? input.replace(ansiRegex(), "") : input;
|
|
124
|
+
var isFullwidthCodePoint = (x) => {
|
|
125
|
+
if (Number.isNaN(x)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (x >= 4352 && (x <= 4447 || x === 9001 || x === 9002 || 11904 <= x && x <= 12871 && x !== 12351 || 12880 <= x && x <= 19903 || 19968 <= x && x <= 42182 || 43360 <= x && x <= 43388 || 44032 <= x && x <= 55203 || 63744 <= x && x <= 64255 || 65040 <= x && x <= 65049 || 65072 <= x && x <= 65131 || 65281 <= x && x <= 65376 || 65504 <= x && x <= 65510 || 110592 <= x && x <= 110593 || 127488 <= x && x <= 127569 || 131072 <= x && x <= 262141)) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
};
|
|
133
|
+
var stringWidth = (str) => {
|
|
134
|
+
if (typeof str !== "string" || str.length === 0) {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
str = stripAnsi(str);
|
|
138
|
+
let width = 0;
|
|
139
|
+
for (let i = 0;i < str.length; i++) {
|
|
140
|
+
const code = str.codePointAt(i);
|
|
141
|
+
if (code <= 31 || code >= 127 && code <= 159) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (code >= 768 && code <= 879) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (code > 65535) {
|
|
148
|
+
i++;
|
|
149
|
+
}
|
|
150
|
+
width += isFullwidthCodePoint(code) ? 2 : 1;
|
|
151
|
+
}
|
|
152
|
+
return width;
|
|
153
|
+
};
|
|
154
|
+
var say = function(text, wrap) {
|
|
155
|
+
var delimiters = {
|
|
156
|
+
first: ["/", "\\"],
|
|
157
|
+
middle: ["|", "|"],
|
|
158
|
+
last: ["\\", "/"],
|
|
159
|
+
only: ["<", ">"]
|
|
160
|
+
};
|
|
161
|
+
return format(text, wrap, delimiters);
|
|
162
|
+
};
|
|
163
|
+
var think = function(text, wrap) {
|
|
164
|
+
var delimiters = {
|
|
165
|
+
first: ["(", ")"],
|
|
166
|
+
middle: ["(", ")"],
|
|
167
|
+
last: ["(", ")"],
|
|
168
|
+
only: ["(", ")"]
|
|
169
|
+
};
|
|
170
|
+
return format(text, wrap, delimiters);
|
|
171
|
+
};
|
|
172
|
+
function format(text, wrap, delimiters) {
|
|
173
|
+
var lines = split(text, wrap);
|
|
174
|
+
var maxLength = max(lines);
|
|
175
|
+
var balloon;
|
|
176
|
+
if (lines.length === 1) {
|
|
177
|
+
balloon = [
|
|
178
|
+
" " + top(maxLength),
|
|
179
|
+
delimiters.only[0] + " " + lines[0] + " " + delimiters.only[1],
|
|
180
|
+
" " + bottom(maxLength)
|
|
181
|
+
];
|
|
182
|
+
} else {
|
|
183
|
+
balloon = [" " + top(maxLength)];
|
|
184
|
+
for (var i = 0, len = lines.length;i < len; i += 1) {
|
|
185
|
+
var delimiter;
|
|
186
|
+
if (i === 0) {
|
|
187
|
+
delimiter = delimiters.first;
|
|
188
|
+
} else if (i === len - 1) {
|
|
189
|
+
delimiter = delimiters.last;
|
|
190
|
+
} else {
|
|
191
|
+
delimiter = delimiters.middle;
|
|
192
|
+
}
|
|
193
|
+
balloon.push(delimiter[0] + " " + pad(lines[i], maxLength) + " " + delimiter[1]);
|
|
194
|
+
}
|
|
195
|
+
balloon.push(" " + bottom(maxLength));
|
|
196
|
+
}
|
|
197
|
+
return balloon.join(`
|
|
198
|
+
`);
|
|
199
|
+
}
|
|
200
|
+
function split(text, wrap) {
|
|
201
|
+
text = text.replace(/\r\n?|[\n\u2028\u2029]/g, `
|
|
202
|
+
`).replace(/^\uFEFF/, "").replace(/\t/g, " ");
|
|
203
|
+
var lines = [];
|
|
204
|
+
if (!wrap) {
|
|
205
|
+
lines = text.split(`
|
|
206
|
+
`);
|
|
207
|
+
} else {
|
|
208
|
+
var start = 0;
|
|
209
|
+
while (start < text.length) {
|
|
210
|
+
var nextNewLine = text.indexOf(`
|
|
211
|
+
`, start);
|
|
212
|
+
var wrapAt = Math.min(start + wrap, nextNewLine === -1 ? text.length : nextNewLine);
|
|
213
|
+
lines.push(text.substring(start, wrapAt));
|
|
214
|
+
start = wrapAt;
|
|
215
|
+
if (text.charAt(start) === `
|
|
216
|
+
`) {
|
|
217
|
+
start += 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return lines;
|
|
222
|
+
}
|
|
223
|
+
function max(lines) {
|
|
224
|
+
var max2 = 0;
|
|
225
|
+
for (var i = 0, len = lines.length;i < len; i += 1) {
|
|
226
|
+
if (stringWidth(lines[i]) > max2) {
|
|
227
|
+
max2 = stringWidth(lines[i]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return max2;
|
|
231
|
+
}
|
|
232
|
+
function pad(text, length) {
|
|
233
|
+
return text + new Array(length - stringWidth(text) + 1).join(" ");
|
|
234
|
+
}
|
|
235
|
+
function top(length) {
|
|
236
|
+
return new Array(length + 3).join("_");
|
|
237
|
+
}
|
|
238
|
+
function bottom(length) {
|
|
239
|
+
return new Array(length + 3).join("-");
|
|
240
|
+
}
|
|
241
|
+
var balloon = {
|
|
242
|
+
say,
|
|
243
|
+
think
|
|
244
|
+
};
|
|
245
|
+
var replacer = function(cow, variables) {
|
|
246
|
+
var eyes = escapeRe(variables.eyes);
|
|
247
|
+
var eyeL = eyes.charAt(0);
|
|
248
|
+
var eyeR = eyes.charAt(1);
|
|
249
|
+
var tongue = escapeRe(variables.tongue);
|
|
250
|
+
if (cow.indexOf("$the_cow") !== -1) {
|
|
251
|
+
cow = extractTheCow(cow);
|
|
252
|
+
}
|
|
253
|
+
return cow.replace(/\$thoughts/g, variables.thoughts).replace(/\$eyes/g, eyes).replace(/\$tongue/g, tongue).replace(/\$\{eyes\}/g, eyes).replace(/\$eye/, eyeL).replace(/\$eye/, eyeR).replace(/\$\{tongue\}/g, tongue);
|
|
254
|
+
};
|
|
255
|
+
function escapeRe(s) {
|
|
256
|
+
if (s && s.replace) {
|
|
257
|
+
return s.replace(/\$/g, "$$$$");
|
|
258
|
+
}
|
|
259
|
+
return s;
|
|
260
|
+
}
|
|
261
|
+
function extractTheCow(cow) {
|
|
262
|
+
cow = cow.replace(/\r\n?|[\n\u2028\u2029]/g, `
|
|
263
|
+
`).replace(/^\uFEFF/, "");
|
|
264
|
+
var match = /\$the_cow\s*=\s*<<"*EOC"*;*\n([\s\S]+)\nEOC\n/.exec(cow);
|
|
265
|
+
if (!match) {
|
|
266
|
+
console.error(`Cannot parse cow file
|
|
267
|
+
`, cow);
|
|
268
|
+
return cow;
|
|
269
|
+
} else {
|
|
270
|
+
return match[1].replace(/\\{2}/g, "\\").replace(/\\@/g, "@").replace(/\\\$/g, "$");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
var modes = {
|
|
274
|
+
b: {
|
|
275
|
+
eyes: "==",
|
|
276
|
+
tongue: " "
|
|
277
|
+
},
|
|
278
|
+
d: {
|
|
279
|
+
eyes: "xx",
|
|
280
|
+
tongue: "U "
|
|
281
|
+
},
|
|
282
|
+
g: {
|
|
283
|
+
eyes: "$$",
|
|
284
|
+
tongue: " "
|
|
285
|
+
},
|
|
286
|
+
p: {
|
|
287
|
+
eyes: "@@",
|
|
288
|
+
tongue: " "
|
|
289
|
+
},
|
|
290
|
+
s: {
|
|
291
|
+
eyes: "**",
|
|
292
|
+
tongue: "U "
|
|
293
|
+
},
|
|
294
|
+
t: {
|
|
295
|
+
eyes: "--",
|
|
296
|
+
tongue: " "
|
|
297
|
+
},
|
|
298
|
+
w: {
|
|
299
|
+
eyes: "OO",
|
|
300
|
+
tongue: " "
|
|
301
|
+
},
|
|
302
|
+
y: {
|
|
303
|
+
eyes: "..",
|
|
304
|
+
tongue: " "
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var faces = function(options) {
|
|
308
|
+
for (var mode in modes) {
|
|
309
|
+
if (options[mode] === true) {
|
|
310
|
+
return modes[mode];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
eyes: options.e || "oo",
|
|
315
|
+
tongue: options.T || " "
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
var DEFAULT_COW = `$the_cow = <<"EOC";
|
|
319
|
+
$thoughts ^__^
|
|
320
|
+
$thoughts ($eyes)\\\\_______
|
|
321
|
+
(__)\\\\ )\\\\/\\\\
|
|
322
|
+
$tongue ||----w |
|
|
323
|
+
|| ||
|
|
324
|
+
EOC
|
|
325
|
+
`;
|
|
326
|
+
function convertToCliOptions(browserOptions) {
|
|
327
|
+
const cliOptions = {
|
|
328
|
+
e: browserOptions.eyes || "oo",
|
|
329
|
+
T: browserOptions.tongue || " ",
|
|
330
|
+
n: browserOptions.wrap,
|
|
331
|
+
W: browserOptions.wrapLength || 40,
|
|
332
|
+
text: browserOptions.text || "",
|
|
333
|
+
_: browserOptions.text || [],
|
|
334
|
+
f: browserOptions.cow
|
|
335
|
+
};
|
|
336
|
+
if (browserOptions.mode) {
|
|
337
|
+
cliOptions[browserOptions.mode] = true;
|
|
338
|
+
}
|
|
339
|
+
return cliOptions;
|
|
340
|
+
}
|
|
341
|
+
function doIt(options, sayAloud) {
|
|
342
|
+
const cow = options.f || DEFAULT_COW;
|
|
343
|
+
const face = faces(options);
|
|
344
|
+
face.thoughts = sayAloud ? "\\" : "o";
|
|
345
|
+
const action = sayAloud ? "say" : "think";
|
|
346
|
+
return balloon[action](options.text || options._.join(" "), options.n ? null : options.W) + `
|
|
347
|
+
` + replacer(cow, face);
|
|
348
|
+
}
|
|
349
|
+
function say$1(browserOptions) {
|
|
350
|
+
return doIt(convertToCliOptions(browserOptions), true);
|
|
351
|
+
}
|
|
352
|
+
|
|
39
353
|
// src/service/DefaultDemoService.ts
|
|
40
354
|
class DefaultDemoService {
|
|
41
|
-
|
|
42
|
-
return `Hello, ${name}
|
|
355
|
+
cowsay(name) {
|
|
356
|
+
return say$1({ text: `Hello, ${name}!` });
|
|
43
357
|
}
|
|
44
358
|
}
|
|
45
359
|
|
|
@@ -61,19 +375,10 @@ class DemoServiceProviderFactory {
|
|
|
61
375
|
}
|
|
62
376
|
|
|
63
377
|
// src/plugin.ts
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
factory: { create: async () => new DemoCommandFactory }
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
extensionPoint: DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
|
|
72
|
-
factory: { create: async () => new DemoServiceProviderFactory }
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
|
-
var plugin_default = plugin;
|
|
378
|
+
var plugin_default = createCLIPlugin({
|
|
379
|
+
commandFactory: new DemoCommandFactory,
|
|
380
|
+
serviceProviderFactory: new DemoServiceProviderFactory
|
|
381
|
+
});
|
|
77
382
|
export {
|
|
78
383
|
plugin_default as default
|
|
79
384
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelloCommand.d.ts","sourceRoot":"","sources":["../../../src/command/HelloCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,
|
|
1
|
+
{"version":3,"file":"HelloCommand.d.ts","sourceRoot":"","sources":["../../../src/command/HelloCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,4CAA4C,CAAC;AAQpD,QAAA,MAAM,YAAY,EAAE,UAoBnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default plugin;
|
|
1
|
+
declare const _default: import("@flowscripter/dynamic-cli-framework/plugin").CLIPlugin;
|
|
2
|
+
export default _default;
|
|
4
3
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/src/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":";AAIA,wBAGG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultDemoService.d.ts","sourceRoot":"","sources":["../../../src/service/DefaultDemoService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DefaultDemoService.d.ts","sourceRoot":"","sources":["../../../src/service/DefaultDemoService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,WAAW;IAC5D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DemoService.d.ts","sourceRoot":"","sources":["../../../src/service/DemoService.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,MAAM,CAAC,OAAO,WAAW,WAAW;IAClC,
|
|
1
|
+
{"version":3,"file":"DemoService.d.ts","sourceRoot":"","sources":["../../../src/service/DemoService.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,MAAM,CAAC,OAAO,WAAW,WAAW;IAClC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.test.d.ts","sourceRoot":"","sources":["../../tests/plugin.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/example-cli-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Example CLI plugin for the https://github.com/flowscripter/dynamic-cli-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"build": "bun build index.ts --outdir dist --target bun && tsc -p tsconfig.build.json"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"
|
|
45
|
+
"cowsay": "^1.6.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@flowscripter/dynamic-cli-framework": "1.
|
|
48
|
+
"@flowscripter/dynamic-cli-framework": "1.7.0",
|
|
49
49
|
"@types/bun": "^1.3.14",
|
|
50
50
|
"oxfmt": "0.56.0",
|
|
51
51
|
"oxlint": "1.71.0"
|
|
@@ -59,5 +59,11 @@
|
|
|
59
59
|
"DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY",
|
|
60
60
|
"DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY"
|
|
61
61
|
]
|
|
62
|
+
},
|
|
63
|
+
"typedocOptions": {
|
|
64
|
+
"readme": "none",
|
|
65
|
+
"exclude": [
|
|
66
|
+
"tests/**"
|
|
67
|
+
]
|
|
62
68
|
}
|
|
63
69
|
}
|
|
@@ -2,8 +2,12 @@ import type {
|
|
|
2
2
|
SubCommand,
|
|
3
3
|
Context,
|
|
4
4
|
ArgumentValues,
|
|
5
|
+
PrinterService,
|
|
6
|
+
} from "@flowscripter/dynamic-cli-framework/plugin";
|
|
7
|
+
import {
|
|
8
|
+
ArgumentValueTypeName,
|
|
9
|
+
PRINTER_SERVICE_ID,
|
|
5
10
|
} from "@flowscripter/dynamic-cli-framework/plugin";
|
|
6
|
-
import { ArgumentValueTypeName } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
7
11
|
import { DEMO_SERVICE_ID } from "../service/DemoService.ts";
|
|
8
12
|
import type DemoService from "../service/DemoService.ts";
|
|
9
13
|
|
|
@@ -21,10 +25,11 @@ const helloCommand: SubCommand = {
|
|
|
21
25
|
},
|
|
22
26
|
],
|
|
23
27
|
execute: async (context: Context, argumentValues: ArgumentValues) => {
|
|
24
|
-
const demoService = context.getServiceById(DEMO_SERVICE_ID) as DemoService
|
|
28
|
+
const demoService = context.getServiceById(DEMO_SERVICE_ID) as DemoService;
|
|
29
|
+
const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
|
|
25
30
|
const name = (argumentValues["name"] as string | undefined) ?? "World";
|
|
26
|
-
const greeting = demoService
|
|
27
|
-
|
|
31
|
+
const greeting = demoService.cowsay(name);
|
|
32
|
+
await printerService?.print(greeting);
|
|
28
33
|
},
|
|
29
34
|
};
|
|
30
35
|
|
package/src/plugin.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT,
|
|
4
|
-
DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
|
|
5
|
-
} from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import { createCLIPlugin } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
6
2
|
import DemoCommandFactory from "./factory/DemoCommandFactory.ts";
|
|
7
3
|
import DemoServiceProviderFactory from "./factory/DemoServiceProviderFactory.ts";
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
factory: { create: async () => new DemoCommandFactory() },
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
extensionPoint: DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
|
|
17
|
-
factory: { create: async () => new DemoServiceProviderFactory() },
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default plugin;
|
|
5
|
+
export default createCLIPlugin({
|
|
6
|
+
commandFactory: new DemoCommandFactory(),
|
|
7
|
+
serviceProviderFactory: new DemoServiceProviderFactory(),
|
|
8
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import * as cowsay from "cowsay";
|
|
1
2
|
import type DemoService from "./DemoService.ts";
|
|
2
3
|
|
|
3
4
|
export default class DefaultDemoService implements DemoService {
|
|
4
|
-
|
|
5
|
-
return `Hello, ${name}
|
|
5
|
+
cowsay(name: string): string {
|
|
6
|
+
return cowsay.say({ text: `Hello, ${name}!` });
|
|
6
7
|
}
|
|
7
8
|
}
|