@4399ywkf/core 4.0.84 → 5.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.
Files changed (81) hide show
  1. package/dist/cli/index.js +2180 -0
  2. package/dist/cli/index.js.map +1 -0
  3. package/dist/config/index.d.ts +37 -0
  4. package/dist/config/index.js +143 -0
  5. package/dist/config/index.js.map +1 -0
  6. package/dist/index.d.ts +496 -6
  7. package/dist/index.js +3671 -49
  8. package/dist/index.js.map +1 -0
  9. package/dist/plugin/index.d.ts +110 -0
  10. package/dist/plugin/index.js +277 -0
  11. package/dist/plugin/index.js.map +1 -0
  12. package/dist/router/index.d.ts +126 -0
  13. package/dist/router/index.js +390 -0
  14. package/dist/router/index.js.map +1 -0
  15. package/dist/rspack/index.d.ts +29 -0
  16. package/dist/rspack/index.js +1574 -0
  17. package/dist/rspack/index.js.map +1 -0
  18. package/dist/runtime/index.d.ts +120 -0
  19. package/dist/runtime/index.js +406 -0
  20. package/dist/runtime/index.js.map +1 -0
  21. package/dist/schema-BuqmN_ra.d.ts +390 -0
  22. package/dist/types-BZV_2QtD.d.ts +97 -0
  23. package/package.json +88 -37
  24. package/README.md +0 -3
  25. package/compiled/dotenv/LICENSE +0 -23
  26. package/compiled/dotenv/index.js +0 -1
  27. package/compiled/dotenv/lib/main.d.ts +0 -73
  28. package/compiled/dotenv/package.json +0 -1
  29. package/compiled/dotenv/types/index.d.ts +0 -59
  30. package/compiled/dotenv-expand/LICENSE +0 -24
  31. package/compiled/dotenv-expand/index.js +0 -1
  32. package/compiled/dotenv-expand/lib/main.d.ts +0 -29
  33. package/compiled/dotenv-expand/package.json +0 -1
  34. package/compiled/just-diff/LICENSE +0 -21
  35. package/compiled/just-diff/index.d.ts +0 -20
  36. package/compiled/just-diff/index.js +0 -1
  37. package/compiled/just-diff/package.json +0 -1
  38. package/dist/config/config.d.ts +0 -62
  39. package/dist/config/config.js +0 -240
  40. package/dist/config/utils.d.ts +0 -8
  41. package/dist/config/utils.js +0 -40
  42. package/dist/constants.d.ts +0 -9
  43. package/dist/constants.js +0 -45
  44. package/dist/route/defineRoutes.d.ts +0 -1
  45. package/dist/route/defineRoutes.js +0 -61
  46. package/dist/route/route.d.ts +0 -3
  47. package/dist/route/route.js +0 -27
  48. package/dist/route/routeUtils.d.ts +0 -8
  49. package/dist/route/routeUtils.js +0 -46
  50. package/dist/route/routesConfig.d.ts +0 -6
  51. package/dist/route/routesConfig.js +0 -125
  52. package/dist/route/routesConvention.d.ts +0 -5
  53. package/dist/route/routesConvention.js +0 -88
  54. package/dist/route/utils.d.ts +0 -8
  55. package/dist/route/utils.js +0 -59
  56. package/dist/service/command.d.ts +0 -30
  57. package/dist/service/command.js +0 -39
  58. package/dist/service/env.d.ts +0 -4
  59. package/dist/service/env.js +0 -47
  60. package/dist/service/generatePlugin.d.ts +0 -4
  61. package/dist/service/generatePlugin.js +0 -102
  62. package/dist/service/generator.d.ts +0 -71
  63. package/dist/service/generator.js +0 -40
  64. package/dist/service/hook.d.ts +0 -16
  65. package/dist/service/hook.js +0 -52
  66. package/dist/service/path.d.ts +0 -15
  67. package/dist/service/path.js +0 -55
  68. package/dist/service/plugin.d.ts +0 -61
  69. package/dist/service/plugin.js +0 -174
  70. package/dist/service/pluginAPI.d.ts +0 -49
  71. package/dist/service/pluginAPI.js +0 -233
  72. package/dist/service/service.d.ts +0 -147
  73. package/dist/service/service.js +0 -544
  74. package/dist/service/servicePlugin.d.ts +0 -3
  75. package/dist/service/servicePlugin.js +0 -37
  76. package/dist/service/telemetry.d.ts +0 -32
  77. package/dist/service/telemetry.js +0 -127
  78. package/dist/service/utils.d.ts +0 -2
  79. package/dist/service/utils.js +0 -36
  80. package/dist/types.d.ts +0 -116
  81. package/dist/types.js +0 -77
