ccjk 12.0.0 → 12.0.2
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/chunks/agent-teams.mjs +17 -18
- package/dist/chunks/agent.mjs +105 -102
- package/dist/chunks/agents.mjs +87 -77
- package/dist/chunks/api-cli.mjs +41 -27
- package/dist/chunks/api-providers.mjs +2 -4
- package/dist/chunks/api.mjs +22 -11
- package/dist/chunks/auto-bootstrap.mjs +3 -5
- package/dist/chunks/auto-init.mjs +3 -4
- package/dist/chunks/auto-updater.mjs +103 -91
- package/dist/chunks/banner.mjs +41 -42
- package/dist/chunks/boost.mjs +30 -31
- package/dist/chunks/ccjk-agents.mjs +6 -9
- package/dist/chunks/ccjk-all.mjs +703 -85
- package/dist/chunks/ccjk-config.mjs +6 -6
- package/dist/chunks/ccjk-hooks.mjs +20 -9
- package/dist/chunks/ccjk-mcp.mjs +64 -52
- package/dist/chunks/ccjk-setup.mjs +35 -25
- package/dist/chunks/ccjk-skills.mjs +51 -41
- package/dist/chunks/ccr.mjs +42 -32
- package/dist/chunks/ccu.mjs +16 -12
- package/dist/chunks/check-updates.mjs +30 -19
- package/dist/chunks/claude-code-config-manager.mjs +25 -10
- package/dist/chunks/claude-code-incremental-manager.mjs +65 -51
- package/dist/chunks/claude-config.mjs +2 -2
- package/dist/chunks/claude-wrapper.mjs +9 -6
- package/dist/chunks/cleanup-migration.mjs +1 -1
- package/dist/chunks/cli-hook.mjs +10 -3
- package/dist/chunks/cloud-sync.mjs +1 -1
- package/dist/chunks/codex-config-switch.mjs +58 -45
- package/dist/chunks/codex-provider-manager.mjs +29 -16
- package/dist/chunks/codex-uninstaller.mjs +5 -6
- package/dist/chunks/codex.mjs +89 -89
- package/dist/chunks/commands.mjs +28 -29
- package/dist/chunks/commands2.mjs +4 -3
- package/dist/chunks/commit.mjs +42 -23
- package/dist/chunks/completion.mjs +46 -47
- package/dist/chunks/config-consolidator.mjs +12 -13
- package/dist/chunks/config-switch.mjs +66 -53
- package/dist/chunks/config.mjs +10 -10
- package/dist/chunks/config2.mjs +53 -42
- package/dist/chunks/config3.mjs +107 -93
- package/dist/chunks/constants.mjs +2 -4
- package/dist/chunks/context-loader.mjs +5 -4
- package/dist/chunks/context.mjs +77 -76
- package/dist/chunks/convoy-manager.mjs +4 -4
- package/dist/chunks/dashboard.mjs +28 -29
- package/dist/chunks/doctor.mjs +68 -54
- package/dist/chunks/evolution.mjs +37 -38
- package/dist/chunks/features.mjs +103 -92
- package/dist/chunks/fs-operations.mjs +1 -1
- package/dist/chunks/health-alerts.mjs +1 -1
- package/dist/chunks/health-check.mjs +1 -1
- package/dist/chunks/help.mjs +117 -116
- package/dist/chunks/hook-installer.mjs +3 -2
- package/dist/chunks/index.mjs +20 -6
- package/dist/chunks/index10.mjs +1171 -0
- package/dist/chunks/index11.mjs +1008 -0
- package/dist/chunks/index12.mjs +193 -0
- package/dist/chunks/index13.mjs +218 -0
- package/dist/chunks/index14.mjs +663 -0
- package/dist/chunks/index2.mjs +19 -10
- package/dist/chunks/index3.mjs +19079 -164
- package/dist/chunks/index4.mjs +8 -1171
- package/dist/chunks/index5.mjs +7479 -884
- package/dist/chunks/index6.mjs +160 -184
- package/dist/chunks/index7.mjs +3573 -653
- package/dist/chunks/index8.mjs +19 -0
- package/dist/chunks/index9.mjs +616 -0
- package/dist/chunks/init.mjs +173 -173
- package/dist/chunks/installer.mjs +92 -82
- package/dist/chunks/installer2.mjs +3 -2
- package/dist/chunks/interview.mjs +118 -107
- package/dist/chunks/json-config.mjs +3 -2
- package/dist/chunks/linux.mjs +3863 -0
- package/dist/chunks/macos.mjs +69 -0
- package/dist/chunks/main.mjs +635 -0
- package/dist/chunks/marketplace.mjs +69 -66
- package/dist/chunks/mcp-cli.mjs +61 -48
- package/dist/chunks/mcp.mjs +140 -127
- package/dist/chunks/menu.mjs +85 -85
- package/dist/chunks/metrics-display.mjs +41 -40
- package/dist/chunks/migrator.mjs +4 -5
- package/dist/chunks/monitor.mjs +95 -95
- package/dist/chunks/notification.mjs +151 -141
- package/dist/chunks/onboarding.mjs +26 -15
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/paradigm.mjs +24 -23
- package/dist/chunks/permission-manager.mjs +10 -11
- package/dist/chunks/permissions.mjs +72 -57
- package/dist/chunks/persistence-manager.mjs +97 -84
- package/dist/chunks/persistence.mjs +1 -1
- package/dist/chunks/platform.mjs +29 -29
- package/dist/chunks/plugin.mjs +104 -105
- package/dist/chunks/prompts.mjs +36 -25
- package/dist/chunks/providers.mjs +68 -69
- package/dist/chunks/quick-actions.mjs +71 -72
- package/dist/chunks/quick-provider.mjs +56 -40
- package/dist/chunks/quick-setup.mjs +71 -60
- package/dist/chunks/remote.mjs +21 -12
- package/dist/chunks/session.mjs +116 -103
- package/dist/chunks/sessions.mjs +29 -28
- package/dist/chunks/silent-updater.mjs +8 -10
- package/dist/chunks/simple-config.mjs +13 -10
- package/dist/chunks/skill.mjs +8560 -103
- package/dist/chunks/skills-sync.mjs +5212 -79
- package/dist/chunks/skills.mjs +105 -94
- package/dist/chunks/slash-commands.mjs +36 -37
- package/dist/chunks/smart-defaults.mjs +7 -3
- package/dist/chunks/smart-guide.mjs +1 -1
- package/dist/chunks/startup.mjs +2 -4
- package/dist/chunks/stats.mjs +41 -42
- package/dist/chunks/status.mjs +49 -50
- package/dist/chunks/team.mjs +24 -12
- package/dist/chunks/thinking.mjs +74 -63
- package/dist/chunks/trace.mjs +20 -19
- package/dist/chunks/uninstall.mjs +69 -56
- package/dist/chunks/update.mjs +39 -28
- package/dist/chunks/upgrade-manager.mjs +24 -18
- package/dist/chunks/version-checker.mjs +45 -41
- package/dist/chunks/vim.mjs +81 -69
- package/dist/chunks/windows.mjs +14 -0
- package/dist/chunks/workflows.mjs +15 -15
- package/dist/chunks/wsl.mjs +129 -0
- package/dist/chunks/zero-config.mjs +45 -34
- package/dist/cli.mjs +20 -20
- package/dist/index.mjs +41 -31
- package/dist/shared/ccjk.BAGoDD49.mjs +36 -0
- package/dist/shared/ccjk.BBtCGd_g.mjs +899 -0
- package/dist/shared/{ccjk.CGcy7cNM.mjs → ccjk.BDKUdmLk.mjs} +1 -1
- package/dist/shared/{ccjk.DtMBiwVG.mjs → ccjk.BFxsJM0k.mjs} +1 -1
- package/dist/shared/{ccjk.j4uut26D.mjs → ccjk.BIxuVL3_.mjs} +5 -5
- package/dist/shared/ccjk.BRZ9ww8S.mjs +142 -0
- package/dist/shared/{ccjk.CN0edl87.mjs → ccjk.BSYWk9ML.mjs} +1 -1
- package/dist/shared/{ccjk.Dk1HDseQ.mjs → ccjk.BnpWvs9V.mjs} +75 -75
- package/dist/shared/ccjk.BoApaI4j.mjs +28 -0
- package/dist/shared/{ccjk.DKojSRzw.mjs → ccjk.BrPUmTqm.mjs} +1 -1
- package/dist/shared/{ccjk.C10pepYx.mjs → ccjk.BxSmJ8B7.mjs} +1 -1
- package/dist/shared/ccjk.Bx_rmYfN.mjs +69 -0
- package/dist/shared/ccjk.COweQ1RR.mjs +5 -0
- package/dist/shared/{ccjk.BN90X6oc.mjs → ccjk.CePkJq2S.mjs} +17 -17
- package/dist/shared/{ccjk.Bvoex4TZ.mjs → ccjk.CfKKcvWy.mjs} +1 -1
- package/dist/shared/ccjk.Cjgrln_h.mjs +297 -0
- package/dist/shared/ccjk.CxpGa6MC.mjs +2724 -0
- package/dist/shared/{ccjk.DfwJOEok.mjs → ccjk.D5MFQT7w.mjs} +1 -1
- package/dist/shared/{ccjk.cChAaGgT.mjs → ccjk.DG_o24cZ.mjs} +6 -6
- package/dist/shared/{ccjk.bhFAMRyc.mjs → ccjk.DLLw-h4Y.mjs} +32 -32
- package/dist/shared/ccjk.DOwtZMk8.mjs +4019 -0
- package/dist/shared/{ccjk.BsXQugfY.mjs → ccjk.DTdjs-qK.mjs} +13 -13
- package/dist/shared/{ccjk.Bdhyg3X-.mjs → ccjk.DsYaCCx4.mjs} +1 -1
- package/dist/shared/ccjk.KfSWcGlE.mjs +38 -0
- package/dist/shared/ccjk.RyizuzOI.mjs +21 -0
- package/dist/shared/{ccjk.h7_W-wTs.mjs → ccjk.SPoXMvZD.mjs} +1 -1
- package/dist/shared/ccjk.T_cX87dY.mjs +15 -0
- package/dist/shared/{ccjk.CrB6OYHv.mjs → ccjk._dESH4Rk.mjs} +2 -2
- package/dist/shared/ccjk.bQ7Dh1g4.mjs +249 -0
- package/dist/shared/{ccjk.CBhIZiPz.mjs → ccjk.hoqrwWdN.mjs} +1 -1
- package/dist/shared/{ccjk.BNwRnWYx.mjs → ccjk.s7OCVzdd.mjs} +1230 -33
- package/dist/shared/{ccjk.BOIUTf5z.mjs → ccjk.waa2ikKJ.mjs} +8 -9
- package/package.json +31 -30
- package/dist/shared/ccjk.DHbrGcgg.mjs +0 -13
- package/dist/shared/ccjk.DntgA8fQ.mjs +0 -42
|
@@ -1,9 +1,581 @@
|
|
|
1
|
-
import consola from 'consola';
|
|
2
1
|
import { promises, existsSync } from 'node:fs';
|
|
3
|
-
import
|
|
2
|
+
import posix from '../chunks/index8.mjs';
|
|
4
3
|
import { glob } from 'tinyglobby';
|
|
5
|
-
import { parse } from '
|
|
6
|
-
|
|
4
|
+
import { p as parse } from './ccjk.BBtCGd_g.mjs';
|
|
5
|
+
|
|
6
|
+
const LogLevels = {
|
|
7
|
+
fatal: 0,
|
|
8
|
+
error: 0,
|
|
9
|
+
warn: 1,
|
|
10
|
+
log: 2,
|
|
11
|
+
info: 3,
|
|
12
|
+
success: 3,
|
|
13
|
+
fail: 3,
|
|
14
|
+
debug: 4,
|
|
15
|
+
trace: 5,
|
|
16
|
+
verbose: Number.POSITIVE_INFINITY
|
|
17
|
+
};
|
|
18
|
+
const LogTypes = {
|
|
19
|
+
// Silent
|
|
20
|
+
silent: {
|
|
21
|
+
level: -1
|
|
22
|
+
},
|
|
23
|
+
// Level 0
|
|
24
|
+
fatal: {
|
|
25
|
+
level: LogLevels.fatal
|
|
26
|
+
},
|
|
27
|
+
error: {
|
|
28
|
+
level: LogLevels.error
|
|
29
|
+
},
|
|
30
|
+
// Level 1
|
|
31
|
+
warn: {
|
|
32
|
+
level: LogLevels.warn
|
|
33
|
+
},
|
|
34
|
+
// Level 2
|
|
35
|
+
log: {
|
|
36
|
+
level: LogLevels.log
|
|
37
|
+
},
|
|
38
|
+
// Level 3
|
|
39
|
+
info: {
|
|
40
|
+
level: LogLevels.info
|
|
41
|
+
},
|
|
42
|
+
success: {
|
|
43
|
+
level: LogLevels.success
|
|
44
|
+
},
|
|
45
|
+
fail: {
|
|
46
|
+
level: LogLevels.fail
|
|
47
|
+
},
|
|
48
|
+
ready: {
|
|
49
|
+
level: LogLevels.info
|
|
50
|
+
},
|
|
51
|
+
start: {
|
|
52
|
+
level: LogLevels.info
|
|
53
|
+
},
|
|
54
|
+
box: {
|
|
55
|
+
level: LogLevels.info
|
|
56
|
+
},
|
|
57
|
+
// Level 4
|
|
58
|
+
debug: {
|
|
59
|
+
level: LogLevels.debug
|
|
60
|
+
},
|
|
61
|
+
// Level 5
|
|
62
|
+
trace: {
|
|
63
|
+
level: LogLevels.trace
|
|
64
|
+
},
|
|
65
|
+
// Verbose
|
|
66
|
+
verbose: {
|
|
67
|
+
level: LogLevels.verbose
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function isPlainObject$1(value) {
|
|
72
|
+
if (value === null || typeof value !== "object") {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const prototype = Object.getPrototypeOf(value);
|
|
76
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (Symbol.iterator in value) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (Symbol.toStringTag in value) {
|
|
83
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
89
|
+
if (!isPlainObject$1(defaults)) {
|
|
90
|
+
return _defu(baseObject, {}, namespace);
|
|
91
|
+
}
|
|
92
|
+
const object = Object.assign({}, defaults);
|
|
93
|
+
for (const key in baseObject) {
|
|
94
|
+
if (key === "__proto__" || key === "constructor") {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const value = baseObject[key];
|
|
98
|
+
if (value === null || value === void 0) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
102
|
+
object[key] = [...value, ...object[key]];
|
|
103
|
+
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
104
|
+
object[key] = _defu(
|
|
105
|
+
value,
|
|
106
|
+
object[key],
|
|
107
|
+
(namespace ? `${namespace}.` : "") + key.toString());
|
|
108
|
+
} else {
|
|
109
|
+
object[key] = value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return object;
|
|
113
|
+
}
|
|
114
|
+
function createDefu(merger) {
|
|
115
|
+
return (...arguments_) => (
|
|
116
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
117
|
+
arguments_.reduce((p, c) => _defu(p, c, ""), {})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
const defu = createDefu();
|
|
121
|
+
|
|
122
|
+
function isPlainObject(obj) {
|
|
123
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
124
|
+
}
|
|
125
|
+
function isLogObj(arg) {
|
|
126
|
+
if (!isPlainObject(arg)) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
if (!arg.message && !arg.args) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (arg.stack) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let paused = false;
|
|
139
|
+
const queue = [];
|
|
140
|
+
class Consola {
|
|
141
|
+
options;
|
|
142
|
+
_lastLog;
|
|
143
|
+
_mockFn;
|
|
144
|
+
/**
|
|
145
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
146
|
+
*
|
|
147
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
148
|
+
*/
|
|
149
|
+
constructor(options = {}) {
|
|
150
|
+
const types = options.types || LogTypes;
|
|
151
|
+
this.options = defu(
|
|
152
|
+
{
|
|
153
|
+
...options,
|
|
154
|
+
defaults: { ...options.defaults },
|
|
155
|
+
level: _normalizeLogLevel(options.level, types),
|
|
156
|
+
reporters: [...options.reporters || []]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
types: LogTypes,
|
|
160
|
+
throttle: 1e3,
|
|
161
|
+
throttleMin: 5,
|
|
162
|
+
formatOptions: {
|
|
163
|
+
date: true,
|
|
164
|
+
colors: false,
|
|
165
|
+
compact: true
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
for (const type in types) {
|
|
170
|
+
const defaults = {
|
|
171
|
+
type,
|
|
172
|
+
...this.options.defaults,
|
|
173
|
+
...types[type]
|
|
174
|
+
};
|
|
175
|
+
this[type] = this._wrapLogFn(defaults);
|
|
176
|
+
this[type].raw = this._wrapLogFn(
|
|
177
|
+
defaults,
|
|
178
|
+
true
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (this.options.mockFn) {
|
|
182
|
+
this.mockTypes();
|
|
183
|
+
}
|
|
184
|
+
this._lastLog = {};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Gets the current log level of the Consola instance.
|
|
188
|
+
*
|
|
189
|
+
* @returns {number} The current log level.
|
|
190
|
+
*/
|
|
191
|
+
get level() {
|
|
192
|
+
return this.options.level;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Sets the minimum log level that will be output by the instance.
|
|
196
|
+
*
|
|
197
|
+
* @param {number} level - The new log level to set.
|
|
198
|
+
*/
|
|
199
|
+
set level(level) {
|
|
200
|
+
this.options.level = _normalizeLogLevel(
|
|
201
|
+
level,
|
|
202
|
+
this.options.types,
|
|
203
|
+
this.options.level
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Displays a prompt to the user and returns the response.
|
|
208
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
209
|
+
*
|
|
210
|
+
* @template T
|
|
211
|
+
* @param {string} message - The message to display in the prompt.
|
|
212
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
213
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
214
|
+
*/
|
|
215
|
+
prompt(message, opts) {
|
|
216
|
+
if (!this.options.prompt) {
|
|
217
|
+
throw new Error("prompt is not supported!");
|
|
218
|
+
}
|
|
219
|
+
return this.options.prompt(message, opts);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
223
|
+
*
|
|
224
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
225
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
226
|
+
*/
|
|
227
|
+
create(options) {
|
|
228
|
+
const instance = new Consola({
|
|
229
|
+
...this.options,
|
|
230
|
+
...options
|
|
231
|
+
});
|
|
232
|
+
if (this._mockFn) {
|
|
233
|
+
instance.mockTypes(this._mockFn);
|
|
234
|
+
}
|
|
235
|
+
return instance;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
239
|
+
*
|
|
240
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
241
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
242
|
+
*/
|
|
243
|
+
withDefaults(defaults) {
|
|
244
|
+
return this.create({
|
|
245
|
+
...this.options,
|
|
246
|
+
defaults: {
|
|
247
|
+
...this.options.defaults,
|
|
248
|
+
...defaults
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
256
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
257
|
+
*/
|
|
258
|
+
withTag(tag) {
|
|
259
|
+
return this.withDefaults({
|
|
260
|
+
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Adds a custom reporter to the Consola instance.
|
|
265
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
266
|
+
*
|
|
267
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
268
|
+
* @returns {Consola} The current Consola instance.
|
|
269
|
+
*/
|
|
270
|
+
addReporter(reporter) {
|
|
271
|
+
this.options.reporters.push(reporter);
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Removes a custom reporter from the Consola instance.
|
|
276
|
+
* If no reporter is specified, all reporters will be removed.
|
|
277
|
+
*
|
|
278
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
279
|
+
* @returns {Consola} The current Consola instance.
|
|
280
|
+
*/
|
|
281
|
+
removeReporter(reporter) {
|
|
282
|
+
if (reporter) {
|
|
283
|
+
const i = this.options.reporters.indexOf(reporter);
|
|
284
|
+
if (i !== -1) {
|
|
285
|
+
return this.options.reporters.splice(i, 1);
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
this.options.reporters.splice(0);
|
|
289
|
+
}
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
294
|
+
*
|
|
295
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
296
|
+
* @returns {Consola} The current Consola instance.
|
|
297
|
+
*/
|
|
298
|
+
setReporters(reporters) {
|
|
299
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
wrapAll() {
|
|
303
|
+
this.wrapConsole();
|
|
304
|
+
this.wrapStd();
|
|
305
|
+
}
|
|
306
|
+
restoreAll() {
|
|
307
|
+
this.restoreConsole();
|
|
308
|
+
this.restoreStd();
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
312
|
+
*/
|
|
313
|
+
wrapConsole() {
|
|
314
|
+
for (const type in this.options.types) {
|
|
315
|
+
if (!console["__" + type]) {
|
|
316
|
+
console["__" + type] = console[type];
|
|
317
|
+
}
|
|
318
|
+
console[type] = this[type].raw;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Restores the original console methods, removing Consola overrides.
|
|
323
|
+
*/
|
|
324
|
+
restoreConsole() {
|
|
325
|
+
for (const type in this.options.types) {
|
|
326
|
+
if (console["__" + type]) {
|
|
327
|
+
console[type] = console["__" + type];
|
|
328
|
+
delete console["__" + type];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
334
|
+
*/
|
|
335
|
+
wrapStd() {
|
|
336
|
+
this._wrapStream(this.options.stdout, "log");
|
|
337
|
+
this._wrapStream(this.options.stderr, "log");
|
|
338
|
+
}
|
|
339
|
+
_wrapStream(stream, type) {
|
|
340
|
+
if (!stream) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (!stream.__write) {
|
|
344
|
+
stream.__write = stream.write;
|
|
345
|
+
}
|
|
346
|
+
stream.write = (data) => {
|
|
347
|
+
this[type].raw(String(data).trim());
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
352
|
+
*/
|
|
353
|
+
restoreStd() {
|
|
354
|
+
this._restoreStream(this.options.stdout);
|
|
355
|
+
this._restoreStream(this.options.stderr);
|
|
356
|
+
}
|
|
357
|
+
_restoreStream(stream) {
|
|
358
|
+
if (!stream) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (stream.__write) {
|
|
362
|
+
stream.write = stream.__write;
|
|
363
|
+
delete stream.__write;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
368
|
+
*/
|
|
369
|
+
pauseLogs() {
|
|
370
|
+
paused = true;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Resumes logging, processing any queued logs.
|
|
374
|
+
*/
|
|
375
|
+
resumeLogs() {
|
|
376
|
+
paused = false;
|
|
377
|
+
const _queue = queue.splice(0);
|
|
378
|
+
for (const item of _queue) {
|
|
379
|
+
item[0]._logFn(item[1], item[2]);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
384
|
+
*
|
|
385
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
386
|
+
*/
|
|
387
|
+
mockTypes(mockFn) {
|
|
388
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
389
|
+
this._mockFn = _mockFn;
|
|
390
|
+
if (typeof _mockFn !== "function") {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
for (const type in this.options.types) {
|
|
394
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
395
|
+
this[type].raw = this[type];
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
_wrapLogFn(defaults, isRaw) {
|
|
399
|
+
return (...args) => {
|
|
400
|
+
if (paused) {
|
|
401
|
+
queue.push([this, defaults, args, isRaw]);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
return this._logFn(defaults, args, isRaw);
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
_logFn(defaults, args, isRaw) {
|
|
408
|
+
if ((defaults.level || 0) > this.level) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
const logObj = {
|
|
412
|
+
date: /* @__PURE__ */ new Date(),
|
|
413
|
+
args: [],
|
|
414
|
+
...defaults,
|
|
415
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
416
|
+
};
|
|
417
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
418
|
+
Object.assign(logObj, args[0]);
|
|
419
|
+
} else {
|
|
420
|
+
logObj.args = [...args];
|
|
421
|
+
}
|
|
422
|
+
if (logObj.message) {
|
|
423
|
+
logObj.args.unshift(logObj.message);
|
|
424
|
+
delete logObj.message;
|
|
425
|
+
}
|
|
426
|
+
if (logObj.additional) {
|
|
427
|
+
if (!Array.isArray(logObj.additional)) {
|
|
428
|
+
logObj.additional = logObj.additional.split("\n");
|
|
429
|
+
}
|
|
430
|
+
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
431
|
+
delete logObj.additional;
|
|
432
|
+
}
|
|
433
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
434
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
435
|
+
const resolveLog = (newLog = false) => {
|
|
436
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
437
|
+
if (this._lastLog.object && repeated > 0) {
|
|
438
|
+
const args2 = [...this._lastLog.object.args];
|
|
439
|
+
if (repeated > 1) {
|
|
440
|
+
args2.push(`(repeated ${repeated} times)`);
|
|
441
|
+
}
|
|
442
|
+
this._log({ ...this._lastLog.object, args: args2 });
|
|
443
|
+
this._lastLog.count = 1;
|
|
444
|
+
}
|
|
445
|
+
if (newLog) {
|
|
446
|
+
this._lastLog.object = logObj;
|
|
447
|
+
this._log(logObj);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
clearTimeout(this._lastLog.timeout);
|
|
451
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
452
|
+
this._lastLog.time = logObj.date;
|
|
453
|
+
if (diffTime < this.options.throttle) {
|
|
454
|
+
try {
|
|
455
|
+
const serializedLog = JSON.stringify([
|
|
456
|
+
logObj.type,
|
|
457
|
+
logObj.tag,
|
|
458
|
+
logObj.args
|
|
459
|
+
]);
|
|
460
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
461
|
+
this._lastLog.serialized = serializedLog;
|
|
462
|
+
if (isSameLog) {
|
|
463
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
464
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
465
|
+
this._lastLog.timeout = setTimeout(
|
|
466
|
+
resolveLog,
|
|
467
|
+
this.options.throttle
|
|
468
|
+
);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
} catch {
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
resolveLog(true);
|
|
476
|
+
}
|
|
477
|
+
_log(logObj) {
|
|
478
|
+
for (const reporter of this.options.reporters) {
|
|
479
|
+
reporter.log(logObj, {
|
|
480
|
+
options: this.options
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
486
|
+
if (input === void 0) {
|
|
487
|
+
return defaultLevel;
|
|
488
|
+
}
|
|
489
|
+
if (typeof input === "number") {
|
|
490
|
+
return input;
|
|
491
|
+
}
|
|
492
|
+
if (types[input] && types[input].level !== void 0) {
|
|
493
|
+
return types[input].level;
|
|
494
|
+
}
|
|
495
|
+
return defaultLevel;
|
|
496
|
+
}
|
|
497
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
498
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
499
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
500
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
501
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
502
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
503
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
504
|
+
function createConsola$1(options = {}) {
|
|
505
|
+
return new Consola(options);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
class BrowserReporter {
|
|
509
|
+
options;
|
|
510
|
+
defaultColor;
|
|
511
|
+
levelColorMap;
|
|
512
|
+
typeColorMap;
|
|
513
|
+
constructor(options) {
|
|
514
|
+
this.options = { ...options };
|
|
515
|
+
this.defaultColor = "#7f8c8d";
|
|
516
|
+
this.levelColorMap = {
|
|
517
|
+
0: "#c0392b",
|
|
518
|
+
// Red
|
|
519
|
+
1: "#f39c12",
|
|
520
|
+
// Yellow
|
|
521
|
+
3: "#00BCD4"
|
|
522
|
+
// Cyan
|
|
523
|
+
};
|
|
524
|
+
this.typeColorMap = {
|
|
525
|
+
success: "#2ecc71"
|
|
526
|
+
// Green
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
_getLogFn(level) {
|
|
530
|
+
if (level < 1) {
|
|
531
|
+
return console.__error || console.error;
|
|
532
|
+
}
|
|
533
|
+
if (level === 1) {
|
|
534
|
+
return console.__warn || console.warn;
|
|
535
|
+
}
|
|
536
|
+
return console.__log || console.log;
|
|
537
|
+
}
|
|
538
|
+
log(logObj) {
|
|
539
|
+
const consoleLogFn = this._getLogFn(logObj.level);
|
|
540
|
+
const type = logObj.type === "log" ? "" : logObj.type;
|
|
541
|
+
const tag = logObj.tag || "";
|
|
542
|
+
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
|
543
|
+
const style = `
|
|
544
|
+
background: ${color};
|
|
545
|
+
border-radius: 0.5em;
|
|
546
|
+
color: white;
|
|
547
|
+
font-weight: bold;
|
|
548
|
+
padding: 2px 0.5em;
|
|
549
|
+
`;
|
|
550
|
+
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
|
551
|
+
if (typeof logObj.args[0] === "string") {
|
|
552
|
+
consoleLogFn(
|
|
553
|
+
`${badge}%c ${logObj.args[0]}`,
|
|
554
|
+
style,
|
|
555
|
+
// Empty string as style resets to default console style
|
|
556
|
+
"",
|
|
557
|
+
...logObj.args.slice(1)
|
|
558
|
+
);
|
|
559
|
+
} else {
|
|
560
|
+
consoleLogFn(badge, style, ...logObj.args);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function createConsola(options = {}) {
|
|
566
|
+
const consola2 = createConsola$1({
|
|
567
|
+
reporters: options.reporters || [new BrowserReporter({})],
|
|
568
|
+
prompt(message, options2 = {}) {
|
|
569
|
+
if (options2.type === "confirm") {
|
|
570
|
+
return Promise.resolve(confirm(message));
|
|
571
|
+
}
|
|
572
|
+
return Promise.resolve(prompt(message));
|
|
573
|
+
},
|
|
574
|
+
...options
|
|
575
|
+
});
|
|
576
|
+
return consola2;
|
|
577
|
+
}
|
|
578
|
+
const consola = createConsola();
|
|
7
579
|
|
|
8
580
|
async function pathExists$5(p) {
|
|
9
581
|
try {
|
|
@@ -68,7 +640,7 @@ async function analyzeDependencies$1(analysis, config) {
|
|
|
68
640
|
};
|
|
69
641
|
}
|
|
70
642
|
async function analyzeNpmDependencies(projectPath) {
|
|
71
|
-
const packageJsonPath =
|
|
643
|
+
const packageJsonPath = posix.join(projectPath, "package.json");
|
|
72
644
|
if (!await pathExists$5(packageJsonPath)) {
|
|
73
645
|
return { direct: [], all: [] };
|
|
74
646
|
}
|
|
@@ -107,10 +679,10 @@ async function analyzePythonDependencies(projectPath, packageManager) {
|
|
|
107
679
|
const direct = [];
|
|
108
680
|
const all = [];
|
|
109
681
|
if (packageManager === "poetry") {
|
|
110
|
-
const pyprojectPath =
|
|
682
|
+
const pyprojectPath = posix.join(projectPath, "pyproject.toml");
|
|
111
683
|
if (await pathExists$5(pyprojectPath)) {
|
|
112
684
|
try {
|
|
113
|
-
const { parse } = await import('
|
|
685
|
+
const { parse } = await import('../chunks/index6.mjs');
|
|
114
686
|
const content = await promises.readFile(pyprojectPath, "utf-8");
|
|
115
687
|
const pyproject = parse(content);
|
|
116
688
|
const deps = pyproject.tool?.poetry?.dependencies || {};
|
|
@@ -140,10 +712,10 @@ async function analyzePythonDependencies(projectPath, packageManager) {
|
|
|
140
712
|
}
|
|
141
713
|
}
|
|
142
714
|
} else if (packageManager === "pipenv") {
|
|
143
|
-
const pipfilePath =
|
|
715
|
+
const pipfilePath = posix.join(projectPath, "Pipfile");
|
|
144
716
|
if (await pathExists$5(pipfilePath)) {
|
|
145
717
|
try {
|
|
146
|
-
const { parse } = await import('
|
|
718
|
+
const { parse } = await import('../chunks/index6.mjs');
|
|
147
719
|
const content = await promises.readFile(pipfilePath, "utf-8");
|
|
148
720
|
const pipfile = parse(content);
|
|
149
721
|
const deps = pipfile.packages || {};
|
|
@@ -173,7 +745,7 @@ async function analyzePythonDependencies(projectPath, packageManager) {
|
|
|
173
745
|
}
|
|
174
746
|
}
|
|
175
747
|
} else {
|
|
176
|
-
const requirementsPath =
|
|
748
|
+
const requirementsPath = posix.join(projectPath, "requirements.txt");
|
|
177
749
|
if (await pathExists$5(requirementsPath)) {
|
|
178
750
|
try {
|
|
179
751
|
const content = await promises.readFile(requirementsPath, "utf-8");
|
|
@@ -203,7 +775,7 @@ async function analyzePythonDependencies(projectPath, packageManager) {
|
|
|
203
775
|
return { direct, all };
|
|
204
776
|
}
|
|
205
777
|
async function analyzeGoDependencies(projectPath) {
|
|
206
|
-
const goModPath =
|
|
778
|
+
const goModPath = posix.join(projectPath, "go.mod");
|
|
207
779
|
if (!await pathExists$5(goModPath)) {
|
|
208
780
|
return { direct: [], all: [] };
|
|
209
781
|
}
|
|
@@ -246,12 +818,12 @@ async function analyzeGoDependencies(projectPath) {
|
|
|
246
818
|
}
|
|
247
819
|
}
|
|
248
820
|
async function analyzeRustDependencies(projectPath) {
|
|
249
|
-
const cargoTomlPath =
|
|
821
|
+
const cargoTomlPath = posix.join(projectPath, "Cargo.toml");
|
|
250
822
|
if (!await pathExists$5(cargoTomlPath)) {
|
|
251
823
|
return { direct: [], all: [] };
|
|
252
824
|
}
|
|
253
825
|
try {
|
|
254
|
-
const { parse } = await import('
|
|
826
|
+
const { parse } = await import('../chunks/index6.mjs');
|
|
255
827
|
const content = await promises.readFile(cargoTomlPath, "utf-8");
|
|
256
828
|
const cargoToml = parse(content);
|
|
257
829
|
const direct = [];
|
|
@@ -520,7 +1092,7 @@ const FRAMEWORK_PATTERNS$3 = {
|
|
|
520
1092
|
async function analyzeGoProject(projectPath, files, _languages) {
|
|
521
1093
|
logger$5.info("Analyzing Go project");
|
|
522
1094
|
const frameworks = [];
|
|
523
|
-
const goModPath =
|
|
1095
|
+
const goModPath = posix.join(projectPath, "go.mod");
|
|
524
1096
|
let _goMod = null;
|
|
525
1097
|
try {
|
|
526
1098
|
if (await pathExists$4(goModPath)) {
|
|
@@ -591,7 +1163,7 @@ async function scanGoImports(projectPath, files) {
|
|
|
591
1163
|
const goFiles = files.filter((f) => f.endsWith(".go"));
|
|
592
1164
|
for (const file of goFiles) {
|
|
593
1165
|
try {
|
|
594
|
-
const content = await promises.readFile(
|
|
1166
|
+
const content = await promises.readFile(posix.join(projectPath, file), "utf-8");
|
|
595
1167
|
const fileImports = extractGoImports(content);
|
|
596
1168
|
for (const importPath of fileImports) {
|
|
597
1169
|
if (!imports[importPath]) {
|
|
@@ -649,7 +1221,7 @@ function getFrameworkCategory$3(framework) {
|
|
|
649
1221
|
return "other";
|
|
650
1222
|
}
|
|
651
1223
|
async function detectAdditionalPatterns$3(projectPath, files, frameworks, imports) {
|
|
652
|
-
const goModPath =
|
|
1224
|
+
const goModPath = posix.join(projectPath, "go.mod");
|
|
653
1225
|
if (files.includes("go.mod") && await pathExists$4(goModPath)) {
|
|
654
1226
|
try {
|
|
655
1227
|
const content = await promises.readFile(goModPath, "utf-8");
|
|
@@ -741,7 +1313,7 @@ async function detectAdditionalPatterns$3(projectPath, files, frameworks, import
|
|
|
741
1313
|
evidence: ["Found .proto files"]
|
|
742
1314
|
});
|
|
743
1315
|
}
|
|
744
|
-
const goWorkPath =
|
|
1316
|
+
const goWorkPath = posix.join(projectPath, "go.work");
|
|
745
1317
|
if (files.includes("go.work") && await pathExists$4(goWorkPath)) {
|
|
746
1318
|
frameworks.push({
|
|
747
1319
|
name: "workspace",
|
|
@@ -938,7 +1510,7 @@ async function analyzePythonProject(projectPath, files, _languages) {
|
|
|
938
1510
|
}
|
|
939
1511
|
async function analyzeDependencies(projectPath, files) {
|
|
940
1512
|
const dependencies = {};
|
|
941
|
-
const requirementsPath =
|
|
1513
|
+
const requirementsPath = posix.join(projectPath, "requirements.txt");
|
|
942
1514
|
if (files.includes("requirements.txt") && await pathExists$3(requirementsPath)) {
|
|
943
1515
|
try {
|
|
944
1516
|
const content = await promises.readFile(requirementsPath, "utf-8");
|
|
@@ -956,7 +1528,7 @@ async function analyzeDependencies(projectPath, files) {
|
|
|
956
1528
|
logger$4.warn("Failed to parse requirements.txt:", error);
|
|
957
1529
|
}
|
|
958
1530
|
}
|
|
959
|
-
const pyprojectPath =
|
|
1531
|
+
const pyprojectPath = posix.join(projectPath, "pyproject.toml");
|
|
960
1532
|
if (files.includes("pyproject.toml") && await pathExists$3(pyprojectPath)) {
|
|
961
1533
|
try {
|
|
962
1534
|
const content = await promises.readFile(pyprojectPath, "utf-8");
|
|
@@ -993,7 +1565,7 @@ async function analyzeDependencies(projectPath, files) {
|
|
|
993
1565
|
logger$4.warn("Failed to parse pyproject.toml:", error);
|
|
994
1566
|
}
|
|
995
1567
|
}
|
|
996
|
-
const pipfilePath =
|
|
1568
|
+
const pipfilePath = posix.join(projectPath, "Pipfile");
|
|
997
1569
|
if (files.includes("Pipfile") && await pathExists$3(pipfilePath)) {
|
|
998
1570
|
try {
|
|
999
1571
|
const content = await promises.readFile(pipfilePath, "utf-8");
|
|
@@ -1020,7 +1592,7 @@ async function analyzeDependencies(projectPath, files) {
|
|
|
1020
1592
|
logger$4.warn("Failed to parse Pipfile:", error);
|
|
1021
1593
|
}
|
|
1022
1594
|
}
|
|
1023
|
-
const setupPath =
|
|
1595
|
+
const setupPath = posix.join(projectPath, "setup.py");
|
|
1024
1596
|
if (files.includes("setup.py") && await pathExists$3(setupPath)) {
|
|
1025
1597
|
try {
|
|
1026
1598
|
const content = await promises.readFile(setupPath, "utf-8");
|
|
@@ -1039,7 +1611,7 @@ async function analyzeDependencies(projectPath, files) {
|
|
|
1039
1611
|
logger$4.warn("Failed to parse setup.py:", error);
|
|
1040
1612
|
}
|
|
1041
1613
|
}
|
|
1042
|
-
const envPath =
|
|
1614
|
+
const envPath = posix.join(projectPath, "environment.yml");
|
|
1043
1615
|
if (files.includes("environment.yml") && await pathExists$3(envPath)) {
|
|
1044
1616
|
try {
|
|
1045
1617
|
const content = await promises.readFile(envPath, "utf-8");
|
|
@@ -1092,7 +1664,7 @@ function getFrameworkCategory$2(framework) {
|
|
|
1092
1664
|
return "other";
|
|
1093
1665
|
}
|
|
1094
1666
|
async function detectAdditionalPatterns$2(projectPath, files, frameworks, dependencies) {
|
|
1095
|
-
const pythonVersionPath =
|
|
1667
|
+
const pythonVersionPath = posix.join(projectPath, ".python-version");
|
|
1096
1668
|
if (files.includes(".python-version") && await pathExists$3(pythonVersionPath)) {
|
|
1097
1669
|
try {
|
|
1098
1670
|
const version = await promises.readFile(pythonVersionPath, "utf-8");
|
|
@@ -1309,7 +1881,7 @@ const FRAMEWORK_PATTERNS$1 = {
|
|
|
1309
1881
|
async function analyzeRustProject(projectPath, files, _languages) {
|
|
1310
1882
|
logger$3.info("Analyzing Rust project");
|
|
1311
1883
|
const frameworks = [];
|
|
1312
|
-
const cargoTomlPath =
|
|
1884
|
+
const cargoTomlPath = posix.join(projectPath, "Cargo.toml");
|
|
1313
1885
|
let cargoToml = null;
|
|
1314
1886
|
try {
|
|
1315
1887
|
if (await pathExists$2(cargoTomlPath)) {
|
|
@@ -1390,7 +1962,7 @@ async function scanRustPatterns(projectPath, files) {
|
|
|
1390
1962
|
const rustFiles = files.filter((f) => f.endsWith(".rs"));
|
|
1391
1963
|
for (const file of rustFiles) {
|
|
1392
1964
|
try {
|
|
1393
|
-
const content = await promises.readFile(
|
|
1965
|
+
const content = await promises.readFile(posix.join(projectPath, file), "utf-8");
|
|
1394
1966
|
const patternRegex = /(\w+::|@\[|!\w+\()/g;
|
|
1395
1967
|
let match;
|
|
1396
1968
|
while ((match = patternRegex.exec(content)) !== null) {
|
|
@@ -1790,7 +2362,7 @@ const FRAMEWORK_PATTERNS = {
|
|
|
1790
2362
|
async function analyzeTypeScriptProject(projectPath, files, _languages) {
|
|
1791
2363
|
logger$2.info("Analyzing TypeScript/JavaScript project");
|
|
1792
2364
|
const frameworks = [];
|
|
1793
|
-
const packageJsonPath =
|
|
2365
|
+
const packageJsonPath = posix.join(projectPath, "package.json");
|
|
1794
2366
|
let packageJson = null;
|
|
1795
2367
|
try {
|
|
1796
2368
|
if (await pathExists$1(packageJsonPath)) {
|
|
@@ -1809,7 +2381,7 @@ async function analyzeTypeScriptProject(projectPath, files, _languages) {
|
|
|
1809
2381
|
}
|
|
1810
2382
|
}
|
|
1811
2383
|
for (const indicator of patterns.indicators) {
|
|
1812
|
-
const indicatorPath =
|
|
2384
|
+
const indicatorPath = posix.join(projectPath, indicator);
|
|
1813
2385
|
if (files.some((f) => f.startsWith(indicator)) || await pathExists$1(indicatorPath)) {
|
|
1814
2386
|
evidence.push(`Found ${indicator} directory`);
|
|
1815
2387
|
confidence += 0.2;
|
|
@@ -2080,7 +2652,7 @@ const FRAMEWORK_PRIORITY = {
|
|
|
2080
2652
|
async function detectProject(projectPath, config) {
|
|
2081
2653
|
const startTime = Date.now();
|
|
2082
2654
|
logger$1.info(`Detecting project at: ${projectPath}`);
|
|
2083
|
-
const absolutePath =
|
|
2655
|
+
const absolutePath = posix.resolve(projectPath);
|
|
2084
2656
|
if (!await pathExists(absolutePath)) {
|
|
2085
2657
|
throw new Error(`Project path does not exist: ${absolutePath}`);
|
|
2086
2658
|
}
|
|
@@ -2153,7 +2725,7 @@ const ROOT_CONFIG_FILES = [
|
|
|
2153
2725
|
async function scanProjectFiles(projectPath, config) {
|
|
2154
2726
|
const rootConfigFiles = [];
|
|
2155
2727
|
for (const configFile of ROOT_CONFIG_FILES) {
|
|
2156
|
-
const configPath =
|
|
2728
|
+
const configPath = posix.join(projectPath, configFile);
|
|
2157
2729
|
if (await pathExists(configPath)) {
|
|
2158
2730
|
rootConfigFiles.push(configFile);
|
|
2159
2731
|
logger$1.debug(`Found root config: ${configFile}`);
|
|
@@ -2184,7 +2756,7 @@ async function detectLanguages(projectPath, files, config) {
|
|
|
2184
2756
|
const languageCounts = /* @__PURE__ */ new Map();
|
|
2185
2757
|
const languageIndicators = /* @__PURE__ */ new Map();
|
|
2186
2758
|
for (const file of files) {
|
|
2187
|
-
const ext =
|
|
2759
|
+
const ext = posix.extname(file).toLowerCase();
|
|
2188
2760
|
for (const [language, patterns] of Object.entries(LANGUAGE_PATTERNS)) {
|
|
2189
2761
|
const extensions = patterns.extensions;
|
|
2190
2762
|
if (extensions.includes(ext)) {
|
|
@@ -2202,7 +2774,7 @@ async function detectLanguages(projectPath, files, config) {
|
|
|
2202
2774
|
}
|
|
2203
2775
|
}
|
|
2204
2776
|
for (const indicator of patterns.indicators) {
|
|
2205
|
-
if (fileSet.has(indicator) || await pathExists(
|
|
2777
|
+
if (fileSet.has(indicator) || await pathExists(posix.join(projectPath, indicator))) {
|
|
2206
2778
|
indicators.push(`Found ${indicator}`);
|
|
2207
2779
|
languageCounts.set(language, (languageCounts.get(language) || 0) + 5);
|
|
2208
2780
|
}
|
|
@@ -2351,7 +2923,7 @@ function detectImportantDirs(projectPath) {
|
|
|
2351
2923
|
];
|
|
2352
2924
|
const foundDirs = [];
|
|
2353
2925
|
for (const dir of importantDirs) {
|
|
2354
|
-
if (existsSync(
|
|
2926
|
+
if (existsSync(posix.join(projectPath, dir))) {
|
|
2355
2927
|
foundDirs.push(dir);
|
|
2356
2928
|
}
|
|
2357
2929
|
}
|
|
@@ -2449,6 +3021,631 @@ async function detectProjectType(projectPath) {
|
|
|
2449
3021
|
return analysis.projectType;
|
|
2450
3022
|
}
|
|
2451
3023
|
|
|
3024
|
+
const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
|
3025
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
3026
|
+
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
3027
|
+
function jsonParseTransform(key, value) {
|
|
3028
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
3029
|
+
warnKeyDropped(key);
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
return value;
|
|
3033
|
+
}
|
|
3034
|
+
function warnKeyDropped(key) {
|
|
3035
|
+
console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
|
|
3036
|
+
}
|
|
3037
|
+
function destr(value, options = {}) {
|
|
3038
|
+
if (typeof value !== "string") {
|
|
3039
|
+
return value;
|
|
3040
|
+
}
|
|
3041
|
+
if (value[0] === '"' && value[value.length - 1] === '"' && value.indexOf("\\") === -1) {
|
|
3042
|
+
return value.slice(1, -1);
|
|
3043
|
+
}
|
|
3044
|
+
const _value = value.trim();
|
|
3045
|
+
if (_value.length <= 9) {
|
|
3046
|
+
switch (_value.toLowerCase()) {
|
|
3047
|
+
case "true": {
|
|
3048
|
+
return true;
|
|
3049
|
+
}
|
|
3050
|
+
case "false": {
|
|
3051
|
+
return false;
|
|
3052
|
+
}
|
|
3053
|
+
case "undefined": {
|
|
3054
|
+
return void 0;
|
|
3055
|
+
}
|
|
3056
|
+
case "null": {
|
|
3057
|
+
return null;
|
|
3058
|
+
}
|
|
3059
|
+
case "nan": {
|
|
3060
|
+
return Number.NaN;
|
|
3061
|
+
}
|
|
3062
|
+
case "infinity": {
|
|
3063
|
+
return Number.POSITIVE_INFINITY;
|
|
3064
|
+
}
|
|
3065
|
+
case "-infinity": {
|
|
3066
|
+
return Number.NEGATIVE_INFINITY;
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
if (!JsonSigRx.test(value)) {
|
|
3071
|
+
if (options.strict) {
|
|
3072
|
+
throw new SyntaxError("[destr] Invalid JSON");
|
|
3073
|
+
}
|
|
3074
|
+
return value;
|
|
3075
|
+
}
|
|
3076
|
+
try {
|
|
3077
|
+
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
|
3078
|
+
if (options.strict) {
|
|
3079
|
+
throw new Error("[destr] Possible prototype pollution");
|
|
3080
|
+
}
|
|
3081
|
+
return JSON.parse(value, jsonParseTransform);
|
|
3082
|
+
}
|
|
3083
|
+
return JSON.parse(value);
|
|
3084
|
+
} catch (error) {
|
|
3085
|
+
if (options.strict) {
|
|
3086
|
+
throw error;
|
|
3087
|
+
}
|
|
3088
|
+
return value;
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
const HASH_RE = /#/g;
|
|
3093
|
+
const AMPERSAND_RE = /&/g;
|
|
3094
|
+
const SLASH_RE = /\//g;
|
|
3095
|
+
const EQUAL_RE = /=/g;
|
|
3096
|
+
const PLUS_RE = /\+/g;
|
|
3097
|
+
const ENC_CARET_RE = /%5e/gi;
|
|
3098
|
+
const ENC_BACKTICK_RE = /%60/gi;
|
|
3099
|
+
const ENC_PIPE_RE = /%7c/gi;
|
|
3100
|
+
const ENC_SPACE_RE = /%20/gi;
|
|
3101
|
+
function encode(text) {
|
|
3102
|
+
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
3103
|
+
}
|
|
3104
|
+
function encodeQueryValue(input) {
|
|
3105
|
+
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
3106
|
+
}
|
|
3107
|
+
function encodeQueryKey(text) {
|
|
3108
|
+
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
3109
|
+
}
|
|
3110
|
+
function decode(text = "") {
|
|
3111
|
+
try {
|
|
3112
|
+
return decodeURIComponent("" + text);
|
|
3113
|
+
} catch {
|
|
3114
|
+
return "" + text;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
function decodeQueryKey(text) {
|
|
3118
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
3119
|
+
}
|
|
3120
|
+
function decodeQueryValue(text) {
|
|
3121
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
function parseQuery(parametersString = "") {
|
|
3125
|
+
const object = /* @__PURE__ */ Object.create(null);
|
|
3126
|
+
if (parametersString[0] === "?") {
|
|
3127
|
+
parametersString = parametersString.slice(1);
|
|
3128
|
+
}
|
|
3129
|
+
for (const parameter of parametersString.split("&")) {
|
|
3130
|
+
const s = parameter.match(/([^=]+)=?(.*)/) || [];
|
|
3131
|
+
if (s.length < 2) {
|
|
3132
|
+
continue;
|
|
3133
|
+
}
|
|
3134
|
+
const key = decodeQueryKey(s[1]);
|
|
3135
|
+
if (key === "__proto__" || key === "constructor") {
|
|
3136
|
+
continue;
|
|
3137
|
+
}
|
|
3138
|
+
const value = decodeQueryValue(s[2] || "");
|
|
3139
|
+
if (object[key] === void 0) {
|
|
3140
|
+
object[key] = value;
|
|
3141
|
+
} else if (Array.isArray(object[key])) {
|
|
3142
|
+
object[key].push(value);
|
|
3143
|
+
} else {
|
|
3144
|
+
object[key] = [object[key], value];
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
return object;
|
|
3148
|
+
}
|
|
3149
|
+
function encodeQueryItem(key, value) {
|
|
3150
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
3151
|
+
value = String(value);
|
|
3152
|
+
}
|
|
3153
|
+
if (!value) {
|
|
3154
|
+
return encodeQueryKey(key);
|
|
3155
|
+
}
|
|
3156
|
+
if (Array.isArray(value)) {
|
|
3157
|
+
return value.map(
|
|
3158
|
+
(_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`
|
|
3159
|
+
).join("&");
|
|
3160
|
+
}
|
|
3161
|
+
return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
|
|
3162
|
+
}
|
|
3163
|
+
function stringifyQuery(query) {
|
|
3164
|
+
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
3168
|
+
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
3169
|
+
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
3170
|
+
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
3171
|
+
function hasProtocol(inputString, opts = {}) {
|
|
3172
|
+
if (typeof opts === "boolean") {
|
|
3173
|
+
opts = { acceptRelative: opts };
|
|
3174
|
+
}
|
|
3175
|
+
if (opts.strict) {
|
|
3176
|
+
return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
3177
|
+
}
|
|
3178
|
+
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
3179
|
+
}
|
|
3180
|
+
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
3181
|
+
{
|
|
3182
|
+
return input.endsWith("/");
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
3186
|
+
{
|
|
3187
|
+
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
3191
|
+
{
|
|
3192
|
+
return input.endsWith("/") ? input : input + "/";
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
function withBase(input, base) {
|
|
3196
|
+
if (isEmptyURL(base) || hasProtocol(input)) {
|
|
3197
|
+
return input;
|
|
3198
|
+
}
|
|
3199
|
+
const _base = withoutTrailingSlash(base);
|
|
3200
|
+
if (input.startsWith(_base)) {
|
|
3201
|
+
return input;
|
|
3202
|
+
}
|
|
3203
|
+
return joinURL(_base, input);
|
|
3204
|
+
}
|
|
3205
|
+
function withQuery(input, query) {
|
|
3206
|
+
const parsed = parseURL(input);
|
|
3207
|
+
const mergedQuery = { ...parseQuery(parsed.search), ...query };
|
|
3208
|
+
parsed.search = stringifyQuery(mergedQuery);
|
|
3209
|
+
return stringifyParsedURL(parsed);
|
|
3210
|
+
}
|
|
3211
|
+
function isEmptyURL(url) {
|
|
3212
|
+
return !url || url === "/";
|
|
3213
|
+
}
|
|
3214
|
+
function isNonEmptyURL(url) {
|
|
3215
|
+
return url && url !== "/";
|
|
3216
|
+
}
|
|
3217
|
+
function joinURL(base, ...input) {
|
|
3218
|
+
let url = base || "";
|
|
3219
|
+
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {
|
|
3220
|
+
if (url) {
|
|
3221
|
+
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
|
3222
|
+
url = withTrailingSlash(url) + _segment;
|
|
3223
|
+
} else {
|
|
3224
|
+
url = segment;
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
return url;
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
const protocolRelative = Symbol.for("ufo:protocolRelative");
|
|
3231
|
+
function parseURL(input = "", defaultProto) {
|
|
3232
|
+
const _specialProtoMatch = input.match(
|
|
3233
|
+
/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
|
|
3234
|
+
);
|
|
3235
|
+
if (_specialProtoMatch) {
|
|
3236
|
+
const [, _proto, _pathname = ""] = _specialProtoMatch;
|
|
3237
|
+
return {
|
|
3238
|
+
protocol: _proto.toLowerCase(),
|
|
3239
|
+
pathname: _pathname,
|
|
3240
|
+
href: _proto + _pathname,
|
|
3241
|
+
auth: "",
|
|
3242
|
+
host: "",
|
|
3243
|
+
search: "",
|
|
3244
|
+
hash: ""
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
if (!hasProtocol(input, { acceptRelative: true })) {
|
|
3248
|
+
return parsePath(input);
|
|
3249
|
+
}
|
|
3250
|
+
const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
3251
|
+
let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
|
|
3252
|
+
if (protocol === "file:") {
|
|
3253
|
+
path = path.replace(/\/(?=[A-Za-z]:)/, "");
|
|
3254
|
+
}
|
|
3255
|
+
const { pathname, search, hash } = parsePath(path);
|
|
3256
|
+
return {
|
|
3257
|
+
protocol: protocol.toLowerCase(),
|
|
3258
|
+
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
|
3259
|
+
host,
|
|
3260
|
+
pathname,
|
|
3261
|
+
search,
|
|
3262
|
+
hash,
|
|
3263
|
+
[protocolRelative]: !protocol
|
|
3264
|
+
};
|
|
3265
|
+
}
|
|
3266
|
+
function parsePath(input = "") {
|
|
3267
|
+
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
3268
|
+
return {
|
|
3269
|
+
pathname,
|
|
3270
|
+
search,
|
|
3271
|
+
hash
|
|
3272
|
+
};
|
|
3273
|
+
}
|
|
3274
|
+
function stringifyParsedURL(parsed) {
|
|
3275
|
+
const pathname = parsed.pathname || "";
|
|
3276
|
+
const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
|
|
3277
|
+
const hash = parsed.hash || "";
|
|
3278
|
+
const auth = parsed.auth ? parsed.auth + "@" : "";
|
|
3279
|
+
const host = parsed.host || "";
|
|
3280
|
+
const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "";
|
|
3281
|
+
return proto + auth + host + pathname + search + hash;
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
class FetchError extends Error {
|
|
3285
|
+
constructor(message, opts) {
|
|
3286
|
+
super(message, opts);
|
|
3287
|
+
this.name = "FetchError";
|
|
3288
|
+
if (opts?.cause && !this.cause) {
|
|
3289
|
+
this.cause = opts.cause;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
function createFetchError(ctx) {
|
|
3294
|
+
const errorMessage = ctx.error?.message || ctx.error?.toString() || "";
|
|
3295
|
+
const method = ctx.request?.method || ctx.options?.method || "GET";
|
|
3296
|
+
const url = ctx.request?.url || String(ctx.request) || "/";
|
|
3297
|
+
const requestStr = `[${method}] ${JSON.stringify(url)}`;
|
|
3298
|
+
const statusStr = ctx.response ? `${ctx.response.status} ${ctx.response.statusText}` : "<no response>";
|
|
3299
|
+
const message = `${requestStr}: ${statusStr}${errorMessage ? ` ${errorMessage}` : ""}`;
|
|
3300
|
+
const fetchError = new FetchError(
|
|
3301
|
+
message,
|
|
3302
|
+
ctx.error ? { cause: ctx.error } : void 0
|
|
3303
|
+
);
|
|
3304
|
+
for (const key of ["request", "options", "response"]) {
|
|
3305
|
+
Object.defineProperty(fetchError, key, {
|
|
3306
|
+
get() {
|
|
3307
|
+
return ctx[key];
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3310
|
+
}
|
|
3311
|
+
for (const [key, refKey] of [
|
|
3312
|
+
["data", "_data"],
|
|
3313
|
+
["status", "status"],
|
|
3314
|
+
["statusCode", "status"],
|
|
3315
|
+
["statusText", "statusText"],
|
|
3316
|
+
["statusMessage", "statusText"]
|
|
3317
|
+
]) {
|
|
3318
|
+
Object.defineProperty(fetchError, key, {
|
|
3319
|
+
get() {
|
|
3320
|
+
return ctx.response && ctx.response[refKey];
|
|
3321
|
+
}
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
return fetchError;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
const payloadMethods = new Set(
|
|
3328
|
+
Object.freeze(["PATCH", "POST", "PUT", "DELETE"])
|
|
3329
|
+
);
|
|
3330
|
+
function isPayloadMethod(method = "GET") {
|
|
3331
|
+
return payloadMethods.has(method.toUpperCase());
|
|
3332
|
+
}
|
|
3333
|
+
function isJSONSerializable(value) {
|
|
3334
|
+
if (value === void 0) {
|
|
3335
|
+
return false;
|
|
3336
|
+
}
|
|
3337
|
+
const t = typeof value;
|
|
3338
|
+
if (t === "string" || t === "number" || t === "boolean" || t === null) {
|
|
3339
|
+
return true;
|
|
3340
|
+
}
|
|
3341
|
+
if (t !== "object") {
|
|
3342
|
+
return false;
|
|
3343
|
+
}
|
|
3344
|
+
if (Array.isArray(value)) {
|
|
3345
|
+
return true;
|
|
3346
|
+
}
|
|
3347
|
+
if (value.buffer) {
|
|
3348
|
+
return false;
|
|
3349
|
+
}
|
|
3350
|
+
if (value instanceof FormData || value instanceof URLSearchParams) {
|
|
3351
|
+
return false;
|
|
3352
|
+
}
|
|
3353
|
+
return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
|
|
3354
|
+
}
|
|
3355
|
+
const textTypes = /* @__PURE__ */ new Set([
|
|
3356
|
+
"image/svg",
|
|
3357
|
+
"application/xml",
|
|
3358
|
+
"application/xhtml",
|
|
3359
|
+
"application/html"
|
|
3360
|
+
]);
|
|
3361
|
+
const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
|
3362
|
+
function detectResponseType(_contentType = "") {
|
|
3363
|
+
if (!_contentType) {
|
|
3364
|
+
return "json";
|
|
3365
|
+
}
|
|
3366
|
+
const contentType = _contentType.split(";").shift() || "";
|
|
3367
|
+
if (JSON_RE.test(contentType)) {
|
|
3368
|
+
return "json";
|
|
3369
|
+
}
|
|
3370
|
+
if (contentType === "text/event-stream") {
|
|
3371
|
+
return "stream";
|
|
3372
|
+
}
|
|
3373
|
+
if (textTypes.has(contentType) || contentType.startsWith("text/")) {
|
|
3374
|
+
return "text";
|
|
3375
|
+
}
|
|
3376
|
+
return "blob";
|
|
3377
|
+
}
|
|
3378
|
+
function resolveFetchOptions(request, input, defaults, Headers) {
|
|
3379
|
+
const headers = mergeHeaders(
|
|
3380
|
+
input?.headers ?? request?.headers,
|
|
3381
|
+
defaults?.headers,
|
|
3382
|
+
Headers
|
|
3383
|
+
);
|
|
3384
|
+
let query;
|
|
3385
|
+
if (defaults?.query || defaults?.params || input?.params || input?.query) {
|
|
3386
|
+
query = {
|
|
3387
|
+
...defaults?.params,
|
|
3388
|
+
...defaults?.query,
|
|
3389
|
+
...input?.params,
|
|
3390
|
+
...input?.query
|
|
3391
|
+
};
|
|
3392
|
+
}
|
|
3393
|
+
return {
|
|
3394
|
+
...defaults,
|
|
3395
|
+
...input,
|
|
3396
|
+
query,
|
|
3397
|
+
params: query,
|
|
3398
|
+
headers
|
|
3399
|
+
};
|
|
3400
|
+
}
|
|
3401
|
+
function mergeHeaders(input, defaults, Headers) {
|
|
3402
|
+
if (!defaults) {
|
|
3403
|
+
return new Headers(input);
|
|
3404
|
+
}
|
|
3405
|
+
const headers = new Headers(defaults);
|
|
3406
|
+
if (input) {
|
|
3407
|
+
for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers(input)) {
|
|
3408
|
+
headers.set(key, value);
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
return headers;
|
|
3412
|
+
}
|
|
3413
|
+
async function callHooks(context, hooks) {
|
|
3414
|
+
if (hooks) {
|
|
3415
|
+
if (Array.isArray(hooks)) {
|
|
3416
|
+
for (const hook of hooks) {
|
|
3417
|
+
await hook(context);
|
|
3418
|
+
}
|
|
3419
|
+
} else {
|
|
3420
|
+
await hooks(context);
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
const retryStatusCodes = /* @__PURE__ */ new Set([
|
|
3426
|
+
408,
|
|
3427
|
+
// Request Timeout
|
|
3428
|
+
409,
|
|
3429
|
+
// Conflict
|
|
3430
|
+
425,
|
|
3431
|
+
// Too Early (Experimental)
|
|
3432
|
+
429,
|
|
3433
|
+
// Too Many Requests
|
|
3434
|
+
500,
|
|
3435
|
+
// Internal Server Error
|
|
3436
|
+
502,
|
|
3437
|
+
// Bad Gateway
|
|
3438
|
+
503,
|
|
3439
|
+
// Service Unavailable
|
|
3440
|
+
504
|
|
3441
|
+
// Gateway Timeout
|
|
3442
|
+
]);
|
|
3443
|
+
const nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]);
|
|
3444
|
+
function createFetch(globalOptions = {}) {
|
|
3445
|
+
const {
|
|
3446
|
+
fetch = globalThis.fetch,
|
|
3447
|
+
Headers = globalThis.Headers,
|
|
3448
|
+
AbortController = globalThis.AbortController
|
|
3449
|
+
} = globalOptions;
|
|
3450
|
+
async function onError(context) {
|
|
3451
|
+
const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
|
|
3452
|
+
if (context.options.retry !== false && !isAbort) {
|
|
3453
|
+
let retries;
|
|
3454
|
+
if (typeof context.options.retry === "number") {
|
|
3455
|
+
retries = context.options.retry;
|
|
3456
|
+
} else {
|
|
3457
|
+
retries = isPayloadMethod(context.options.method) ? 0 : 1;
|
|
3458
|
+
}
|
|
3459
|
+
const responseCode = context.response && context.response.status || 500;
|
|
3460
|
+
if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {
|
|
3461
|
+
const retryDelay = typeof context.options.retryDelay === "function" ? context.options.retryDelay(context) : context.options.retryDelay || 0;
|
|
3462
|
+
if (retryDelay > 0) {
|
|
3463
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
3464
|
+
}
|
|
3465
|
+
return $fetchRaw(context.request, {
|
|
3466
|
+
...context.options,
|
|
3467
|
+
retry: retries - 1
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
const error = createFetchError(context);
|
|
3472
|
+
if (Error.captureStackTrace) {
|
|
3473
|
+
Error.captureStackTrace(error, $fetchRaw);
|
|
3474
|
+
}
|
|
3475
|
+
throw error;
|
|
3476
|
+
}
|
|
3477
|
+
const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {
|
|
3478
|
+
const context = {
|
|
3479
|
+
request: _request,
|
|
3480
|
+
options: resolveFetchOptions(
|
|
3481
|
+
_request,
|
|
3482
|
+
_options,
|
|
3483
|
+
globalOptions.defaults,
|
|
3484
|
+
Headers
|
|
3485
|
+
),
|
|
3486
|
+
response: void 0,
|
|
3487
|
+
error: void 0
|
|
3488
|
+
};
|
|
3489
|
+
if (context.options.method) {
|
|
3490
|
+
context.options.method = context.options.method.toUpperCase();
|
|
3491
|
+
}
|
|
3492
|
+
if (context.options.onRequest) {
|
|
3493
|
+
await callHooks(context, context.options.onRequest);
|
|
3494
|
+
if (!(context.options.headers instanceof Headers)) {
|
|
3495
|
+
context.options.headers = new Headers(
|
|
3496
|
+
context.options.headers || {}
|
|
3497
|
+
/* compat */
|
|
3498
|
+
);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
if (typeof context.request === "string") {
|
|
3502
|
+
if (context.options.baseURL) {
|
|
3503
|
+
context.request = withBase(context.request, context.options.baseURL);
|
|
3504
|
+
}
|
|
3505
|
+
if (context.options.query) {
|
|
3506
|
+
context.request = withQuery(context.request, context.options.query);
|
|
3507
|
+
delete context.options.query;
|
|
3508
|
+
}
|
|
3509
|
+
if ("query" in context.options) {
|
|
3510
|
+
delete context.options.query;
|
|
3511
|
+
}
|
|
3512
|
+
if ("params" in context.options) {
|
|
3513
|
+
delete context.options.params;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
if (context.options.body && isPayloadMethod(context.options.method)) {
|
|
3517
|
+
if (isJSONSerializable(context.options.body)) {
|
|
3518
|
+
const contentType = context.options.headers.get("content-type");
|
|
3519
|
+
if (typeof context.options.body !== "string") {
|
|
3520
|
+
context.options.body = contentType === "application/x-www-form-urlencoded" ? new URLSearchParams(
|
|
3521
|
+
context.options.body
|
|
3522
|
+
).toString() : JSON.stringify(context.options.body);
|
|
3523
|
+
}
|
|
3524
|
+
if (!contentType) {
|
|
3525
|
+
context.options.headers.set("content-type", "application/json");
|
|
3526
|
+
}
|
|
3527
|
+
if (!context.options.headers.has("accept")) {
|
|
3528
|
+
context.options.headers.set("accept", "application/json");
|
|
3529
|
+
}
|
|
3530
|
+
} else if (
|
|
3531
|
+
// ReadableStream Body
|
|
3532
|
+
"pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || // Node.js Stream Body
|
|
3533
|
+
typeof context.options.body.pipe === "function"
|
|
3534
|
+
) {
|
|
3535
|
+
if (!("duplex" in context.options)) {
|
|
3536
|
+
context.options.duplex = "half";
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
let abortTimeout;
|
|
3541
|
+
if (!context.options.signal && context.options.timeout) {
|
|
3542
|
+
const controller = new AbortController();
|
|
3543
|
+
abortTimeout = setTimeout(() => {
|
|
3544
|
+
const error = new Error(
|
|
3545
|
+
"[TimeoutError]: The operation was aborted due to timeout"
|
|
3546
|
+
);
|
|
3547
|
+
error.name = "TimeoutError";
|
|
3548
|
+
error.code = 23;
|
|
3549
|
+
controller.abort(error);
|
|
3550
|
+
}, context.options.timeout);
|
|
3551
|
+
context.options.signal = controller.signal;
|
|
3552
|
+
}
|
|
3553
|
+
try {
|
|
3554
|
+
context.response = await fetch(
|
|
3555
|
+
context.request,
|
|
3556
|
+
context.options
|
|
3557
|
+
);
|
|
3558
|
+
} catch (error) {
|
|
3559
|
+
context.error = error;
|
|
3560
|
+
if (context.options.onRequestError) {
|
|
3561
|
+
await callHooks(
|
|
3562
|
+
context,
|
|
3563
|
+
context.options.onRequestError
|
|
3564
|
+
);
|
|
3565
|
+
}
|
|
3566
|
+
return await onError(context);
|
|
3567
|
+
} finally {
|
|
3568
|
+
if (abortTimeout) {
|
|
3569
|
+
clearTimeout(abortTimeout);
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
const hasBody = (context.response.body || // https://github.com/unjs/ofetch/issues/324
|
|
3573
|
+
// https://github.com/unjs/ofetch/issues/294
|
|
3574
|
+
// https://github.com/JakeChampion/fetch/issues/1454
|
|
3575
|
+
context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD";
|
|
3576
|
+
if (hasBody) {
|
|
3577
|
+
const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
|
|
3578
|
+
switch (responseType) {
|
|
3579
|
+
case "json": {
|
|
3580
|
+
const data = await context.response.text();
|
|
3581
|
+
const parseFunction = context.options.parseResponse || destr;
|
|
3582
|
+
context.response._data = parseFunction(data);
|
|
3583
|
+
break;
|
|
3584
|
+
}
|
|
3585
|
+
case "stream": {
|
|
3586
|
+
context.response._data = context.response.body || context.response._bodyInit;
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
default: {
|
|
3590
|
+
context.response._data = await context.response[responseType]();
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
if (context.options.onResponse) {
|
|
3595
|
+
await callHooks(
|
|
3596
|
+
context,
|
|
3597
|
+
context.options.onResponse
|
|
3598
|
+
);
|
|
3599
|
+
}
|
|
3600
|
+
if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {
|
|
3601
|
+
if (context.options.onResponseError) {
|
|
3602
|
+
await callHooks(
|
|
3603
|
+
context,
|
|
3604
|
+
context.options.onResponseError
|
|
3605
|
+
);
|
|
3606
|
+
}
|
|
3607
|
+
return await onError(context);
|
|
3608
|
+
}
|
|
3609
|
+
return context.response;
|
|
3610
|
+
};
|
|
3611
|
+
const $fetch = async function $fetch2(request, options) {
|
|
3612
|
+
const r = await $fetchRaw(request, options);
|
|
3613
|
+
return r._data;
|
|
3614
|
+
};
|
|
3615
|
+
$fetch.raw = $fetchRaw;
|
|
3616
|
+
$fetch.native = (...args) => fetch(...args);
|
|
3617
|
+
$fetch.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
|
|
3618
|
+
...globalOptions,
|
|
3619
|
+
...customGlobalOptions,
|
|
3620
|
+
defaults: {
|
|
3621
|
+
...globalOptions.defaults,
|
|
3622
|
+
...customGlobalOptions.defaults,
|
|
3623
|
+
...defaultOptions
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3626
|
+
return $fetch;
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
const _globalThis = (function() {
|
|
3630
|
+
if (typeof globalThis !== "undefined") {
|
|
3631
|
+
return globalThis;
|
|
3632
|
+
}
|
|
3633
|
+
if (typeof self !== "undefined") {
|
|
3634
|
+
return self;
|
|
3635
|
+
}
|
|
3636
|
+
if (typeof window !== "undefined") {
|
|
3637
|
+
return window;
|
|
3638
|
+
}
|
|
3639
|
+
if (typeof global !== "undefined") {
|
|
3640
|
+
return global;
|
|
3641
|
+
}
|
|
3642
|
+
throw new Error("unable to locate global object");
|
|
3643
|
+
})();
|
|
3644
|
+
const fetch = _globalThis.fetch ? (...args) => _globalThis.fetch(...args) : () => Promise.reject(new Error("[ofetch] global.fetch is not supported!"));
|
|
3645
|
+
const Headers = _globalThis.Headers;
|
|
3646
|
+
const AbortController = _globalThis.AbortController;
|
|
3647
|
+
const ofetch = createFetch({ fetch, Headers, AbortController });
|
|
3648
|
+
|
|
2452
3649
|
class TemplatesClient {
|
|
2453
3650
|
fetch;
|
|
2454
3651
|
baseURL;
|
|
@@ -2732,4 +3929,4 @@ function getTemplatesClient(config) {
|
|
|
2732
3929
|
return templatesClientInstance;
|
|
2733
3930
|
}
|
|
2734
3931
|
|
|
2735
|
-
export { ProjectAnalyzer as P, analyzeProject as a, getTemplatesClient as g };
|
|
3932
|
+
export { ProjectAnalyzer as P, analyzeProject as a, consola as c, getTemplatesClient as g, ofetch as o };
|