@frontman-ai/astro 0.1.6 → 0.1.7
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 +429 -353
- package/dist/integration.js +425 -352
- package/package.json +1 -1
package/dist/integration.js
CHANGED
|
@@ -4,6 +4,8 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
4
4
|
import * as Nodepath from 'path';
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
6
|
import { createRequire } from 'module';
|
|
7
|
+
import * as Nodebuffer from 'buffer';
|
|
8
|
+
import * as Nodechild_process from 'child_process';
|
|
7
9
|
|
|
8
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
11
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -16,9 +18,9 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
16
18
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
// ../../node_modules/
|
|
21
|
+
// ../../node_modules/@vscode/ripgrep/lib/index.js
|
|
20
22
|
var require_lib = __commonJS({
|
|
21
|
-
"../../node_modules/
|
|
23
|
+
"../../node_modules/@vscode/ripgrep/lib/index.js"(exports$1, module) {
|
|
22
24
|
var path = __require("path");
|
|
23
25
|
module.exports.rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
|
|
24
26
|
}
|
|
@@ -89,6 +91,9 @@ function orElse(opt, other) {
|
|
|
89
91
|
return other;
|
|
90
92
|
}
|
|
91
93
|
}
|
|
94
|
+
function isSome(x) {
|
|
95
|
+
return x !== void 0;
|
|
96
|
+
}
|
|
92
97
|
|
|
93
98
|
// ../frontman-core/src/FrontmanCore__Hosts.res.mjs
|
|
94
99
|
var apiHost = "api.frontman.sh";
|
|
@@ -2003,6 +2008,7 @@ var ctx = {
|
|
|
2003
2008
|
function factory$4(definer) {
|
|
2004
2009
|
return definitionToSchema(definer(ctx));
|
|
2005
2010
|
}
|
|
2011
|
+
var js_schema = definitionToSchema;
|
|
2006
2012
|
function option(item) {
|
|
2007
2013
|
return factory$1(item, unit);
|
|
2008
2014
|
}
|
|
@@ -2242,8 +2248,10 @@ function toJSONSchema(schema3) {
|
|
|
2242
2248
|
}
|
|
2243
2249
|
return jsonSchema;
|
|
2244
2250
|
}
|
|
2251
|
+
var literal = js_schema;
|
|
2245
2252
|
var array = factory$2;
|
|
2246
2253
|
var dict = factory$3;
|
|
2254
|
+
var union = factory;
|
|
2247
2255
|
var schema = factory$4;
|
|
2248
2256
|
|
|
2249
2257
|
// ../../node_modules/sury/src/S.res.mjs
|
|
@@ -2253,9 +2261,11 @@ var bool2 = bool;
|
|
|
2253
2261
|
var int2 = int;
|
|
2254
2262
|
var json2 = json;
|
|
2255
2263
|
var enableJson2 = enableJson;
|
|
2264
|
+
var literal2 = literal;
|
|
2256
2265
|
var array2 = array;
|
|
2257
2266
|
var dict2 = dict;
|
|
2258
2267
|
var option2 = option;
|
|
2268
|
+
var union2 = union;
|
|
2259
2269
|
var parseOrThrow2 = parseOrThrow;
|
|
2260
2270
|
var reverseConvertToJsonOrThrow2 = reverseConvertToJsonOrThrow;
|
|
2261
2271
|
var schema2 = schema;
|
|
@@ -4010,69 +4020,160 @@ function fromString2(x, radix) {
|
|
|
4010
4020
|
return maybeInt | 0;
|
|
4011
4021
|
}
|
|
4012
4022
|
}
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4023
|
+
function execPromise(command, options) {
|
|
4024
|
+
return new Promise((resolve3, _reject) => {
|
|
4025
|
+
let cwd = options.cwd;
|
|
4026
|
+
let env = options.env;
|
|
4027
|
+
let maxBuffer = getOr(options.maxBuffer, 52428800);
|
|
4028
|
+
Nodechild_process.exec(command, {
|
|
4029
|
+
cwd,
|
|
4030
|
+
env,
|
|
4031
|
+
maxBuffer,
|
|
4032
|
+
encoding: "utf8"
|
|
4033
|
+
}, (err, stdout, stderr) => {
|
|
4034
|
+
if (err == null) {
|
|
4035
|
+
return resolve3({
|
|
4036
|
+
TAG: "Ok",
|
|
4037
|
+
_0: {
|
|
4038
|
+
stdout,
|
|
4039
|
+
stderr
|
|
4040
|
+
}
|
|
4041
|
+
});
|
|
4042
|
+
} else {
|
|
4043
|
+
return resolve3({
|
|
4044
|
+
TAG: "Error",
|
|
4045
|
+
_0: {
|
|
4046
|
+
code: fromNullable(err.code),
|
|
4047
|
+
stdout,
|
|
4048
|
+
stderr,
|
|
4049
|
+
message: err.message
|
|
4050
|
+
}
|
|
4051
|
+
});
|
|
4037
4052
|
}
|
|
4053
|
+
});
|
|
4054
|
+
});
|
|
4055
|
+
}
|
|
4056
|
+
function spawnPromise(command, args, options) {
|
|
4057
|
+
let maxBuffer = getOr(options.maxBuffer, 52428800);
|
|
4058
|
+
return new Promise((resolve3, _reject) => {
|
|
4059
|
+
let cwd = options.cwd;
|
|
4060
|
+
let env = options.env;
|
|
4061
|
+
let proc = Nodechild_process.spawn(command, args, {
|
|
4062
|
+
cwd,
|
|
4063
|
+
env
|
|
4064
|
+
});
|
|
4065
|
+
let stdoutChunks = {
|
|
4066
|
+
contents: []
|
|
4038
4067
|
};
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
let actualError = getOr(fromNullable(exn._1), exn);
|
|
4042
|
-
return {
|
|
4043
|
-
TAG: "Error",
|
|
4044
|
-
_0: {
|
|
4045
|
-
code: fromNullable(actualError.code),
|
|
4046
|
-
stdout: getOr(map(fromNullable(actualError.stdout), bufferToString), ""),
|
|
4047
|
-
stderr: getOr(map(fromNullable(actualError.stderr), bufferToString), "")
|
|
4048
|
-
}
|
|
4068
|
+
let stderrChunks = {
|
|
4069
|
+
contents: []
|
|
4049
4070
|
};
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
let
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4071
|
+
let stdoutLen = {
|
|
4072
|
+
contents: 0
|
|
4073
|
+
};
|
|
4074
|
+
let stderrLen = {
|
|
4075
|
+
contents: 0
|
|
4076
|
+
};
|
|
4077
|
+
let resolved = {
|
|
4078
|
+
contents: false
|
|
4079
|
+
};
|
|
4080
|
+
let guardedResolve = (value) => {
|
|
4081
|
+
if (resolved.contents) {
|
|
4082
|
+
return;
|
|
4083
|
+
} else {
|
|
4084
|
+
resolved.contents = true;
|
|
4085
|
+
return resolve3(value);
|
|
4062
4086
|
}
|
|
4063
4087
|
};
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4088
|
+
proc.stdout.on("data", (chunk) => {
|
|
4089
|
+
if (resolved.contents) {
|
|
4090
|
+
return;
|
|
4091
|
+
} else {
|
|
4092
|
+
stdoutChunks.contents.push(chunk);
|
|
4093
|
+
stdoutLen.contents = stdoutLen.contents + chunk.byteLength | 0;
|
|
4094
|
+
if (stdoutLen.contents > maxBuffer) {
|
|
4095
|
+
proc.kill("SIGTERM");
|
|
4096
|
+
return guardedResolve({
|
|
4097
|
+
TAG: "Error",
|
|
4098
|
+
_0: {
|
|
4099
|
+
code: void 0,
|
|
4100
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4101
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4102
|
+
message: "stdout maxBuffer exceeded"
|
|
4103
|
+
}
|
|
4104
|
+
});
|
|
4105
|
+
} else {
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
});
|
|
4110
|
+
proc.stderr.on("data", (chunk) => {
|
|
4111
|
+
if (resolved.contents) {
|
|
4112
|
+
return;
|
|
4113
|
+
} else {
|
|
4114
|
+
stderrChunks.contents.push(chunk);
|
|
4115
|
+
stderrLen.contents = stderrLen.contents + chunk.byteLength | 0;
|
|
4116
|
+
if (stderrLen.contents > maxBuffer) {
|
|
4117
|
+
proc.kill("SIGTERM");
|
|
4118
|
+
return guardedResolve({
|
|
4119
|
+
TAG: "Error",
|
|
4120
|
+
_0: {
|
|
4121
|
+
code: void 0,
|
|
4122
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4123
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4124
|
+
message: "stderr maxBuffer exceeded"
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
} else {
|
|
4128
|
+
return;
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
});
|
|
4132
|
+
proc.on("error", (err) => guardedResolve({
|
|
4068
4133
|
TAG: "Error",
|
|
4069
4134
|
_0: {
|
|
4070
|
-
code:
|
|
4071
|
-
stdout:
|
|
4072
|
-
stderr:
|
|
4135
|
+
code: void 0,
|
|
4136
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4137
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4138
|
+
message: err.message
|
|
4073
4139
|
}
|
|
4074
|
-
};
|
|
4075
|
-
|
|
4140
|
+
}));
|
|
4141
|
+
proc.on("close", (nullableCode) => {
|
|
4142
|
+
let code = nullableCode == null ? void 0 : some(nullableCode);
|
|
4143
|
+
if (!(nullableCode == null) && nullableCode === 0) {
|
|
4144
|
+
return guardedResolve({
|
|
4145
|
+
TAG: "Ok",
|
|
4146
|
+
_0: {
|
|
4147
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4148
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8")
|
|
4149
|
+
}
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
4152
|
+
let codeStr = nullableCode == null ? "null" : nullableCode.toString();
|
|
4153
|
+
guardedResolve({
|
|
4154
|
+
TAG: "Error",
|
|
4155
|
+
_0: {
|
|
4156
|
+
code,
|
|
4157
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4158
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4159
|
+
message: `Process exited with code ` + codeStr
|
|
4160
|
+
}
|
|
4161
|
+
});
|
|
4162
|
+
});
|
|
4163
|
+
});
|
|
4164
|
+
}
|
|
4165
|
+
async function execWithOptions(command, options) {
|
|
4166
|
+
let newrecord = { ...options };
|
|
4167
|
+
newrecord.maxBuffer = getOr(options.maxBuffer, 52428800);
|
|
4168
|
+
return await execPromise(command, newrecord);
|
|
4169
|
+
}
|
|
4170
|
+
async function spawnResult(command, args, cwd) {
|
|
4171
|
+
let options_maxBuffer = 52428800;
|
|
4172
|
+
let options = {
|
|
4173
|
+
cwd,
|
|
4174
|
+
maxBuffer: options_maxBuffer
|
|
4175
|
+
};
|
|
4176
|
+
return await spawnPromise(command, args, options);
|
|
4076
4177
|
}
|
|
4077
4178
|
function resolve(sourceRoot, inputPath) {
|
|
4078
4179
|
let normalizedRoot = Nodepath.normalize(sourceRoot);
|
|
@@ -4220,14 +4321,14 @@ function getRipgrepPath() {
|
|
|
4220
4321
|
return;
|
|
4221
4322
|
}
|
|
4222
4323
|
}
|
|
4223
|
-
function buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive,
|
|
4324
|
+
function buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive, literal3, maxResults) {
|
|
4224
4325
|
let args = [];
|
|
4225
4326
|
args.push("-n");
|
|
4226
4327
|
args.push("-H");
|
|
4227
4328
|
if (caseInsensitive) {
|
|
4228
4329
|
args.push("-i");
|
|
4229
4330
|
}
|
|
4230
|
-
if (
|
|
4331
|
+
if (literal3) {
|
|
4231
4332
|
args.push("-F");
|
|
4232
4333
|
}
|
|
4233
4334
|
args.push("-m");
|
|
@@ -4244,7 +4345,7 @@ function buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive, li
|
|
|
4244
4345
|
args.push(searchPath);
|
|
4245
4346
|
return args;
|
|
4246
4347
|
}
|
|
4247
|
-
function buildGitGrepArgs(pattern2, caseInsensitive,
|
|
4348
|
+
function buildGitGrepArgs(pattern2, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4248
4349
|
let args = [
|
|
4249
4350
|
"grep",
|
|
4250
4351
|
"-n",
|
|
@@ -4253,12 +4354,22 @@ function buildGitGrepArgs(pattern2, caseInsensitive, literal2, maxResults) {
|
|
|
4253
4354
|
if (caseInsensitive) {
|
|
4254
4355
|
args.push("-i");
|
|
4255
4356
|
}
|
|
4256
|
-
if (
|
|
4357
|
+
if (literal3) {
|
|
4257
4358
|
args.push("-F");
|
|
4258
4359
|
}
|
|
4259
4360
|
args.push("--max-count");
|
|
4260
4361
|
args.push(maxResults.toString());
|
|
4261
4362
|
args.push(pattern2);
|
|
4363
|
+
let hasPathspec = isSome(glob) || isSome(type_);
|
|
4364
|
+
if (hasPathspec) {
|
|
4365
|
+
args.push("--");
|
|
4366
|
+
if (glob !== void 0) {
|
|
4367
|
+
args.push(glob);
|
|
4368
|
+
}
|
|
4369
|
+
if (type_ !== void 0 && glob === void 0) {
|
|
4370
|
+
args.push(`*.` + type_);
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4262
4373
|
return args;
|
|
4263
4374
|
}
|
|
4264
4375
|
function parseGrepOutput(output, maxResults) {
|
|
@@ -4293,119 +4404,152 @@ function parseGrepOutput(output, maxResults) {
|
|
|
4293
4404
|
});
|
|
4294
4405
|
fileMap[filePath] = matches2;
|
|
4295
4406
|
});
|
|
4296
|
-
let
|
|
4407
|
+
let allFiles = Object.entries(fileMap).map((param) => ({
|
|
4297
4408
|
path: param[0],
|
|
4298
4409
|
matches: param[1]
|
|
4299
|
-
}))
|
|
4410
|
+
}));
|
|
4411
|
+
let totalFiles = allFiles.length;
|
|
4412
|
+
let files = allFiles.slice(0, maxResults);
|
|
4300
4413
|
return {
|
|
4301
4414
|
files,
|
|
4302
4415
|
totalMatches: totalMatches.contents,
|
|
4303
|
-
truncated:
|
|
4416
|
+
truncated: totalFiles > maxResults
|
|
4304
4417
|
};
|
|
4305
4418
|
}
|
|
4306
|
-
async function executeRipgrep(rgPath, pattern2, searchPath, type_, glob, caseInsensitive,
|
|
4307
|
-
let args = buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive,
|
|
4308
|
-
let
|
|
4309
|
-
|
|
4310
|
-
let result = await exec(command);
|
|
4311
|
-
if (result.TAG === "Ok") {
|
|
4312
|
-
return {
|
|
4313
|
-
TAG: "Ok",
|
|
4314
|
-
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4315
|
-
};
|
|
4316
|
-
}
|
|
4317
|
-
let match = result._0;
|
|
4318
|
-
let match$1 = match.code;
|
|
4319
|
-
let exit = 0;
|
|
4320
|
-
if (match$1 !== void 0) {
|
|
4321
|
-
if (match$1 === 1) {
|
|
4322
|
-
return {
|
|
4323
|
-
TAG: "Ok",
|
|
4324
|
-
_0: {
|
|
4325
|
-
files: [],
|
|
4326
|
-
totalMatches: 0,
|
|
4327
|
-
truncated: false
|
|
4328
|
-
}
|
|
4329
|
-
};
|
|
4330
|
-
}
|
|
4331
|
-
exit = 1;
|
|
4332
|
-
} else {
|
|
4333
|
-
exit = 1;
|
|
4334
|
-
}
|
|
4335
|
-
if (exit === 1) {
|
|
4336
|
-
return {
|
|
4337
|
-
TAG: "Error",
|
|
4338
|
-
_0: `Ripgrep failed: ` + match.stderr
|
|
4339
|
-
};
|
|
4340
|
-
}
|
|
4341
|
-
} catch (raw_exn) {
|
|
4342
|
-
let exn = internalToException(raw_exn);
|
|
4343
|
-
let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
|
|
4419
|
+
async function executeRipgrep(rgPath, pattern2, searchPath, type_, glob, caseInsensitive, literal3, maxResults) {
|
|
4420
|
+
let args = buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive, literal3, maxResults);
|
|
4421
|
+
let result = await spawnResult(rgPath, args, void 0);
|
|
4422
|
+
if (result.TAG === "Ok") {
|
|
4344
4423
|
return {
|
|
4345
|
-
TAG: "
|
|
4346
|
-
_0:
|
|
4424
|
+
TAG: "Ok",
|
|
4425
|
+
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4426
|
+
};
|
|
4427
|
+
}
|
|
4428
|
+
let match = result._0;
|
|
4429
|
+
let match$1 = match.code;
|
|
4430
|
+
if (match$1 === 1) {
|
|
4431
|
+
return {
|
|
4432
|
+
TAG: "Ok",
|
|
4433
|
+
_0: {
|
|
4434
|
+
files: [],
|
|
4435
|
+
totalMatches: 0,
|
|
4436
|
+
truncated: false
|
|
4437
|
+
}
|
|
4347
4438
|
};
|
|
4348
4439
|
}
|
|
4440
|
+
let stderr = match.stderr;
|
|
4441
|
+
let detail = stderr === "" ? match.message : stderr;
|
|
4442
|
+
return {
|
|
4443
|
+
TAG: "Error",
|
|
4444
|
+
_0: `Ripgrep failed: ` + detail
|
|
4445
|
+
};
|
|
4349
4446
|
}
|
|
4350
|
-
async function executeGitGrep(pattern2, searchPath, caseInsensitive,
|
|
4351
|
-
let args = buildGitGrepArgs(pattern2, caseInsensitive,
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
TAG: "Ok",
|
|
4369
|
-
_0: {
|
|
4370
|
-
files: [],
|
|
4371
|
-
totalMatches: 0,
|
|
4372
|
-
truncated: false
|
|
4373
|
-
}
|
|
4374
|
-
};
|
|
4447
|
+
async function executeGitGrep(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4448
|
+
let args = buildGitGrepArgs(pattern2, caseInsensitive, literal3, maxResults, glob, type_);
|
|
4449
|
+
let result = await spawnResult("git", args, searchPath);
|
|
4450
|
+
if (result.TAG === "Ok") {
|
|
4451
|
+
return {
|
|
4452
|
+
TAG: "Ok",
|
|
4453
|
+
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4454
|
+
};
|
|
4455
|
+
}
|
|
4456
|
+
let match = result._0;
|
|
4457
|
+
let code = match.code;
|
|
4458
|
+
if (code === 1) {
|
|
4459
|
+
return {
|
|
4460
|
+
TAG: "Ok",
|
|
4461
|
+
_0: {
|
|
4462
|
+
files: [],
|
|
4463
|
+
totalMatches: 0,
|
|
4464
|
+
truncated: false
|
|
4375
4465
|
}
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4466
|
+
};
|
|
4467
|
+
}
|
|
4468
|
+
let stderr = match.stderr;
|
|
4469
|
+
let codeStr = getOr(map(code, (c2) => c2.toString()), "unknown");
|
|
4470
|
+
let detail = stderr === "" ? match.message : stderr;
|
|
4471
|
+
return {
|
|
4472
|
+
TAG: "Error",
|
|
4473
|
+
_0: `Git grep failed (exit ` + codeStr + `): ` + detail
|
|
4474
|
+
};
|
|
4475
|
+
}
|
|
4476
|
+
function buildPlainGrepArgs(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4477
|
+
let args = ["-rn"];
|
|
4478
|
+
if (caseInsensitive) {
|
|
4479
|
+
args.push("-i");
|
|
4480
|
+
}
|
|
4481
|
+
if (literal3) {
|
|
4482
|
+
args.push("-F");
|
|
4483
|
+
}
|
|
4484
|
+
args.push("-m");
|
|
4485
|
+
args.push(maxResults.toString());
|
|
4486
|
+
if (glob !== void 0) {
|
|
4487
|
+
args.push("--include");
|
|
4488
|
+
args.push(glob);
|
|
4489
|
+
} else if (type_ !== void 0) {
|
|
4490
|
+
args.push("--include");
|
|
4491
|
+
args.push(`*.` + type_);
|
|
4492
|
+
}
|
|
4493
|
+
args.push("--exclude-dir=node_modules");
|
|
4494
|
+
args.push("--exclude-dir=.git");
|
|
4495
|
+
args.push("--exclude-dir=dist");
|
|
4496
|
+
args.push("--exclude-dir=build");
|
|
4497
|
+
args.push("--exclude-dir=_build");
|
|
4498
|
+
args.push(pattern2);
|
|
4499
|
+
args.push(searchPath);
|
|
4500
|
+
return args;
|
|
4501
|
+
}
|
|
4502
|
+
async function executePlainGrep(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4503
|
+
let args = buildPlainGrepArgs(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_);
|
|
4504
|
+
let result = await spawnResult("grep", args, void 0);
|
|
4505
|
+
if (result.TAG === "Ok") {
|
|
4389
4506
|
return {
|
|
4390
|
-
TAG: "
|
|
4391
|
-
_0:
|
|
4507
|
+
TAG: "Ok",
|
|
4508
|
+
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4509
|
+
};
|
|
4510
|
+
}
|
|
4511
|
+
let match = result._0;
|
|
4512
|
+
let code = match.code;
|
|
4513
|
+
if (code === 1) {
|
|
4514
|
+
return {
|
|
4515
|
+
TAG: "Ok",
|
|
4516
|
+
_0: {
|
|
4517
|
+
files: [],
|
|
4518
|
+
totalMatches: 0,
|
|
4519
|
+
truncated: false
|
|
4520
|
+
}
|
|
4392
4521
|
};
|
|
4393
4522
|
}
|
|
4523
|
+
let stderr = match.stderr;
|
|
4524
|
+
let codeStr = getOr(map(code, (c2) => c2.toString()), "unknown");
|
|
4525
|
+
let detail = stderr === "" ? match.message : stderr;
|
|
4526
|
+
return {
|
|
4527
|
+
TAG: "Error",
|
|
4528
|
+
_0: `Grep failed (exit ` + codeStr + `): ` + detail
|
|
4529
|
+
};
|
|
4394
4530
|
}
|
|
4395
4531
|
async function execute(ctx2, input) {
|
|
4396
4532
|
let searchPath = resolveSearchPath(ctx2.sourceRoot, input.path);
|
|
4397
4533
|
let caseInsensitive = getOr(input.case_insensitive, false);
|
|
4398
|
-
let
|
|
4399
|
-
let maxResults = getOr(input.max_results,
|
|
4534
|
+
let literal3 = getOr(input.literal, false);
|
|
4535
|
+
let maxResults = getOr(input.max_results, 20);
|
|
4536
|
+
let gitGrepWithFallback = async () => {
|
|
4537
|
+
let gitResult = await executeGitGrep(input.pattern, searchPath, caseInsensitive, literal3, maxResults, input.glob, input.type);
|
|
4538
|
+
if (gitResult.TAG === "Ok") {
|
|
4539
|
+
return gitResult;
|
|
4540
|
+
} else {
|
|
4541
|
+
return await executePlainGrep(input.pattern, searchPath, caseInsensitive, literal3, maxResults, input.glob, input.type);
|
|
4542
|
+
}
|
|
4543
|
+
};
|
|
4400
4544
|
let rgPath = getRipgrepPath();
|
|
4401
4545
|
if (rgPath === void 0) {
|
|
4402
|
-
return await
|
|
4546
|
+
return await gitGrepWithFallback();
|
|
4403
4547
|
}
|
|
4404
|
-
let result = await executeRipgrep(rgPath, input.pattern, searchPath, input.type, input.glob, caseInsensitive,
|
|
4548
|
+
let result = await executeRipgrep(rgPath, input.pattern, searchPath, input.type, input.glob, caseInsensitive, literal3, maxResults);
|
|
4405
4549
|
if (result.TAG === "Ok") {
|
|
4406
4550
|
return result;
|
|
4407
4551
|
} else {
|
|
4408
|
-
return await
|
|
4552
|
+
return await gitGrepWithFallback();
|
|
4409
4553
|
}
|
|
4410
4554
|
}
|
|
4411
4555
|
var name2 = "grep";
|
|
@@ -4722,7 +4866,6 @@ var outputSchema5 = bool2;
|
|
|
4722
4866
|
var inputSchema6 = schema2((s2) => ({
|
|
4723
4867
|
pattern: s2.m(string2),
|
|
4724
4868
|
path: s2.m(option2(string2)),
|
|
4725
|
-
type: s2.m(option2(string2)),
|
|
4726
4869
|
max_results: s2.m(option2(int2))
|
|
4727
4870
|
}));
|
|
4728
4871
|
var outputSchema6 = schema2((s2) => ({
|
|
@@ -4746,56 +4889,38 @@ function buildRipgrepArgs2(searchPath) {
|
|
|
4746
4889
|
args.push(searchPath);
|
|
4747
4890
|
return args;
|
|
4748
4891
|
}
|
|
4749
|
-
function
|
|
4750
|
-
let
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
return fileName2.includes(part);
|
|
4770
|
-
}
|
|
4771
|
-
} else {
|
|
4772
|
-
return false;
|
|
4773
|
-
}
|
|
4774
|
-
});
|
|
4775
|
-
} else {
|
|
4776
|
-
patternMatches = fileName2.includes(patternLower);
|
|
4777
|
-
}
|
|
4778
|
-
let typeMatches;
|
|
4779
|
-
if (type_ !== void 0) {
|
|
4780
|
-
switch (type_) {
|
|
4781
|
-
case "directory":
|
|
4782
|
-
typeMatches = filePath.endsWith("/");
|
|
4783
|
-
break;
|
|
4784
|
-
case "file":
|
|
4785
|
-
typeMatches = !filePath.endsWith("/");
|
|
4786
|
-
break;
|
|
4787
|
-
default:
|
|
4788
|
-
typeMatches = true;
|
|
4892
|
+
function matchesPattern(fileName2, patternLower) {
|
|
4893
|
+
let fileNameLower = fileName2.toLowerCase();
|
|
4894
|
+
if (patternLower === "") {
|
|
4895
|
+
return true;
|
|
4896
|
+
}
|
|
4897
|
+
if (!patternLower.includes("*")) {
|
|
4898
|
+
return fileNameLower.includes(patternLower);
|
|
4899
|
+
}
|
|
4900
|
+
let parts = patternLower.split("*");
|
|
4901
|
+
let partsLength = parts.length;
|
|
4902
|
+
return reduceWithIndex(parts, true, (matches2, part, idx) => {
|
|
4903
|
+
if (matches2) {
|
|
4904
|
+
if (part === "") {
|
|
4905
|
+
return true;
|
|
4906
|
+
} else if (idx === 0) {
|
|
4907
|
+
return fileNameLower.startsWith(part);
|
|
4908
|
+
} else if (idx === (partsLength - 1 | 0)) {
|
|
4909
|
+
return fileNameLower.endsWith(part);
|
|
4910
|
+
} else {
|
|
4911
|
+
return fileNameLower.includes(part);
|
|
4789
4912
|
}
|
|
4790
|
-
} else {
|
|
4791
|
-
typeMatches = true;
|
|
4792
|
-
}
|
|
4793
|
-
if (patternMatches) {
|
|
4794
|
-
return typeMatches;
|
|
4795
4913
|
} else {
|
|
4796
4914
|
return false;
|
|
4797
4915
|
}
|
|
4798
4916
|
});
|
|
4917
|
+
}
|
|
4918
|
+
function filterAndPaginate(lines, pattern2, maxResults) {
|
|
4919
|
+
let patternLower = pattern2.toLowerCase();
|
|
4920
|
+
let matchedFiles = lines.filter((filePath) => {
|
|
4921
|
+
let fileName2 = Nodepath.basename(filePath);
|
|
4922
|
+
return matchesPattern(fileName2, patternLower);
|
|
4923
|
+
});
|
|
4799
4924
|
let truncated = matchedFiles.length > maxResults;
|
|
4800
4925
|
let files = matchedFiles.slice(0, maxResults);
|
|
4801
4926
|
return {
|
|
@@ -4804,113 +4929,67 @@ function parseRipgrepOutput(output, pattern2, type_, maxResults) {
|
|
|
4804
4929
|
truncated
|
|
4805
4930
|
};
|
|
4806
4931
|
}
|
|
4807
|
-
function
|
|
4808
|
-
let lines = output.trim().split("\n").filter((line) => line !== "");
|
|
4809
|
-
let truncated = lines.length > maxResults;
|
|
4810
|
-
let files = lines.slice(0, maxResults);
|
|
4811
|
-
return {
|
|
4812
|
-
files,
|
|
4813
|
-
totalResults: lines.length,
|
|
4814
|
-
truncated
|
|
4815
|
-
};
|
|
4816
|
-
}
|
|
4817
|
-
async function executeRipgrep2(rgPath, pattern2, searchPath, type_, maxResults) {
|
|
4932
|
+
async function executeRipgrep2(rgPath, pattern2, searchPath, maxResults) {
|
|
4818
4933
|
let args = buildRipgrepArgs2(searchPath);
|
|
4819
|
-
let
|
|
4820
|
-
|
|
4821
|
-
let
|
|
4822
|
-
if (result.TAG === "Ok") {
|
|
4823
|
-
return {
|
|
4824
|
-
TAG: "Ok",
|
|
4825
|
-
_0: parseRipgrepOutput(result._0.stdout, pattern2, type_, maxResults)
|
|
4826
|
-
};
|
|
4827
|
-
}
|
|
4828
|
-
let match = result._0;
|
|
4829
|
-
let match$1 = match.code;
|
|
4830
|
-
let exit = 0;
|
|
4831
|
-
if (match$1 !== void 0) {
|
|
4832
|
-
if (match$1 === 1) {
|
|
4833
|
-
return {
|
|
4834
|
-
TAG: "Ok",
|
|
4835
|
-
_0: {
|
|
4836
|
-
files: [],
|
|
4837
|
-
totalResults: 0,
|
|
4838
|
-
truncated: false
|
|
4839
|
-
}
|
|
4840
|
-
};
|
|
4841
|
-
}
|
|
4842
|
-
exit = 1;
|
|
4843
|
-
} else {
|
|
4844
|
-
exit = 1;
|
|
4845
|
-
}
|
|
4846
|
-
if (exit === 1) {
|
|
4847
|
-
return {
|
|
4848
|
-
TAG: "Error",
|
|
4849
|
-
_0: `Ripgrep failed: ` + match.stderr
|
|
4850
|
-
};
|
|
4851
|
-
}
|
|
4852
|
-
} catch (raw_exn) {
|
|
4853
|
-
let exn = internalToException(raw_exn);
|
|
4854
|
-
let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
|
|
4934
|
+
let result = await spawnResult(rgPath, args, void 0);
|
|
4935
|
+
if (result.TAG === "Ok") {
|
|
4936
|
+
let lines = result._0.stdout.trim().split("\n").filter((line) => line !== "");
|
|
4855
4937
|
return {
|
|
4856
|
-
TAG: "
|
|
4857
|
-
_0:
|
|
4938
|
+
TAG: "Ok",
|
|
4939
|
+
_0: filterAndPaginate(lines, pattern2, maxResults)
|
|
4940
|
+
};
|
|
4941
|
+
}
|
|
4942
|
+
let match = result._0;
|
|
4943
|
+
let match$1 = match.code;
|
|
4944
|
+
if (match$1 === 1) {
|
|
4945
|
+
return {
|
|
4946
|
+
TAG: "Ok",
|
|
4947
|
+
_0: {
|
|
4948
|
+
files: [],
|
|
4949
|
+
totalResults: 0,
|
|
4950
|
+
truncated: false
|
|
4951
|
+
}
|
|
4858
4952
|
};
|
|
4859
4953
|
}
|
|
4954
|
+
return {
|
|
4955
|
+
TAG: "Error",
|
|
4956
|
+
_0: `Ripgrep failed: ` + match.stderr
|
|
4957
|
+
};
|
|
4860
4958
|
}
|
|
4861
4959
|
async function executeGitLsFiles(pattern2, searchPath, maxResults) {
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
let
|
|
4865
|
-
cwd: searchPath
|
|
4866
|
-
});
|
|
4867
|
-
if (result.TAG === "Ok") {
|
|
4868
|
-
return {
|
|
4869
|
-
TAG: "Ok",
|
|
4870
|
-
_0: parseGitLsFilesOutput(result._0.stdout, maxResults)
|
|
4871
|
-
};
|
|
4872
|
-
}
|
|
4873
|
-
let match = result._0;
|
|
4874
|
-
let match$1 = match.code;
|
|
4875
|
-
let exit = 0;
|
|
4876
|
-
if (match$1 !== void 0) {
|
|
4877
|
-
if (match$1 === 1) {
|
|
4878
|
-
return {
|
|
4879
|
-
TAG: "Ok",
|
|
4880
|
-
_0: {
|
|
4881
|
-
files: [],
|
|
4882
|
-
totalResults: 0,
|
|
4883
|
-
truncated: false
|
|
4884
|
-
}
|
|
4885
|
-
};
|
|
4886
|
-
}
|
|
4887
|
-
exit = 1;
|
|
4888
|
-
} else {
|
|
4889
|
-
exit = 1;
|
|
4890
|
-
}
|
|
4891
|
-
if (exit === 1) {
|
|
4892
|
-
return {
|
|
4893
|
-
TAG: "Error",
|
|
4894
|
-
_0: `Git ls-files failed: ` + match.stderr
|
|
4895
|
-
};
|
|
4896
|
-
}
|
|
4897
|
-
} catch (raw_exn) {
|
|
4898
|
-
let exn = internalToException(raw_exn);
|
|
4899
|
-
let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
|
|
4960
|
+
let result = await spawnResult("git", ["ls-files"], searchPath);
|
|
4961
|
+
if (result.TAG === "Ok") {
|
|
4962
|
+
let lines = result._0.stdout.trim().split("\n").filter((line) => line !== "");
|
|
4900
4963
|
return {
|
|
4901
|
-
TAG: "
|
|
4902
|
-
_0:
|
|
4964
|
+
TAG: "Ok",
|
|
4965
|
+
_0: filterAndPaginate(lines, pattern2, maxResults)
|
|
4903
4966
|
};
|
|
4904
4967
|
}
|
|
4968
|
+
let match = result._0;
|
|
4969
|
+
let match$1 = match.code;
|
|
4970
|
+
if (match$1 === 1) {
|
|
4971
|
+
return {
|
|
4972
|
+
TAG: "Ok",
|
|
4973
|
+
_0: {
|
|
4974
|
+
files: [],
|
|
4975
|
+
totalResults: 0,
|
|
4976
|
+
truncated: false
|
|
4977
|
+
}
|
|
4978
|
+
};
|
|
4979
|
+
}
|
|
4980
|
+
return {
|
|
4981
|
+
TAG: "Error",
|
|
4982
|
+
_0: `Git ls-files failed: ` + match.stderr
|
|
4983
|
+
};
|
|
4905
4984
|
}
|
|
4906
4985
|
async function execute6(ctx2, input) {
|
|
4907
4986
|
let searchPath = resolveSearchPath(ctx2.sourceRoot, input.path);
|
|
4908
|
-
let maxResults = getOr(input.max_results,
|
|
4987
|
+
let maxResults = getOr(input.max_results, 20);
|
|
4909
4988
|
let rgPath = getRipgrepPath2();
|
|
4910
4989
|
if (rgPath === void 0) {
|
|
4911
4990
|
return await executeGitLsFiles(input.pattern, searchPath, maxResults);
|
|
4912
4991
|
}
|
|
4913
|
-
let result = await executeRipgrep2(rgPath, input.pattern, searchPath,
|
|
4992
|
+
let result = await executeRipgrep2(rgPath, input.pattern, searchPath, maxResults);
|
|
4914
4993
|
if (result.TAG === "Ok") {
|
|
4915
4994
|
return result;
|
|
4916
4995
|
} else {
|
|
@@ -4918,34 +4997,34 @@ async function execute6(ctx2, input) {
|
|
|
4918
4997
|
}
|
|
4919
4998
|
}
|
|
4920
4999
|
var name7 = "search_files";
|
|
4921
|
-
var description6 = `Fast file
|
|
5000
|
+
var description6 = `Fast file name search tool that finds files matching a pattern.
|
|
4922
5001
|
|
|
4923
5002
|
WHEN TO USE THIS TOOL:
|
|
4924
|
-
- Use when you need to find files
|
|
5003
|
+
- Use when you need to find files by name pattern
|
|
4925
5004
|
- Great for locating specific files like "config.json" or "*.test.ts"
|
|
4926
5005
|
- Useful for finding all files with a specific extension or naming convention
|
|
4927
5006
|
- When you need to discover the file structure of a project
|
|
5007
|
+
- Note: this tool only searches file names, not directory names. Use list_files to browse directories.
|
|
4928
5008
|
|
|
4929
5009
|
PARAMETERS:
|
|
4930
5010
|
- pattern (required): The filename pattern to search for (supports glob-like patterns)
|
|
4931
5011
|
- path (optional): Directory to search in (defaults to source root)
|
|
4932
|
-
- type (optional): Filter by type - "file" for files only, "directory" for directories only
|
|
4933
5012
|
- max_results (optional): Maximum number of results to return (default: 20)
|
|
4934
5013
|
|
|
4935
5014
|
EXAMPLES:
|
|
4936
5015
|
- Find all config files: pattern="config"
|
|
4937
5016
|
- Find TypeScript test files: pattern="*.test.ts"
|
|
4938
|
-
- Find directories named "components": pattern="components", type="directory"
|
|
4939
5017
|
- Find files in specific directory: pattern="*.json", path="src/config"
|
|
4940
5018
|
|
|
4941
5019
|
OUTPUT:
|
|
4942
|
-
Returns list of matching file
|
|
5020
|
+
Returns list of matching file paths.
|
|
4943
5021
|
Results are sorted by modification time (newest first).
|
|
4944
5022
|
|
|
4945
5023
|
LIMITATIONS:
|
|
4946
5024
|
- Results limited to max_results (default 20)
|
|
4947
5025
|
- Hidden files (starting with '.') are included
|
|
4948
|
-
- Respects .gitignore when using git ls-files fallback
|
|
5026
|
+
- Respects .gitignore when using git ls-files fallback
|
|
5027
|
+
- Only finds files, not directories`;
|
|
4949
5028
|
var inputSchema7 = schema2((s2) => ({
|
|
4950
5029
|
startPath: s2.m(option2(string2))
|
|
4951
5030
|
}));
|
|
@@ -5331,16 +5410,6 @@ async function handleToolCall(registry, config, req) {
|
|
|
5331
5410
|
status: 400
|
|
5332
5411
|
});
|
|
5333
5412
|
}
|
|
5334
|
-
function toRelativePath2(absolutePath, sourceRoot) {
|
|
5335
|
-
let normalizedRoot = sourceRoot.endsWith("/") ? sourceRoot : sourceRoot + "/";
|
|
5336
|
-
if (absolutePath.startsWith(normalizedRoot)) {
|
|
5337
|
-
return absolutePath.slice(normalizedRoot.length, absolutePath.length);
|
|
5338
|
-
} else if (absolutePath.startsWith(sourceRoot)) {
|
|
5339
|
-
return absolutePath.slice(sourceRoot.length, absolutePath.length);
|
|
5340
|
-
} else {
|
|
5341
|
-
return absolutePath;
|
|
5342
|
-
}
|
|
5343
|
-
}
|
|
5344
5413
|
function corsHeaders() {
|
|
5345
5414
|
return Object.fromEntries([
|
|
5346
5415
|
[
|
|
@@ -5391,7 +5460,7 @@ async function handleResolveSourceLocation(config, req) {
|
|
|
5391
5460
|
parent: void 0
|
|
5392
5461
|
};
|
|
5393
5462
|
let resolved = await Te(sourceLocation);
|
|
5394
|
-
let relativeFile =
|
|
5463
|
+
let relativeFile = toRelativePath(config.sourceRoot, resolved.file);
|
|
5395
5464
|
let responseJson = Object.fromEntries([
|
|
5396
5465
|
[
|
|
5397
5466
|
"componentName",
|
|
@@ -5441,6 +5510,12 @@ async function handleResolveSourceLocation(config, req) {
|
|
|
5441
5510
|
status: 400
|
|
5442
5511
|
});
|
|
5443
5512
|
}
|
|
5513
|
+
var dynamicTypeSchema = union2([
|
|
5514
|
+
literal2("static"),
|
|
5515
|
+
literal2("single"),
|
|
5516
|
+
literal2("rest"),
|
|
5517
|
+
literal2("optional")
|
|
5518
|
+
]);
|
|
5444
5519
|
var inputSchema8 = schema2((s2) => ({
|
|
5445
5520
|
placeholder: s2.m(option2(bool2))
|
|
5446
5521
|
}));
|
|
@@ -5448,34 +5523,22 @@ var pageSchema = schema2((s2) => ({
|
|
|
5448
5523
|
path: s2.m(string2),
|
|
5449
5524
|
file: s2.m(string2),
|
|
5450
5525
|
isDynamic: s2.m(bool2),
|
|
5451
|
-
dynamicType: s2.m(
|
|
5526
|
+
dynamicType: s2.m(dynamicTypeSchema)
|
|
5452
5527
|
}));
|
|
5453
5528
|
var outputSchema8 = array2(pageSchema);
|
|
5454
5529
|
function analyzeDynamicSegment(segment) {
|
|
5455
5530
|
if (segment.startsWith("[[") && segment.endsWith("]]")) {
|
|
5456
|
-
return "
|
|
5531
|
+
return "optional";
|
|
5457
5532
|
} else if (segment.startsWith("[...") && segment.endsWith("]")) {
|
|
5458
|
-
return "
|
|
5533
|
+
return "rest";
|
|
5459
5534
|
} else if (segment.startsWith("[") && segment.endsWith("]")) {
|
|
5460
|
-
return "
|
|
5535
|
+
return "single";
|
|
5461
5536
|
} else {
|
|
5462
|
-
return "
|
|
5463
|
-
}
|
|
5464
|
-
}
|
|
5465
|
-
function dynamicTypeToString(dt) {
|
|
5466
|
-
switch (dt) {
|
|
5467
|
-
case "Static":
|
|
5468
|
-
return "static";
|
|
5469
|
-
case "SingleParam":
|
|
5470
|
-
return "single";
|
|
5471
|
-
case "RestParam":
|
|
5472
|
-
return "rest";
|
|
5473
|
-
case "OptionalParam":
|
|
5474
|
-
return "optional";
|
|
5537
|
+
return "static";
|
|
5475
5538
|
}
|
|
5476
5539
|
}
|
|
5477
5540
|
function isDynamicSegment(segment) {
|
|
5478
|
-
return analyzeDynamicSegment(segment) !== "
|
|
5541
|
+
return analyzeDynamicSegment(segment) !== "static";
|
|
5479
5542
|
}
|
|
5480
5543
|
function fileToRoute(filePath) {
|
|
5481
5544
|
let p2 = filePath.replace(/\.(astro|md|mdx|html)$/, "").replace(/\/index$/, "");
|
|
@@ -5486,71 +5549,81 @@ function fileToRoute(filePath) {
|
|
|
5486
5549
|
}
|
|
5487
5550
|
}
|
|
5488
5551
|
function getMostSignificantDynamicType(segments) {
|
|
5489
|
-
return reduce(segments, "
|
|
5552
|
+
return reduce(segments, "static", (acc, segment) => {
|
|
5490
5553
|
let segType = analyzeDynamicSegment(segment);
|
|
5491
|
-
if (segType === "
|
|
5492
|
-
return "
|
|
5554
|
+
if (segType === "rest") {
|
|
5555
|
+
return "rest";
|
|
5493
5556
|
}
|
|
5494
5557
|
switch (acc) {
|
|
5495
|
-
case "
|
|
5496
|
-
case "
|
|
5558
|
+
case "static":
|
|
5559
|
+
case "single":
|
|
5497
5560
|
break;
|
|
5498
|
-
case "
|
|
5499
|
-
return "
|
|
5500
|
-
case "
|
|
5501
|
-
return "
|
|
5561
|
+
case "rest":
|
|
5562
|
+
return "rest";
|
|
5563
|
+
case "optional":
|
|
5564
|
+
return "optional";
|
|
5502
5565
|
}
|
|
5503
5566
|
switch (segType) {
|
|
5504
|
-
case "
|
|
5505
|
-
if (acc === "
|
|
5506
|
-
return "
|
|
5567
|
+
case "static":
|
|
5568
|
+
if (acc === "static") {
|
|
5569
|
+
return "static";
|
|
5507
5570
|
} else {
|
|
5508
|
-
return "
|
|
5571
|
+
return "single";
|
|
5509
5572
|
}
|
|
5510
|
-
case "
|
|
5511
|
-
return "
|
|
5512
|
-
case "
|
|
5513
|
-
return "
|
|
5573
|
+
case "single":
|
|
5574
|
+
return "single";
|
|
5575
|
+
case "optional":
|
|
5576
|
+
return "optional";
|
|
5514
5577
|
}
|
|
5515
5578
|
});
|
|
5516
5579
|
}
|
|
5517
|
-
async function findPages(baseDir, currentPath, projectRoot) {
|
|
5580
|
+
async function findPages(baseDir, currentPath, projectRoot, sourceRoot) {
|
|
5518
5581
|
let fullPath = Nodepath.join(projectRoot, baseDir, currentPath);
|
|
5519
5582
|
try {
|
|
5520
5583
|
let entries = await Fs2.promises.readdir(fullPath);
|
|
5521
5584
|
return (await Promise.all(entries.map(async (entry) => {
|
|
5522
5585
|
let entryPath = Nodepath.join(fullPath, entry);
|
|
5523
|
-
let stats = await Fs2.promises.
|
|
5586
|
+
let stats = await Fs2.promises.lstat(entryPath);
|
|
5587
|
+
if (stats.isSymbolicLink()) {
|
|
5588
|
+
return [];
|
|
5589
|
+
}
|
|
5524
5590
|
if (stats.isDirectory()) {
|
|
5525
5591
|
if (entry.startsWith("_") || entry === "api" || entry === "components") {
|
|
5526
5592
|
return [];
|
|
5527
5593
|
} else {
|
|
5528
|
-
return await findPages(baseDir, Nodepath.join(currentPath, entry), projectRoot);
|
|
5594
|
+
return await findPages(baseDir, Nodepath.join(currentPath, entry), projectRoot, sourceRoot);
|
|
5529
5595
|
}
|
|
5530
5596
|
}
|
|
5531
5597
|
if (!(entry.endsWith(".astro") || entry.endsWith(".md") || entry.endsWith(".mdx") || entry.endsWith(".html"))) {
|
|
5532
5598
|
return [];
|
|
5533
5599
|
}
|
|
5534
|
-
let
|
|
5535
|
-
let routePath = fileToRoute(
|
|
5536
|
-
let
|
|
5600
|
+
let filePath = Nodepath.join(currentPath, entry);
|
|
5601
|
+
let routePath = fileToRoute(filePath);
|
|
5602
|
+
let filePathNoExt = filePath.replace(/\.(astro|md|mdx|html)$/, "");
|
|
5603
|
+
let segments = filePathNoExt.split("/");
|
|
5537
5604
|
let hasDynamic = segments.some(isDynamicSegment);
|
|
5538
5605
|
let dynType = getMostSignificantDynamicType(segments);
|
|
5606
|
+
let relativeToSourceRoot = toRelativePath(sourceRoot, entryPath);
|
|
5539
5607
|
return [{
|
|
5540
5608
|
path: routePath,
|
|
5541
|
-
file:
|
|
5609
|
+
file: relativeToSourceRoot,
|
|
5542
5610
|
isDynamic: hasDynamic,
|
|
5543
|
-
dynamicType:
|
|
5611
|
+
dynamicType: dynType
|
|
5544
5612
|
}];
|
|
5545
5613
|
}))).flat();
|
|
5546
|
-
} catch (
|
|
5547
|
-
|
|
5614
|
+
} catch (raw_exn) {
|
|
5615
|
+
let exn = internalToException(raw_exn);
|
|
5616
|
+
let msg = getOr(flatMap(fromException(exn), message2), "");
|
|
5617
|
+
if (msg.includes("ENOENT")) {
|
|
5618
|
+
return [];
|
|
5619
|
+
}
|
|
5620
|
+
throw exn;
|
|
5548
5621
|
}
|
|
5549
5622
|
}
|
|
5550
5623
|
async function execute8(ctx2, _input) {
|
|
5551
5624
|
try {
|
|
5552
|
-
let srcPages = await findPages("src/pages", "", ctx2.projectRoot);
|
|
5553
|
-
let rootPages = await findPages("pages", "", ctx2.projectRoot);
|
|
5625
|
+
let srcPages = await findPages("src/pages", "", ctx2.projectRoot, ctx2.sourceRoot);
|
|
5626
|
+
let rootPages = await findPages("pages", "", ctx2.projectRoot, ctx2.sourceRoot);
|
|
5554
5627
|
let allPages = srcPages.concat(rootPages);
|
|
5555
5628
|
return {
|
|
5556
5629
|
TAG: "Ok",
|
|
@@ -5677,8 +5750,8 @@ var collectRequestBody = (async function(req) {
|
|
|
5677
5750
|
for await (const chunk of req) {
|
|
5678
5751
|
chunks.push(chunk);
|
|
5679
5752
|
}
|
|
5680
|
-
const { Buffer:
|
|
5681
|
-
return
|
|
5753
|
+
const { Buffer: Buffer3 } = await import('buffer');
|
|
5754
|
+
return Buffer3.concat(chunks);
|
|
5682
5755
|
});
|
|
5683
5756
|
|
|
5684
5757
|
// src/FrontmanAstro__ViteAdapter.res.mjs
|