@@ -1,544 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/service/service.ts
30
- var service_exports = {};
31
- __export(service_exports, {
32
- Service: () => Service
33
- });
34
- module.exports = __toCommonJS(service_exports);
35
- var import_tapable = require("@4399ywkf/bundler-utils/compiled/tapable");
36
- var import_utils = require("@4399ywkf/utils");
37
- var import_assert = __toESM(require("assert"));
38
- var import_fs = require("fs");
39
- var import_path = require("path");
40
- var import_config = require("../config/config");
41
- var import_constants = require("../constants");
42
- var import_types = require("../types");
43
- var import_env = require("./env");
44
- var import_path2 = require("./path");
45
- var import_plugin = require("./plugin");
46
- var import_pluginAPI = require("./pluginAPI");
47
- var import_telemetry = require("./telemetry");
48
- var Service = class {
49
- constructor(opts) {
50
- this.appData = {};
51
- this.args = { _: [], $0: "" };
52
- this.commands = {};
53
- this.generators = {};
54
- this.config = {};
55
- this.configSchemas = {};
56
- this.configDefaults = {};
57
- this.configOnChanges = {};
58
- this.hooks = {};
59
- this.name = "";
60
- this.paths = {};
61
- // preset is plugin with different type
62
- this.plugins = {};
63
- this.keyToPluginMap = {};
64
- this.pluginMethods = {};
65
- this.skipPluginIds = /* @__PURE__ */ new Set();
66
- this.stage = import_types.ServiceStage.uninitialized;
67
- this.userConfig = {};
68
- this.configManager = null;
69
- this.pkg = {};
70
- this.pkgPath = "";
71
- this.telemetry = new import_telemetry.Telemetry();
72
- this.cwd = opts.cwd;
73
- this.env = opts.env;
74
- this.opts = opts;
75
- (0, import_assert.default)((0, import_fs.existsSync)(this.cwd), `Invalid cwd ${this.cwd}, it's not found.`);
76
- }
77
- applyPlugins(opts) {
78
- const hooks = this.hooks[opts.key] || [];
79
- let type = opts.type;
80
- if (!type) {
81
- if (opts.key.startsWith("on")) {
82
- type = import_types.ApplyPluginsType.event;
83
- } else if (opts.key.startsWith("modify")) {
84
- type = import_types.ApplyPluginsType.modify;
85
- } else if (opts.key.startsWith("add")) {
86
- type = import_types.ApplyPluginsType.add;
87
- } else {
88
- throw new Error(
89
- `Invalid applyPlugins arguments, type must be supplied for key ${opts.key}.`
90
- );
91
- }
92
- }
93
- switch (type) {
94
- case import_types.ApplyPluginsType.add:
95
- (0, import_assert.default)(
96
- !("initialValue" in opts) || Array.isArray(opts.initialValue),
97
- `applyPlugins failed, opts.initialValue must be Array if opts.type is add.`
98
- );
99
- const tAdd = new import_tapable.AsyncSeriesWaterfallHook(["memo"]);
100
- for (const hook of hooks) {
101
- if (!this.isPluginEnable(hook))
102
- continue;
103
- tAdd.tapPromise(
104
- {
105
- name: hook.plugin.key,
106
- stage: hook.stage || 0,
107
- before: hook.before
108
- },
109
- async (memo) => {
110
- var _a, _b;
111
- const dateStart = /* @__PURE__ */ new Date();
112
- const items = await hook.fn(opts.args);
113
- (_a = hook.plugin.time.hooks)[_b = opts.key] || (_a[_b] = []);
114
- hook.plugin.time.hooks[opts.key].push(
115
- (/* @__PURE__ */ new Date()).getTime() - dateStart.getTime()
116
- );
117
- return memo.concat(items);
118
- }
119
- );
120
- }
121
- return tAdd.promise(opts.initialValue || []);
122
- case import_types.ApplyPluginsType.modify:
123
- const tModify = new import_tapable.AsyncSeriesWaterfallHook(["memo"]);
124
- for (const hook of hooks) {
125
- if (!this.isPluginEnable(hook))
126
- continue;
127
- tModify.tapPromise(
128
- {
129
- name: hook.plugin.key,
130
- stage: hook.stage || 0,
131
- before: hook.before
132
- },
133
- async (memo) => {
134
- var _a, _b;
135
- const dateStart = /* @__PURE__ */ new Date();
136
- const ret = await hook.fn(memo, opts.args);
137
- (_a = hook.plugin.time.hooks)[_b = opts.key] || (_a[_b] = []);
138
- hook.plugin.time.hooks[opts.key].push(
139
- (/* @__PURE__ */ new Date()).getTime() - dateStart.getTime()
140
- );
141
- return ret;
142
- }
143
- );
144
- }
145
- return tModify.promise(opts.initialValue);
146
- case import_types.ApplyPluginsType.event:
147
- if (opts.sync) {
148
- const tEvent2 = new import_tapable.SyncWaterfallHook(["_"]);
149
- hooks.forEach((hook) => {
150
- if (this.isPluginEnable(hook)) {
151
- tEvent2.tap(
152
- {
153
- name: hook.plugin.key,
154
- stage: hook.stage || 0,
155
- before: hook.before
156
- },
157
- () => {
158
- var _a, _b;
159
- const dateStart = /* @__PURE__ */ new Date();
160
- hook.fn(opts.args);
161
- (_a = hook.plugin.time.hooks)[_b = opts.key] || (_a[_b] = []);
162
- hook.plugin.time.hooks[opts.key].push(
163
- (/* @__PURE__ */ new Date()).getTime() - dateStart.getTime()
164
- );
165
- }
166
- );
167
- }
168
- });
169
- return tEvent2.call(1);
170
- }
171
- const tEvent = new import_tapable.AsyncSeriesWaterfallHook(["_"]);
172
- for (const hook of hooks) {
173
- if (!this.isPluginEnable(hook))
174
- continue;
175
- tEvent.tapPromise(
176
- {
177
- name: hook.plugin.key,
178
- stage: hook.stage || 0,
179
- before: hook.before
180
- },
181
- async () => {
182
- var _a, _b;
183
- const dateStart = /* @__PURE__ */ new Date();
184
- await hook.fn(opts.args);
185
- (_a = hook.plugin.time.hooks)[_b = opts.key] || (_a[_b] = []);
186
- hook.plugin.time.hooks[opts.key].push(
187
- (/* @__PURE__ */ new Date()).getTime() - dateStart.getTime()
188
- );
189
- }
190
- );
191
- }
192
- return tEvent.promise(1);
193
- default:
194
- throw new Error(
195
- `applyPlugins failed, type is not defined or is not matched, got ${opts.type}.`
196
- );
197
- }
198
- }
199
- async run(opts) {
200
- const { name, args = {} } = opts;
201
- args._ = args._ || [];
202
- if (args._[0] === name)
203
- args._.shift();
204
- this.args = args;
205
- this.name = name;
206
- this.stage = import_types.ServiceStage.init;
207
- (0, import_env.loadEnv)({ cwd: this.cwd, envFile: ".env" });
208
- let pkg = {};
209
- let pkgPath = "";
210
- try {
211
- pkg = require((0, import_path.join)(this.cwd, "package.json"));
212
- pkgPath = (0, import_path.join)(this.cwd, "package.json");
213
- } catch (_e) {
214
- if (this.cwd !== process.cwd()) {
215
- try {
216
- pkg = require((0, import_path.join)(process.cwd(), "package.json"));
217
- pkgPath = (0, import_path.join)(process.cwd(), "package.json");
218
- } catch (_e2) {
219
- }
220
- }
221
- }
222
- this.pkg = pkg;
223
- this.pkgPath = pkgPath || (0, import_path.join)(this.cwd, "package.json");
224
- const prefix = this.opts.frameworkName || import_constants.DEFAULT_FRAMEWORK_NAME;
225
- const specifiedEnv = process.env[`${prefix}_ENV`.toUpperCase()];
226
- const configManager = new import_config.Config({
227
- cwd: this.cwd,
228
- env: this.env,
229
- defaultConfigFiles: this.opts.defaultConfigFiles,
230
- specifiedEnv
231
- });
232
- this.configManager = configManager;
233
- this.userConfig = configManager.getUserConfig().config;
234
- this.paths = await this.getPaths();
235
- const { plugins, presets } = import_plugin.Plugin.getPluginsAndPresets({
236
- cwd: this.cwd,
237
- pkg,
238
- plugins: [require.resolve("./generatePlugin")].concat(
239
- this.opts.plugins || []
240
- ),
241
- presets: [require.resolve("./servicePlugin")].concat(
242
- this.opts.presets || []
243
- ),
244
- userConfig: this.userConfig,
245
- prefix
246
- });
247
- this.stage = import_types.ServiceStage.initPresets;
248
- const presetPlugins = [];
249
- while (presets.length) {
250
- await this.initPreset({
251
- preset: presets.shift(),
252
- presets,
253
- plugins: presetPlugins
254
- });
255
- }
256
- plugins.unshift(...presetPlugins);
257
- this.stage = import_types.ServiceStage.initPlugins;
258
- while (plugins.length) {
259
- await this.initPlugin({ plugin: plugins.shift(), plugins });
260
- }
261
- const command = this.commands[name];
262
- if (!command) {
263
- this.commandGuessHelper(Object.keys(this.commands), name);
264
- throw Error(`Invalid command ${import_utils.chalk.red(name)}, it's not registered.`);
265
- }
266
- for (const id of Object.keys(this.plugins)) {
267
- const { config, key } = this.plugins[id];
268
- if (config.schema)
269
- this.configSchemas[key] = config.schema;
270
- if (config.default !== void 0) {
271
- this.configDefaults[key] = config.default;
272
- }
273
- this.configOnChanges[key] = config.onChange || import_types.ConfigChangeType.reload;
274
- }
275
- this.stage = import_types.ServiceStage.resolveConfig;
276
- const { defaultConfig } = await this.resolveConfig();
277
- if (this.config.outputPath) {
278
- this.paths.absOutputPath = (0, import_path.isAbsolute)(this.config.outputPath) ? this.config.outputPath : (0, import_path.join)(this.cwd, this.config.outputPath);
279
- }
280
- this.paths = await this.applyPlugins({
281
- key: "modifyPaths",
282
- initialValue: this.paths
283
- });
284
- const storage = await this.applyPlugins({
285
- key: "modifyTelemetryStorage",
286
- initialValue: import_telemetry.noopStorage
287
- });
288
- this.telemetry.useStorage(storage);
289
- this.stage = import_types.ServiceStage.collectAppData;
290
- this.appData = await this.applyPlugins({
291
- key: "modifyAppData",
292
- initialValue: {
293
- // base
294
- cwd: this.cwd,
295
- pkg,
296
- pkgPath,
297
- plugins: this.plugins,
298
- presets,
299
- name,
300
- args,
301
- // config
302
- userConfig: this.userConfig,
303
- mainConfigFile: configManager.mainConfigFile,
304
- config: this.config,
305
- defaultConfig
306
- // TODO
307
- // moduleGraph,
308
- // routes,
309
- // npmClient,
310
- // nodeVersion,
311
- // gitInfo,
312
- // gitBranch,
313
- // debugger info,
314
- // devPort,
315
- // devHost,
316
- // env
317
- }
318
- });
319
- this.stage = import_types.ServiceStage.onCheck;
320
- await this.applyPlugins({
321
- key: "onCheck"
322
- });
323
- this.stage = import_types.ServiceStage.onStart;
324
- await this.applyPlugins({
325
- key: "onStart"
326
- });
327
- this.stage = import_types.ServiceStage.runCommand;
328
- let ret = await command.fn({ args });
329
- this._profilePlugins();
330
- return ret;
331
- }
332
- async getPaths() {
333
- const paths = (0, import_path2.getPaths)({
334
- cwd: this.cwd,
335
- env: this.env,
336
- prefix: this.opts.frameworkName || import_constants.DEFAULT_FRAMEWORK_NAME
337
- });
338
- return paths;
339
- }
340
- async resolveConfig() {
341
- (0, import_assert.default)(
342
- this.stage > import_types.ServiceStage.init,
343
- `Can't generate final config before init stage`
344
- );
345
- const resolveMode = this.commands[this.name].configResolveMode;
346
- const config = await this.applyPlugins({
347
- key: "modifyConfig",
348
- // why clone deep?
349
- // user may change the config in modifyConfig
350
- // e.g. memo.alias = xxx
351
- initialValue: import_utils.lodash.cloneDeep(
352
- resolveMode === "strict" ? this.configManager.getConfig({
353
- schemas: this.configSchemas
354
- }).config : this.configManager.getUserConfig().config
355
- ),
356
- args: { paths: this.paths }
357
- });
358
- const defaultConfig = await this.applyPlugins({
359
- key: "modifyDefaultConfig",
360
- // 避免 modifyDefaultConfig 时修改 this.configDefaults
361
- initialValue: import_utils.lodash.cloneDeep(this.configDefaults)
362
- });
363
- this.config = import_utils.lodash.merge(defaultConfig, config);
364
- return { config, defaultConfig };
365
- }
366
- _profilePlugins() {
367
- if (this.args.profilePlugins) {
368
- console.log();
369
- Object.keys(this.plugins).map((id) => {
370
- const plugin = this.plugins[id];
371
- const total = totalTime(plugin);
372
- return {
373
- id,
374
- total,
375
- register: plugin.time.register || 0,
376
- hooks: plugin.time.hooks
377
- };
378
- }).filter((time) => {
379
- return time.total > (this.args.profilePluginsLimit ?? 10);
380
- }).sort((a, b) => b.total > a.total ? 1 : -1).forEach((time) => {
381
- console.log(import_utils.chalk.green("plugin"), time.id, time.total);
382
- if (this.args.profilePluginsVerbose) {
383
- console.log(" ", import_utils.chalk.green("register"), time.register);
384
- console.log(
385
- " ",
386
- import_utils.chalk.green("hooks"),
387
- JSON.stringify(sortHooks(time.hooks))
388
- );
389
- }
390
- });
391
- }
392
- function sortHooks(hooks) {
393
- const ret = {};
394
- Object.keys(hooks).sort((a, b) => {
395
- return add(hooks[b]) - add(hooks[a]);
396
- }).forEach((key) => {
397
- ret[key] = hooks[key];
398
- });
399
- return ret;
400
- }
401
- function totalTime(plugin) {
402
- const time = plugin.time;
403
- return (time.register || 0) + Object.values(time.hooks).reduce((a, b) => a + add(b), 0);
404
- }
405
- function add(nums) {
406
- return nums.reduce((a, b) => a + b, 0);
407
- }
408
- }
409
- async initPreset(opts) {
410
- const { presets, plugins } = await this.initPlugin({
411
- plugin: opts.preset,
412
- presets: opts.presets,
413
- plugins: opts.plugins
414
- });
415
- opts.presets.unshift(...presets || []);
416
- opts.plugins.push(...plugins || []);
417
- }
418
- async initPlugin(opts) {
419
- var _a, _b;
420
- (0, import_assert.default)(
421
- !this.plugins[opts.plugin.id],
422
- `${opts.plugin.type} ${opts.plugin.id} is already registered by ${(_a = this.plugins[opts.plugin.id]) == null ? void 0 : _a.path}, ${opts.plugin.type} from ${opts.plugin.path} register failed.`
423
- );
424
- this.plugins[opts.plugin.id] = opts.plugin;
425
- const pluginAPI = new import_pluginAPI.PluginAPI({
426
- plugin: opts.plugin,
427
- service: this
428
- });
429
- pluginAPI.registerPresets = pluginAPI.registerPresets.bind(
430
- pluginAPI,
431
- opts.presets || []
432
- );
433
- pluginAPI.registerPlugins = pluginAPI.registerPlugins.bind(
434
- pluginAPI,
435
- opts.plugins
436
- );
437
- const proxyPluginAPI = import_pluginAPI.PluginAPI.proxyPluginAPI({
438
- service: this,
439
- pluginAPI,
440
- serviceProps: [
441
- "appData",
442
- "applyPlugins",
443
- "args",
444
- "config",
445
- "cwd",
446
- "pkg",
447
- "pkgPath",
448
- "name",
449
- "paths",
450
- "userConfig",
451
- "env",
452
- "isPluginEnable"
453
- ],
454
- staticProps: {
455
- ApplyPluginsType: import_types.ApplyPluginsType,
456
- ConfigChangeType: import_types.ConfigChangeType,
457
- EnableBy: import_types.EnableBy,
458
- ServiceStage: import_types.ServiceStage,
459
- service: this
460
- }
461
- });
462
- let dateStart = /* @__PURE__ */ new Date();
463
- let ret = await opts.plugin.apply()(proxyPluginAPI);
464
- opts.plugin.time.register = (/* @__PURE__ */ new Date()).getTime() - dateStart.getTime();
465
- if (opts.plugin.type === "plugin") {
466
- (0, import_assert.default)(!ret, `plugin should return nothing`);
467
- }
468
- (0, import_assert.default)(
469
- !this.keyToPluginMap[opts.plugin.key],
470
- `key ${opts.plugin.key} is already registered by ${(_b = this.keyToPluginMap[opts.plugin.key]) == null ? void 0 : _b.path}, ${opts.plugin.type} from ${opts.plugin.path} register failed.`
471
- );
472
- this.keyToPluginMap[opts.plugin.key] = opts.plugin;
473
- if (ret == null ? void 0 : ret.presets) {
474
- ret.presets = ret.presets.map(
475
- (preset) => new import_plugin.Plugin({
476
- path: preset,
477
- type: import_types.PluginType.preset,
478
- cwd: this.cwd
479
- })
480
- );
481
- }
482
- if (ret == null ? void 0 : ret.plugins) {
483
- ret.plugins = ret.plugins.map(
484
- (plugin) => new import_plugin.Plugin({
485
- path: plugin,
486
- type: import_types.PluginType.plugin,
487
- cwd: this.cwd
488
- })
489
- );
490
- }
491
- return ret || {};
492
- }
493
- isPluginEnable(hook) {
494
- let plugin;
495
- if (hook.plugin) {
496
- plugin = hook.plugin;
497
- } else {
498
- plugin = this.keyToPluginMap[hook];
499
- if (!plugin)
500
- return false;
501
- }
502
- const { id, key, enableBy } = plugin;
503
- if (this.skipPluginIds.has(id))
504
- return false;
505
- if (this.userConfig[key] === false)
506
- return false;
507
- if (this.config[key] === false)
508
- return false;
509
- if (enableBy === import_types.EnableBy.config) {
510
- return key in this.userConfig || this.config && key in this.config;
511
- }
512
- if (typeof enableBy === "function")
513
- return enableBy({
514
- userConfig: this.userConfig,
515
- config: this.config,
516
- env: this.env
517
- });
518
- return true;
519
- }
520
- commandGuessHelper(commands, currentCmd) {
521
- const altCmds = commands.filter((cmd) => {
522
- return import_utils.fastestLevenshtein.distance(currentCmd, cmd) < currentCmd.length * 0.6 && currentCmd !== cmd;
523
- });
524
- const printHelper = altCmds.slice(0, 3).map((cmd) => {
525
- return ` - ${import_utils.chalk.green(cmd)}`;
526
- }).join("\n");
527
- if (altCmds.length) {
528
- console.log();
529
- console.log(
530
- [
531
- import_utils.chalk.cyan(
532
- altCmds.length === 1 ? "Did you mean this command ?" : "Did you mean one of these commands ?"
533
- ),
534
- printHelper
535
- ].join("\n")
536
- );
537
- console.log();
538
- }
539
- }
540
- };
541
- // Annotate the CommonJS export names for ESM import in node:
542
- 0 && (module.exports = {
543
- Service
544
- });
@@ -1,3 +0,0 @@
1
- import { PluginAPI } from './pluginAPI';
2
- declare const _default: (api: PluginAPI) => void;
3
- export default _default;
@@ -1,37 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/service/servicePlugin.ts
20
- var servicePlugin_exports = {};
21
- __export(servicePlugin_exports, {
22
- default: () => servicePlugin_default
23
- });
24
- module.exports = __toCommonJS(servicePlugin_exports);
25
- var servicePlugin_default = (api) => {
26
- [
27
- "onCheck",
28
- "onStart",
29
- "modifyAppData",
30
- "modifyConfig",
31
- "modifyDefaultConfig",
32
- "modifyPaths",
33
- "modifyTelemetryStorage"
34
- ].forEach((name) => {
35
- api.registerMethod({ name });
36
- });
37
- };
@@ -1,32 +0,0 @@
1
- type MetreEvent = {
2
- name: string;
3
- timestamp?: number;
4
- payload: any;
5
- };
6
- interface IStorage {
7
- save(e: MetreEvent): Promise<void>;
8
- }
9
- export interface IMetry {
10
- record(e: MetreEvent): void;
11
- recordAsync(e: MetreEvent): Promise<boolean>;
12
- flush(): Promise<void>;
13
- }
14
- export declare class Telemetry implements IMetry {
15
- private queuedEvents;
16
- private storage;
17
- constructor();
18
- prefixWith(prefix: string): IMetry;
19
- useStorage(s: IStorage): void;
20
- record(e: MetreEvent): void;
21
- recordAsync(e: MetreEvent): Promise<boolean>;
22
- flush(): Promise<void>;
23
- private scheduleFlush;
24
- private afterFlush;
25
- private unFinishedEvents;
26
- private addTimeStamp;
27
- }
28
- declare class NoopStorage implements IStorage {
29
- save(_e: MetreEvent): Promise<void>;
30
- }
31
- export declare const noopStorage: NoopStorage;
32
- export {};