@flowscripter/example-cli-plugin 1.1.1 → 1.1.3
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 +1 -386
- package/dist/src/command/HelloCommand.d.ts +1 -1
- package/dist/src/command/HelloCommand.d.ts.map +1 -1
- package/dist/src/command/HelloCommand.js +25 -0
- package/dist/src/factory/DemoCommandFactory.d.ts +2 -2
- package/dist/src/factory/DemoCommandFactory.d.ts.map +1 -1
- package/dist/src/factory/DemoCommandFactory.js +6 -0
- package/dist/src/factory/DemoServiceProviderFactory.d.ts +1 -1
- package/dist/src/factory/DemoServiceProviderFactory.d.ts.map +1 -1
- package/dist/src/factory/DemoServiceProviderFactory.js +6 -0
- package/dist/src/plugin.d.ts +1 -1
- package/dist/src/plugin.js +7 -0
- package/dist/src/service/DefaultDemoService.js +6 -0
- package/dist/src/service/DemoService.js +1 -0
- package/dist/src/service/DemoServiceProvider.d.ts +1 -1
- package/dist/src/service/DemoServiceProvider.d.ts.map +1 -1
- package/dist/src/service/DemoServiceProvider.js +10 -0
- package/package.json +3 -3
- package/src/command/HelloCommand.ts +2 -2
- package/src/factory/DemoCommandFactory.ts +1 -1
- package/src/factory/DemoServiceProviderFactory.ts +1 -1
- package/src/plugin.ts +1 -1
- package/src/service/DemoServiceProvider.ts +1 -1
- package/dist/tests/plugin.test.d.ts +0 -2
- package/dist/tests/plugin.test.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,386 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// node_modules/@flowscripter/dynamic-cli-framework/src/api/plugin/CommandFactory.ts
|
|
3
|
-
var DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT = "DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY";
|
|
4
|
-
// node_modules/@flowscripter/dynamic-cli-framework/src/api/plugin/ServiceProviderFactory.ts
|
|
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
|
-
}
|
|
81
|
-
// src/service/DemoService.ts
|
|
82
|
-
var DEMO_SERVICE_ID = "DEMO_SERVICE";
|
|
83
|
-
|
|
84
|
-
// src/command/HelloCommand.ts
|
|
85
|
-
var helloCommand = {
|
|
86
|
-
name: "hello",
|
|
87
|
-
description: "Greet someone using the demo service",
|
|
88
|
-
helpTopic: "Hello",
|
|
89
|
-
enableConfiguration: false,
|
|
90
|
-
options: [],
|
|
91
|
-
positionals: [
|
|
92
|
-
{
|
|
93
|
-
name: "name",
|
|
94
|
-
description: "Name to greet",
|
|
95
|
-
type: 0 /* STRING */,
|
|
96
|
-
isVarargOptional: true
|
|
97
|
-
}
|
|
98
|
-
],
|
|
99
|
-
execute: async (context, argumentValues) => {
|
|
100
|
-
const demoService = context.getServiceById(DEMO_SERVICE_ID);
|
|
101
|
-
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
102
|
-
const name = argumentValues["name"] ?? "World";
|
|
103
|
-
const greeting = demoService.cowsay(name);
|
|
104
|
-
await printerService?.print(`${greeting}
|
|
105
|
-
`);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var HelloCommand_default = helloCommand;
|
|
109
|
-
|
|
110
|
-
// src/factory/DemoCommandFactory.ts
|
|
111
|
-
class DemoCommandFactory {
|
|
112
|
-
getCommands() {
|
|
113
|
-
return [HelloCommand_default];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// node_modules/cowsay/build/cowsay.es.js
|
|
118
|
-
var ansiRegex = () => {
|
|
119
|
-
const pattern = [
|
|
120
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[a-zA-Z\\d]*)*)?\\u0007)",
|
|
121
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
122
|
-
].join("|");
|
|
123
|
-
return new RegExp(pattern, "g");
|
|
124
|
-
};
|
|
125
|
-
var stripAnsi = (input) => typeof input === "string" ? input.replace(ansiRegex(), "") : input;
|
|
126
|
-
var isFullwidthCodePoint = (x) => {
|
|
127
|
-
if (Number.isNaN(x)) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
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)) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
};
|
|
135
|
-
var stringWidth = (str) => {
|
|
136
|
-
if (typeof str !== "string" || str.length === 0) {
|
|
137
|
-
return 0;
|
|
138
|
-
}
|
|
139
|
-
str = stripAnsi(str);
|
|
140
|
-
let width = 0;
|
|
141
|
-
for (let i = 0;i < str.length; i++) {
|
|
142
|
-
const code = str.codePointAt(i);
|
|
143
|
-
if (code <= 31 || code >= 127 && code <= 159) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (code >= 768 && code <= 879) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (code > 65535) {
|
|
150
|
-
i++;
|
|
151
|
-
}
|
|
152
|
-
width += isFullwidthCodePoint(code) ? 2 : 1;
|
|
153
|
-
}
|
|
154
|
-
return width;
|
|
155
|
-
};
|
|
156
|
-
var say = function(text, wrap) {
|
|
157
|
-
var delimiters = {
|
|
158
|
-
first: ["/", "\\"],
|
|
159
|
-
middle: ["|", "|"],
|
|
160
|
-
last: ["\\", "/"],
|
|
161
|
-
only: ["<", ">"]
|
|
162
|
-
};
|
|
163
|
-
return format(text, wrap, delimiters);
|
|
164
|
-
};
|
|
165
|
-
var think = function(text, wrap) {
|
|
166
|
-
var delimiters = {
|
|
167
|
-
first: ["(", ")"],
|
|
168
|
-
middle: ["(", ")"],
|
|
169
|
-
last: ["(", ")"],
|
|
170
|
-
only: ["(", ")"]
|
|
171
|
-
};
|
|
172
|
-
return format(text, wrap, delimiters);
|
|
173
|
-
};
|
|
174
|
-
function format(text, wrap, delimiters) {
|
|
175
|
-
var lines = split(text, wrap);
|
|
176
|
-
var maxLength = max(lines);
|
|
177
|
-
var balloon;
|
|
178
|
-
if (lines.length === 1) {
|
|
179
|
-
balloon = [
|
|
180
|
-
" " + top(maxLength),
|
|
181
|
-
delimiters.only[0] + " " + lines[0] + " " + delimiters.only[1],
|
|
182
|
-
" " + bottom(maxLength)
|
|
183
|
-
];
|
|
184
|
-
} else {
|
|
185
|
-
balloon = [" " + top(maxLength)];
|
|
186
|
-
for (var i = 0, len = lines.length;i < len; i += 1) {
|
|
187
|
-
var delimiter;
|
|
188
|
-
if (i === 0) {
|
|
189
|
-
delimiter = delimiters.first;
|
|
190
|
-
} else if (i === len - 1) {
|
|
191
|
-
delimiter = delimiters.last;
|
|
192
|
-
} else {
|
|
193
|
-
delimiter = delimiters.middle;
|
|
194
|
-
}
|
|
195
|
-
balloon.push(delimiter[0] + " " + pad(lines[i], maxLength) + " " + delimiter[1]);
|
|
196
|
-
}
|
|
197
|
-
balloon.push(" " + bottom(maxLength));
|
|
198
|
-
}
|
|
199
|
-
return balloon.join(`
|
|
200
|
-
`);
|
|
201
|
-
}
|
|
202
|
-
function split(text, wrap) {
|
|
203
|
-
text = text.replace(/\r\n?|[\n\u2028\u2029]/g, `
|
|
204
|
-
`).replace(/^\uFEFF/, "").replace(/\t/g, " ");
|
|
205
|
-
var lines = [];
|
|
206
|
-
if (!wrap) {
|
|
207
|
-
lines = text.split(`
|
|
208
|
-
`);
|
|
209
|
-
} else {
|
|
210
|
-
var start = 0;
|
|
211
|
-
while (start < text.length) {
|
|
212
|
-
var nextNewLine = text.indexOf(`
|
|
213
|
-
`, start);
|
|
214
|
-
var wrapAt = Math.min(start + wrap, nextNewLine === -1 ? text.length : nextNewLine);
|
|
215
|
-
lines.push(text.substring(start, wrapAt));
|
|
216
|
-
start = wrapAt;
|
|
217
|
-
if (text.charAt(start) === `
|
|
218
|
-
`) {
|
|
219
|
-
start += 1;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return lines;
|
|
224
|
-
}
|
|
225
|
-
function max(lines) {
|
|
226
|
-
var max2 = 0;
|
|
227
|
-
for (var i = 0, len = lines.length;i < len; i += 1) {
|
|
228
|
-
if (stringWidth(lines[i]) > max2) {
|
|
229
|
-
max2 = stringWidth(lines[i]);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return max2;
|
|
233
|
-
}
|
|
234
|
-
function pad(text, length) {
|
|
235
|
-
return text + new Array(length - stringWidth(text) + 1).join(" ");
|
|
236
|
-
}
|
|
237
|
-
function top(length) {
|
|
238
|
-
return new Array(length + 3).join("_");
|
|
239
|
-
}
|
|
240
|
-
function bottom(length) {
|
|
241
|
-
return new Array(length + 3).join("-");
|
|
242
|
-
}
|
|
243
|
-
var balloon = {
|
|
244
|
-
say,
|
|
245
|
-
think
|
|
246
|
-
};
|
|
247
|
-
var replacer = function(cow, variables) {
|
|
248
|
-
var eyes = escapeRe(variables.eyes);
|
|
249
|
-
var eyeL = eyes.charAt(0);
|
|
250
|
-
var eyeR = eyes.charAt(1);
|
|
251
|
-
var tongue = escapeRe(variables.tongue);
|
|
252
|
-
if (cow.indexOf("$the_cow") !== -1) {
|
|
253
|
-
cow = extractTheCow(cow);
|
|
254
|
-
}
|
|
255
|
-
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);
|
|
256
|
-
};
|
|
257
|
-
function escapeRe(s) {
|
|
258
|
-
if (s && s.replace) {
|
|
259
|
-
return s.replace(/\$/g, "$$$$");
|
|
260
|
-
}
|
|
261
|
-
return s;
|
|
262
|
-
}
|
|
263
|
-
function extractTheCow(cow) {
|
|
264
|
-
cow = cow.replace(/\r\n?|[\n\u2028\u2029]/g, `
|
|
265
|
-
`).replace(/^\uFEFF/, "");
|
|
266
|
-
var match = /\$the_cow\s*=\s*<<"*EOC"*;*\n([\s\S]+)\nEOC\n/.exec(cow);
|
|
267
|
-
if (!match) {
|
|
268
|
-
console.error(`Cannot parse cow file
|
|
269
|
-
`, cow);
|
|
270
|
-
return cow;
|
|
271
|
-
} else {
|
|
272
|
-
return match[1].replace(/\\{2}/g, "\\").replace(/\\@/g, "@").replace(/\\\$/g, "$");
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
var modes = {
|
|
276
|
-
b: {
|
|
277
|
-
eyes: "==",
|
|
278
|
-
tongue: " "
|
|
279
|
-
},
|
|
280
|
-
d: {
|
|
281
|
-
eyes: "xx",
|
|
282
|
-
tongue: "U "
|
|
283
|
-
},
|
|
284
|
-
g: {
|
|
285
|
-
eyes: "$$",
|
|
286
|
-
tongue: " "
|
|
287
|
-
},
|
|
288
|
-
p: {
|
|
289
|
-
eyes: "@@",
|
|
290
|
-
tongue: " "
|
|
291
|
-
},
|
|
292
|
-
s: {
|
|
293
|
-
eyes: "**",
|
|
294
|
-
tongue: "U "
|
|
295
|
-
},
|
|
296
|
-
t: {
|
|
297
|
-
eyes: "--",
|
|
298
|
-
tongue: " "
|
|
299
|
-
},
|
|
300
|
-
w: {
|
|
301
|
-
eyes: "OO",
|
|
302
|
-
tongue: " "
|
|
303
|
-
},
|
|
304
|
-
y: {
|
|
305
|
-
eyes: "..",
|
|
306
|
-
tongue: " "
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
var faces = function(options) {
|
|
310
|
-
for (var mode in modes) {
|
|
311
|
-
if (options[mode] === true) {
|
|
312
|
-
return modes[mode];
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return {
|
|
316
|
-
eyes: options.e || "oo",
|
|
317
|
-
tongue: options.T || " "
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
var DEFAULT_COW = `$the_cow = <<"EOC";
|
|
321
|
-
$thoughts ^__^
|
|
322
|
-
$thoughts ($eyes)\\\\_______
|
|
323
|
-
(__)\\\\ )\\\\/\\\\
|
|
324
|
-
$tongue ||----w |
|
|
325
|
-
|| ||
|
|
326
|
-
EOC
|
|
327
|
-
`;
|
|
328
|
-
function convertToCliOptions(browserOptions) {
|
|
329
|
-
const cliOptions = {
|
|
330
|
-
e: browserOptions.eyes || "oo",
|
|
331
|
-
T: browserOptions.tongue || " ",
|
|
332
|
-
n: browserOptions.wrap,
|
|
333
|
-
W: browserOptions.wrapLength || 40,
|
|
334
|
-
text: browserOptions.text || "",
|
|
335
|
-
_: browserOptions.text || [],
|
|
336
|
-
f: browserOptions.cow
|
|
337
|
-
};
|
|
338
|
-
if (browserOptions.mode) {
|
|
339
|
-
cliOptions[browserOptions.mode] = true;
|
|
340
|
-
}
|
|
341
|
-
return cliOptions;
|
|
342
|
-
}
|
|
343
|
-
function doIt(options, sayAloud) {
|
|
344
|
-
const cow = options.f || DEFAULT_COW;
|
|
345
|
-
const face = faces(options);
|
|
346
|
-
face.thoughts = sayAloud ? "\\" : "o";
|
|
347
|
-
const action = sayAloud ? "say" : "think";
|
|
348
|
-
return balloon[action](options.text || options._.join(" "), options.n ? null : options.W) + `
|
|
349
|
-
` + replacer(cow, face);
|
|
350
|
-
}
|
|
351
|
-
function say$1(browserOptions) {
|
|
352
|
-
return doIt(convertToCliOptions(browserOptions), true);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// src/service/DefaultDemoService.ts
|
|
356
|
-
class DefaultDemoService {
|
|
357
|
-
cowsay(name) {
|
|
358
|
-
return say$1({ text: `Hello, ${name}!` });
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// src/service/DemoServiceProvider.ts
|
|
363
|
-
class DemoServiceProvider {
|
|
364
|
-
serviceId = DEMO_SERVICE_ID;
|
|
365
|
-
servicePriority = 10;
|
|
366
|
-
async getServiceInfo(_cliConfig) {
|
|
367
|
-
return { service: new DefaultDemoService, commands: [] };
|
|
368
|
-
}
|
|
369
|
-
async initService(_context) {}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// src/factory/DemoServiceProviderFactory.ts
|
|
373
|
-
class DemoServiceProviderFactory {
|
|
374
|
-
getServiceProviders() {
|
|
375
|
-
return [new DemoServiceProvider];
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// src/plugin.ts
|
|
380
|
-
var plugin_default = createCLIPlugin({
|
|
381
|
-
commandFactory: new DemoCommandFactory,
|
|
382
|
-
serviceProviderFactory: new DemoServiceProviderFactory
|
|
383
|
-
});
|
|
384
|
-
export {
|
|
385
|
-
plugin_default as default
|
|
386
|
-
};
|
|
1
|
+
export { default } from "./src/plugin.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SubCommand } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import type { SubCommand } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
declare const helloCommand: SubCommand;
|
|
3
3
|
export default helloCommand;
|
|
4
4
|
//# sourceMappingURL=HelloCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelloCommand.d.ts","sourceRoot":"","sources":["../../../src/command/HelloCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,
|
|
1
|
+
{"version":3,"file":"HelloCommand.d.ts","sourceRoot":"","sources":["../../../src/command/HelloCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,gDAAgD,CAAC;AAQxD,QAAA,MAAM,YAAY,EAAE,UAqBnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ArgumentValueTypeName, PRINTER_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
|
+
import { DEMO_SERVICE_ID } from "../service/DemoService.js";
|
|
3
|
+
const helloCommand = {
|
|
4
|
+
name: "hello",
|
|
5
|
+
description: "Greet someone using the demo service",
|
|
6
|
+
helpTopic: "Hello",
|
|
7
|
+
enableConfiguration: false,
|
|
8
|
+
options: [],
|
|
9
|
+
positionals: [
|
|
10
|
+
{
|
|
11
|
+
name: "name",
|
|
12
|
+
description: "Name to greet",
|
|
13
|
+
type: ArgumentValueTypeName.STRING,
|
|
14
|
+
isVarargOptional: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
execute: async (context, argumentValues) => {
|
|
18
|
+
const demoService = context.getServiceById(DEMO_SERVICE_ID);
|
|
19
|
+
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
20
|
+
const name = argumentValues["name"] ?? "World";
|
|
21
|
+
const greeting = demoService.cowsay(name);
|
|
22
|
+
await printerService?.print(`${greeting}\n`);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export default helloCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommandFactory } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import type { CommandFactory } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
export default class DemoCommandFactory implements CommandFactory {
|
|
3
|
-
getCommands(): import("@flowscripter/dynamic-cli-framework").SubCommand[];
|
|
3
|
+
getCommands(): import("@flowscripter/dynamic-cli-framework/cli-plugin").SubCommand[];
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=DemoCommandFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DemoCommandFactory.d.ts","sourceRoot":"","sources":["../../../src/factory/DemoCommandFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"DemoCommandFactory.d.ts","sourceRoot":"","sources":["../../../src/factory/DemoCommandFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAGrF,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,cAAc;IAC/D,WAAW;CAGZ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServiceProviderFactory } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import type { ServiceProviderFactory } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
import DemoServiceProvider from "../service/DemoServiceProvider.ts";
|
|
3
3
|
export default class DemoServiceProviderFactory implements ServiceProviderFactory {
|
|
4
4
|
getServiceProviders(): DemoServiceProvider[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DemoServiceProviderFactory.d.ts","sourceRoot":"","sources":["../../../src/factory/DemoServiceProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"DemoServiceProviderFactory.d.ts","sourceRoot":"","sources":["../../../src/factory/DemoServiceProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,mBAAmB,MAAM,mCAAmC,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,0BAA2B,YAAW,sBAAsB;IAC/E,mBAAmB;CAGpB"}
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCLIPlugin } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
|
+
import DemoCommandFactory from "./factory/DemoCommandFactory.js";
|
|
3
|
+
import DemoServiceProviderFactory from "./factory/DemoServiceProviderFactory.js";
|
|
4
|
+
export default createCLIPlugin({
|
|
5
|
+
commandFactory: new DemoCommandFactory(),
|
|
6
|
+
serviceProviderFactory: new DemoServiceProviderFactory(),
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEMO_SERVICE_ID = "DEMO_SERVICE";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServiceProvider, ServiceInfo, CLIConfig, Context } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import type { ServiceProvider, ServiceInfo, CLIConfig, Context } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
export default class DemoServiceProvider implements ServiceProvider {
|
|
3
3
|
readonly serviceId = "DEMO_SERVICE";
|
|
4
4
|
readonly servicePriority = 10;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DemoServiceProvider.d.ts","sourceRoot":"","sources":["../../../src/service/DemoServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,SAAS,EACT,OAAO,EACR,MAAM,
|
|
1
|
+
{"version":3,"file":"DemoServiceProvider.d.ts","sourceRoot":"","sources":["../../../src/service/DemoServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,SAAS,EACT,OAAO,EACR,MAAM,gDAAgD,CAAC;AAIxD,MAAM,CAAC,OAAO,OAAO,mBAAoB,YAAW,eAAe;IACjE,QAAQ,CAAC,SAAS,kBAAmB;IACrC,QAAQ,CAAC,eAAe,MAAM;IAExB,cAAc,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAI3D,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CACpD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DEMO_SERVICE_ID } from "./DemoService.js";
|
|
2
|
+
import DefaultDemoService from "./DefaultDemoService.js";
|
|
3
|
+
export default class DemoServiceProvider {
|
|
4
|
+
serviceId = DEMO_SERVICE_ID;
|
|
5
|
+
servicePriority = 10;
|
|
6
|
+
async getServiceInfo(_cliConfig) {
|
|
7
|
+
return { service: new DefaultDemoService(), commands: [] };
|
|
8
|
+
}
|
|
9
|
+
async initService(_context) { }
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/example-cli-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Example CLI plugin for the https://github.com/flowscripter/dynamic-cli-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "
|
|
42
|
+
"build": "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.7.
|
|
48
|
+
"@flowscripter/dynamic-cli-framework": "1.7.3",
|
|
49
49
|
"@types/bun": "^1.3.14",
|
|
50
50
|
"oxfmt": "0.56.0",
|
|
51
51
|
"oxlint": "1.71.0"
|
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
Context,
|
|
4
4
|
ArgumentValues,
|
|
5
5
|
PrinterService,
|
|
6
|
-
} from "@flowscripter/dynamic-cli-framework/plugin";
|
|
6
|
+
} from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
7
7
|
import {
|
|
8
8
|
ArgumentValueTypeName,
|
|
9
9
|
PRINTER_SERVICE_ID,
|
|
10
|
-
} from "@flowscripter/dynamic-cli-framework/plugin";
|
|
10
|
+
} from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
11
11
|
import { DEMO_SERVICE_ID } from "../service/DemoService.ts";
|
|
12
12
|
import type DemoService from "../service/DemoService.ts";
|
|
13
13
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommandFactory } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import type { CommandFactory } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
import helloCommand from "../command/HelloCommand.ts";
|
|
3
3
|
|
|
4
4
|
export default class DemoCommandFactory implements CommandFactory {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServiceProviderFactory } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import type { ServiceProviderFactory } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
import DemoServiceProvider from "../service/DemoServiceProvider.ts";
|
|
3
3
|
|
|
4
4
|
export default class DemoServiceProviderFactory implements ServiceProviderFactory {
|
package/src/plugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createCLIPlugin } from "@flowscripter/dynamic-cli-framework/plugin";
|
|
1
|
+
import { createCLIPlugin } from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
2
2
|
import DemoCommandFactory from "./factory/DemoCommandFactory.ts";
|
|
3
3
|
import DemoServiceProviderFactory from "./factory/DemoServiceProviderFactory.ts";
|
|
4
4
|
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
ServiceInfo,
|
|
4
4
|
CLIConfig,
|
|
5
5
|
Context,
|
|
6
|
-
} from "@flowscripter/dynamic-cli-framework/plugin";
|
|
6
|
+
} from "@flowscripter/dynamic-cli-framework/cli-plugin";
|
|
7
7
|
import { DEMO_SERVICE_ID } from "./DemoService.ts";
|
|
8
8
|
import DefaultDemoService from "./DefaultDemoService.ts";
|
|
9
9
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.test.d.ts","sourceRoot":"","sources":["../../tests/plugin.test.ts"],"names":[],"mappings":""}
|