staklink 0.3.36 → 0.3.38

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/README.md CHANGED
@@ -10,14 +10,25 @@ npx -y staklink@latest start
10
10
 
11
11
  ### local cli testing
12
12
 
13
+ ```sh
13
14
  pm2 stop all
14
15
  pm2 delete all
16
+ pm2 flush
17
+ rm ~/.pm2/logs/*.log
15
18
 
16
19
  yarn build:cli
17
20
  yarn build:proxy
18
21
 
19
22
  node bin/staklink.cjs start
20
23
 
24
+ ```
25
+
26
+ cat /Users/evanfeenstra/.pm2/logs/staklink-proxy-out-0.log
27
+
28
+ ```sh
29
+ rm ~/.pm2/logs/*.log
30
+ ```
31
+
21
32
  ## processes
22
33
 
23
34
  There are 2 ways to configure your dev processes (like your backend, frontend, db, etc)
@@ -48423,10 +48423,15 @@ async function findAndLoadPm2Config(workspaceRoot2, log_cb) {
48423
48423
  }
48424
48424
  async function findPm2Config(workspaceRoot2, log_cb) {
48425
48425
  log_cb?.(`Searching for PM2 config in workspace: ${workspaceRoot2}`);
48426
+ const configFilenames = ["pm2.config.js", "pm2.config.cjs"];
48426
48427
  const configPaths = [
48427
- "/workspaces/.pod-config/.user-dockerfile/pm2.config.js",
48428
- path.join(workspaceRoot2, "pm2.config.js"),
48429
- path.join(workspaceRoot2, ".devcontainer", "pm2.config.js")
48428
+ ...configFilenames.map(
48429
+ (filename) => `/workspaces/.pod-config/.user-dockerfile/${filename}`
48430
+ ),
48431
+ ...configFilenames.map((filename) => path.join(workspaceRoot2, filename)),
48432
+ ...configFilenames.map(
48433
+ (filename) => path.join(workspaceRoot2, ".devcontainer", filename)
48434
+ )
48430
48435
  ];
48431
48436
  try {
48432
48437
  const subdirs = await fs2.readdir(workspaceRoot2, {
@@ -48434,10 +48439,12 @@ async function findPm2Config(workspaceRoot2, log_cb) {
48434
48439
  });
48435
48440
  const repoDirs = subdirs.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
48436
48441
  for (const repoDir of repoDirs) {
48437
- configPaths.push(
48438
- path.join(workspaceRoot2, repoDir, "pm2.config.js"),
48439
- path.join(workspaceRoot2, repoDir, ".devcontainer", "pm2.config.js")
48440
- );
48442
+ for (const filename of configFilenames) {
48443
+ configPaths.push(
48444
+ path.join(workspaceRoot2, repoDir, filename),
48445
+ path.join(workspaceRoot2, repoDir, ".devcontainer", filename)
48446
+ );
48447
+ }
48441
48448
  }
48442
48449
  } catch (error82) {
48443
48450
  console.log("Error reading workspace directories:", error82);
@@ -48454,7 +48461,16 @@ async function findPm2Config(workspaceRoot2, log_cb) {
48454
48461
  }
48455
48462
  async function loadPm2Config(configPath) {
48456
48463
  try {
48457
- const configContent = await fs2.readFile(configPath, "utf8");
48464
+ let configContent = await fs2.readFile(configPath, "utf8");
48465
+ configContent = configContent.replace(
48466
+ /export\s+default\s+/g,
48467
+ "module.exports = "
48468
+ );
48469
+ configContent = configContent.replace(
48470
+ /export\s*{([^}]*)as\s+default\s*}/g,
48471
+ "module.exports = $1"
48472
+ );
48473
+ configContent = configContent.replace(/export\s+/g, "");
48458
48474
  const moduleContext = { exports: {}, module: { exports: {} } };
48459
48475
  const configFunction = new Function("module", "exports", configContent);
48460
48476
  configFunction(moduleContext.module, moduleContext.exports);
@@ -48608,7 +48624,9 @@ var Runner = class {
48608
48624
  for (const app of config3.apps || []) {
48609
48625
  const processConfig = this.parseProcessApp(app);
48610
48626
  if (processConfig.rebuildCommand) {
48611
- this.log_cb(`\u{1F527} Rebuilding ${processConfig.name}...`);
48627
+ this.log_cb(
48628
+ `\u{1F527} Rebuilding ${processConfig.name}: ${processConfig.rebuildCommand}`
48629
+ );
48612
48630
  try {
48613
48631
  const { stdout, stderr } = await this.executeCommand(
48614
48632
  processConfig.rebuildCommand,
@@ -48632,7 +48650,9 @@ var Runner = class {
48632
48650
  for (const app of config3.apps || []) {
48633
48651
  const processConfig = this.parseProcessApp(app);
48634
48652
  if (processConfig.installCommand) {
48635
- this.log_cb(`\u{1F4E6} Installing dependencies for ${processConfig.name}...`);
48653
+ this.log_cb(
48654
+ `\u{1F4E6} Installing dependencies for ${processConfig.name}: ${processConfig.installCommand}`
48655
+ );
48636
48656
  try {
48637
48657
  const { stdout, stderr } = await this.executeCommand(
48638
48658
  processConfig.installCommand,
@@ -48651,7 +48671,9 @@ var Runner = class {
48651
48671
  for (const app of config3.apps || []) {
48652
48672
  const processConfig = this.parseProcessApp(app);
48653
48673
  if (processConfig.preRunCommand) {
48654
- this.log_cb(`\u{1F680} Running pre-run command for ${processConfig.name}...`);
48674
+ this.log_cb(
48675
+ `\u{1F680} Running pre-run command for ${processConfig.name}: ${processConfig.preRunCommand}`
48676
+ );
48655
48677
  try {
48656
48678
  await this.executeCommand(
48657
48679
  processConfig.preRunCommand,
@@ -48671,7 +48693,9 @@ var Runner = class {
48671
48693
  for (const app of config3.apps || []) {
48672
48694
  const processConfig = this.parseProcessApp(app);
48673
48695
  if (processConfig.postRunCommand) {
48674
- this.log_cb(`\u{1F680} Running post-run command for ${processConfig.name}...`);
48696
+ this.log_cb(
48697
+ `\u{1F680} Running post-run command for ${processConfig.name}: ${processConfig.postRunCommand}`
48698
+ );
48675
48699
  try {
48676
48700
  await this.executeCommand(
48677
48701
  processConfig.postRunCommand,
@@ -48693,7 +48717,9 @@ var Runner = class {
48693
48717
  for (const app of config3.apps || []) {
48694
48718
  const processConfig = this.parseProcessApp(app);
48695
48719
  if (processConfig.resetCommand) {
48696
- this.log_cb(`\u{1F504} Running reset command for ${processConfig.name}...`);
48720
+ this.log_cb(
48721
+ `\u{1F504} Running reset command for ${processConfig.name}: ${processConfig.resetCommand}`
48722
+ );
48697
48723
  try {
48698
48724
  await this.executeCommand(
48699
48725
  processConfig.resetCommand,
@@ -48714,7 +48740,9 @@ var Runner = class {
48714
48740
  for (const app of config3.apps || []) {
48715
48741
  const processConfig = this.parseProcessApp(app);
48716
48742
  if (processConfig.buildCommand) {
48717
- this.log_cb(`\u{1F528} Running build command for ${processConfig.name}...`);
48743
+ this.log_cb(
48744
+ `\u{1F528} Running build command for ${processConfig.name}: ${processConfig.buildCommand}`
48745
+ );
48718
48746
  let is_next = false;
48719
48747
  if (processConfig.cwd) {
48720
48748
  const proj = detectProject(processConfig.cwd);
@@ -48752,7 +48780,9 @@ var Runner = class {
48752
48780
  for (const app of config3.apps || []) {
48753
48781
  const processConfig = this.parseProcessApp(app);
48754
48782
  if (processConfig.testCommand) {
48755
- this.log_cb(`\u{1F9EA} Running test command for ${processConfig.name}...`);
48783
+ this.log_cb(
48784
+ `\u{1F9EA} Running test command for ${processConfig.name}: ${processConfig.testCommand}`
48785
+ );
48756
48786
  try {
48757
48787
  const { stdout, stderr } = await this.executeCommand(
48758
48788
  processConfig.testCommand,
@@ -48778,7 +48808,9 @@ var Runner = class {
48778
48808
  for (const app of config3.apps || []) {
48779
48809
  const processConfig = this.parseProcessApp(app);
48780
48810
  if (processConfig.e2eTestCommand) {
48781
- this.log_cb(`\u{1F3AD} Running E2E test command for ${processConfig.name}...`);
48811
+ this.log_cb(
48812
+ `\u{1F3AD} Running E2E test command for ${processConfig.name}: ${processConfig.e2eTestCommand}`
48813
+ );
48782
48814
  const isPlaywright = processConfig.e2eTestCommand === "npx playwright test" || processConfig.e2eTestCommand === "npx -y playwright test";
48783
48815
  const cmd = isPlaywright && test_name ? `${processConfig.e2eTestCommand} ${test_name}` : processConfig.e2eTestCommand;
48784
48816
  try {
@@ -48900,8 +48932,8 @@ var Runner = class {
48900
48932
  await this.pm2.stopAll();
48901
48933
  this.log_cb("\u{1F6D1} Stopped all processes.");
48902
48934
  }
48903
- async pm2Logs() {
48904
- return await this.pm2.logs();
48935
+ async pm2Logs(lines) {
48936
+ return await this.pm2.logs(void 0, lines || 100);
48905
48937
  }
48906
48938
  async list() {
48907
48939
  try {
@@ -48932,9 +48964,9 @@ var Runner = class {
48932
48964
  * Get logs for a specific process
48933
48965
  * @param processName Name of the process to get logs for
48934
48966
  */
48935
- async getProcessLogs(processName) {
48967
+ async getProcessLogs(processName, lines = 100) {
48936
48968
  try {
48937
- const logs = await this.pm2.logs(processName);
48969
+ const logs = await this.pm2.logs(processName, lines);
48938
48970
  return logs;
48939
48971
  } catch (error82) {
48940
48972
  this.log_cb(`\u274C Failed to get logs for ${processName}: ${error82}`);
@@ -49129,7 +49161,6 @@ async function findRepoLocation(repoFullName) {
49129
49161
  }
49130
49162
  return null;
49131
49163
  } catch (readdirError) {
49132
- console.warn("Could not read /workspaces directory:", readdirError);
49133
49164
  return null;
49134
49165
  }
49135
49166
  } catch (error82) {
@@ -56419,7 +56450,7 @@ var SSEManager = class {
56419
56450
  var sseManager = new SSEManager();
56420
56451
 
56421
56452
  // src/proxy/version.ts
56422
- var VERSION = "0.3.36";
56453
+ var VERSION = "0.3.38";
56423
56454
 
56424
56455
  // node_modules/uuid/dist/esm/stringify.js
56425
56456
  var byteToHex = [];
@@ -56638,7 +56669,7 @@ function createGooseConfig() {
56638
56669
  fs9.writeFileSync(configPath, configContent, "utf-8");
56639
56670
  console.log(`Created goose config at ${configPath}`);
56640
56671
  } catch (error82) {
56641
- console.error("Error creating goose config:", error82);
56672
+ console.warn("Error creating goose config:", error82);
56642
56673
  }
56643
56674
  }
56644
56675
  async function runGooseWeb(apiKey, cwd, port) {
@@ -102812,6 +102843,7 @@ async function cleanupConfig(configState) {
102812
102843
  }
102813
102844
  }
102814
102845
  async function runPlaywrightTestWithVideo(options) {
102846
+ console.log("=== Running Playwright test with video:", options);
102815
102847
  const { repoName, testFilePath, responseUrl } = options;
102816
102848
  let configState = null;
102817
102849
  console.log(
@@ -103050,7 +103082,8 @@ async function startProxyServer() {
103050
103082
  app.get("/logs", async (req, res) => {
103051
103083
  console.log("===> GET logs");
103052
103084
  const r = await newRunner();
103053
- const logs = await r.pm2Logs();
103085
+ const lines = Number(req.query.lines) || 100;
103086
+ const logs = await r.pm2Logs(lines);
103054
103087
  res.send(logs);
103055
103088
  });
103056
103089
  app.get("/logs/:appName", async (req, res) => {
@@ -103058,7 +103091,8 @@ async function startProxyServer() {
103058
103091
  const appName = req.params.appName;
103059
103092
  const r = await newRunner();
103060
103093
  try {
103061
- const logs = await r.getProcessLogs(appName);
103094
+ const lines = Number(req.query.lines) || 100;
103095
+ const logs = await r.getProcessLogs(appName, lines);
103062
103096
  res.send(logs);
103063
103097
  } catch (error82) {
103064
103098
  console.error(`Error fetching logs for ${appName}:`, error82);
@@ -103365,8 +103399,13 @@ ${diff.trim()}`);
103365
103399
  }
103366
103400
  if (autoMerge) {
103367
103401
  try {
103368
- console.log(`=> Waiting for CI checks to appear for PR #${prNumber}...`);
103369
- const hasChecks = await gh.waitForChecksToExist(prNumber, 3e4);
103402
+ console.log(
103403
+ `=> Waiting for CI checks to appear for PR #${prNumber}...`
103404
+ );
103405
+ const hasChecks = await gh.waitForChecksToExist(
103406
+ prNumber,
103407
+ 3e4
103408
+ );
103370
103409
  if (hasChecks) {
103371
103410
  console.log(`=> Enabling auto-merge for PR #${prNumber}...`);
103372
103411
  await gh.mergePR(prNumber, {
@@ -103376,7 +103415,9 @@ ${diff.trim()}`);
103376
103415
  });
103377
103416
  console.log(`=> Auto-merge enabled for PR #${prNumber}`);
103378
103417
  } else {
103379
- console.log(`=> No CI checks found, skipping auto-merge for PR #${prNumber}`);
103418
+ console.log(
103419
+ `=> No CI checks found, skipping auto-merge for PR #${prNumber}`
103420
+ );
103380
103421
  }
103381
103422
  } catch (autoMergeError) {
103382
103423
  console.error(
@@ -3919,10 +3919,15 @@ async function findAndLoadPm2Config(workspaceRoot2, log_cb) {
3919
3919
  }
3920
3920
  async function findPm2Config(workspaceRoot2, log_cb) {
3921
3921
  log_cb?.(`Searching for PM2 config in workspace: ${workspaceRoot2}`);
3922
+ const configFilenames = ["pm2.config.js", "pm2.config.cjs"];
3922
3923
  const configPaths = [
3923
- "/workspaces/.pod-config/.user-dockerfile/pm2.config.js",
3924
- path.join(workspaceRoot2, "pm2.config.js"),
3925
- path.join(workspaceRoot2, ".devcontainer", "pm2.config.js")
3924
+ ...configFilenames.map(
3925
+ (filename) => `/workspaces/.pod-config/.user-dockerfile/${filename}`
3926
+ ),
3927
+ ...configFilenames.map((filename) => path.join(workspaceRoot2, filename)),
3928
+ ...configFilenames.map(
3929
+ (filename) => path.join(workspaceRoot2, ".devcontainer", filename)
3930
+ )
3926
3931
  ];
3927
3932
  try {
3928
3933
  const subdirs = await fs2.readdir(workspaceRoot2, {
@@ -3930,10 +3935,12 @@ async function findPm2Config(workspaceRoot2, log_cb) {
3930
3935
  });
3931
3936
  const repoDirs = subdirs.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
3932
3937
  for (const repoDir of repoDirs) {
3933
- configPaths.push(
3934
- path.join(workspaceRoot2, repoDir, "pm2.config.js"),
3935
- path.join(workspaceRoot2, repoDir, ".devcontainer", "pm2.config.js")
3936
- );
3938
+ for (const filename of configFilenames) {
3939
+ configPaths.push(
3940
+ path.join(workspaceRoot2, repoDir, filename),
3941
+ path.join(workspaceRoot2, repoDir, ".devcontainer", filename)
3942
+ );
3943
+ }
3937
3944
  }
3938
3945
  } catch (error) {
3939
3946
  console.log("Error reading workspace directories:", error);
@@ -3950,7 +3957,16 @@ async function findPm2Config(workspaceRoot2, log_cb) {
3950
3957
  }
3951
3958
  async function loadPm2Config(configPath) {
3952
3959
  try {
3953
- const configContent = await fs2.readFile(configPath, "utf8");
3960
+ let configContent = await fs2.readFile(configPath, "utf8");
3961
+ configContent = configContent.replace(
3962
+ /export\s+default\s+/g,
3963
+ "module.exports = "
3964
+ );
3965
+ configContent = configContent.replace(
3966
+ /export\s*{([^}]*)as\s+default\s*}/g,
3967
+ "module.exports = $1"
3968
+ );
3969
+ configContent = configContent.replace(/export\s+/g, "");
3954
3970
  const moduleContext = { exports: {}, module: { exports: {} } };
3955
3971
  const configFunction = new Function("module", "exports", configContent);
3956
3972
  configFunction(moduleContext.module, moduleContext.exports);
@@ -4083,7 +4099,9 @@ var Runner = class {
4083
4099
  for (const app of config.apps || []) {
4084
4100
  const processConfig = this.parseProcessApp(app);
4085
4101
  if (processConfig.rebuildCommand) {
4086
- this.log_cb(`\u{1F527} Rebuilding ${processConfig.name}...`);
4102
+ this.log_cb(
4103
+ `\u{1F527} Rebuilding ${processConfig.name}: ${processConfig.rebuildCommand}`
4104
+ );
4087
4105
  try {
4088
4106
  const { stdout, stderr } = await this.executeCommand(
4089
4107
  processConfig.rebuildCommand,
@@ -4107,7 +4125,9 @@ var Runner = class {
4107
4125
  for (const app of config.apps || []) {
4108
4126
  const processConfig = this.parseProcessApp(app);
4109
4127
  if (processConfig.installCommand) {
4110
- this.log_cb(`\u{1F4E6} Installing dependencies for ${processConfig.name}...`);
4128
+ this.log_cb(
4129
+ `\u{1F4E6} Installing dependencies for ${processConfig.name}: ${processConfig.installCommand}`
4130
+ );
4111
4131
  try {
4112
4132
  const { stdout, stderr } = await this.executeCommand(
4113
4133
  processConfig.installCommand,
@@ -4126,7 +4146,9 @@ var Runner = class {
4126
4146
  for (const app of config.apps || []) {
4127
4147
  const processConfig = this.parseProcessApp(app);
4128
4148
  if (processConfig.preRunCommand) {
4129
- this.log_cb(`\u{1F680} Running pre-run command for ${processConfig.name}...`);
4149
+ this.log_cb(
4150
+ `\u{1F680} Running pre-run command for ${processConfig.name}: ${processConfig.preRunCommand}`
4151
+ );
4130
4152
  try {
4131
4153
  await this.executeCommand(
4132
4154
  processConfig.preRunCommand,
@@ -4146,7 +4168,9 @@ var Runner = class {
4146
4168
  for (const app of config.apps || []) {
4147
4169
  const processConfig = this.parseProcessApp(app);
4148
4170
  if (processConfig.postRunCommand) {
4149
- this.log_cb(`\u{1F680} Running post-run command for ${processConfig.name}...`);
4171
+ this.log_cb(
4172
+ `\u{1F680} Running post-run command for ${processConfig.name}: ${processConfig.postRunCommand}`
4173
+ );
4150
4174
  try {
4151
4175
  await this.executeCommand(
4152
4176
  processConfig.postRunCommand,
@@ -4168,7 +4192,9 @@ var Runner = class {
4168
4192
  for (const app of config.apps || []) {
4169
4193
  const processConfig = this.parseProcessApp(app);
4170
4194
  if (processConfig.resetCommand) {
4171
- this.log_cb(`\u{1F504} Running reset command for ${processConfig.name}...`);
4195
+ this.log_cb(
4196
+ `\u{1F504} Running reset command for ${processConfig.name}: ${processConfig.resetCommand}`
4197
+ );
4172
4198
  try {
4173
4199
  await this.executeCommand(
4174
4200
  processConfig.resetCommand,
@@ -4189,7 +4215,9 @@ var Runner = class {
4189
4215
  for (const app of config.apps || []) {
4190
4216
  const processConfig = this.parseProcessApp(app);
4191
4217
  if (processConfig.buildCommand) {
4192
- this.log_cb(`\u{1F528} Running build command for ${processConfig.name}...`);
4218
+ this.log_cb(
4219
+ `\u{1F528} Running build command for ${processConfig.name}: ${processConfig.buildCommand}`
4220
+ );
4193
4221
  let is_next = false;
4194
4222
  if (processConfig.cwd) {
4195
4223
  const proj = detectProject(processConfig.cwd);
@@ -4227,7 +4255,9 @@ var Runner = class {
4227
4255
  for (const app of config.apps || []) {
4228
4256
  const processConfig = this.parseProcessApp(app);
4229
4257
  if (processConfig.testCommand) {
4230
- this.log_cb(`\u{1F9EA} Running test command for ${processConfig.name}...`);
4258
+ this.log_cb(
4259
+ `\u{1F9EA} Running test command for ${processConfig.name}: ${processConfig.testCommand}`
4260
+ );
4231
4261
  try {
4232
4262
  const { stdout, stderr } = await this.executeCommand(
4233
4263
  processConfig.testCommand,
@@ -4253,7 +4283,9 @@ var Runner = class {
4253
4283
  for (const app of config.apps || []) {
4254
4284
  const processConfig = this.parseProcessApp(app);
4255
4285
  if (processConfig.e2eTestCommand) {
4256
- this.log_cb(`\u{1F3AD} Running E2E test command for ${processConfig.name}...`);
4286
+ this.log_cb(
4287
+ `\u{1F3AD} Running E2E test command for ${processConfig.name}: ${processConfig.e2eTestCommand}`
4288
+ );
4257
4289
  const isPlaywright = processConfig.e2eTestCommand === "npx playwright test" || processConfig.e2eTestCommand === "npx -y playwright test";
4258
4290
  const cmd = isPlaywright && test_name ? `${processConfig.e2eTestCommand} ${test_name}` : processConfig.e2eTestCommand;
4259
4291
  try {
@@ -4375,8 +4407,8 @@ var Runner = class {
4375
4407
  await this.pm2.stopAll();
4376
4408
  this.log_cb("\u{1F6D1} Stopped all processes.");
4377
4409
  }
4378
- async pm2Logs() {
4379
- return await this.pm2.logs();
4410
+ async pm2Logs(lines) {
4411
+ return await this.pm2.logs(void 0, lines || 100);
4380
4412
  }
4381
4413
  async list() {
4382
4414
  try {
@@ -4407,9 +4439,9 @@ var Runner = class {
4407
4439
  * Get logs for a specific process
4408
4440
  * @param processName Name of the process to get logs for
4409
4441
  */
4410
- async getProcessLogs(processName) {
4442
+ async getProcessLogs(processName, lines = 100) {
4411
4443
  try {
4412
- const logs = await this.pm2.logs(processName);
4444
+ const logs = await this.pm2.logs(processName, lines);
4413
4445
  return logs;
4414
4446
  } catch (error) {
4415
4447
  this.log_cb(`\u274C Failed to get logs for ${processName}: ${error}`);
@@ -10906,7 +10938,7 @@ var glob = Object.assign(glob_, {
10906
10938
  glob.glob = glob;
10907
10939
 
10908
10940
  // src/proxy/version.ts
10909
- var VERSION = "0.3.36";
10941
+ var VERSION = "0.3.38";
10910
10942
 
10911
10943
  // src/cli.ts
10912
10944
  var STAKLINK_PROXY = "staklink-proxy";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "staklink",
3
3
  "displayName": "staklink",
4
4
  "description": "staklink process manager",
5
- "version": "0.3.36",
5
+ "version": "0.3.38",
6
6
  "type": "module",
7
7
  "publisher": "stakwork",
8
8
  "engines": {