@stacksjs/path 0.58.72 → 0.59.1

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
@@ -13,6 +13,8 @@ Easily work with file paths.
13
13
 
14
14
  ```bash
15
15
  bun install -d @stacksjs/path
16
+ # if stacks is installed, you can also use:
17
+ # import path from 'stacks/path'
16
18
  ```
17
19
 
18
20
  Now, you can easily access it in your project:
@@ -53,7 +55,6 @@ For casual chit-chat with others using this package:
53
55
 
54
56
  Many thanks to the following core technologies & people who have contributed to this package:
55
57
 
56
- - [pathe](https://github.com/unjs/pathe)
57
58
  - [Chris Breuer](https://github.com/chrisbbreuer)
58
59
  - [All Contributors](../../contributors)
59
60
 
@@ -0,0 +1,3 @@
1
+ import { path } from './paths';
2
+ export * from './paths';
3
+ export default path;
package/dist/index.js CHANGED
@@ -1,9 +1,25 @@
1
1
  // @bun
2
- // src/index.ts
2
+ // src/paths.ts
3
3
  import process from "process";
4
- import {basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath} from "pathe";
4
+ import os from "os";
5
+ import {
6
+ basename,
7
+ delimiter,
8
+ dirname,
9
+ extname,
10
+ isAbsolute,
11
+ join,
12
+ normalize,
13
+ parse,
14
+ relative,
15
+ resolve,
16
+ sep,
17
+ toNamespacedPath
18
+ } from "path";
19
+ import {runCommandSync} from "@stacksjs/cli";
20
+ import {log} from "@stacksjs/logging";
5
21
  function actionsPath(path) {
6
- return corePath(`actions/src/${path || ""}`);
22
+ return corePath(`actions/${path || ""}`);
7
23
  }
8
24
  function relativeActionsPath(path) {
9
25
  return relative(projectPath(), actionsPath(path));
@@ -222,11 +238,24 @@ function pathPath(path) {
222
238
  function paymentsPath(path) {
223
239
  return corePath(`payments/${path || ""}`);
224
240
  }
225
- function projectPath(filePath = "") {
241
+ function projectPath(filePath = "", options) {
226
242
  let path = process.cwd();
227
243
  while (path.includes("storage"))
228
244
  path = resolve(path, "..");
229
- return resolve(path, filePath);
245
+ const finalPath = resolve(path, filePath);
246
+ if (options?.relative)
247
+ return relative(process.cwd(), finalPath);
248
+ return finalPath;
249
+ }
250
+ async function findProjectPath(project) {
251
+ const projectList = await runCommandSync("buddy projects:list --quiet");
252
+ log.debug("ProjectList in findProjectPath", projectList);
253
+ const projects = projectList.split("\n").filter((line) => line.startsWith(" - ")).map((line) => line.trim().substring(4));
254
+ log.debug("Projects in findProjectPath:", projects);
255
+ const projectPath2 = projects.find((proj) => proj.includes(project));
256
+ if (!projectPath2)
257
+ throw new Error(`Could not find project with name: ${project}`);
258
+ return projectPath2.startsWith("/") ? projectPath2 : `/${projectPath2}`;
230
259
  }
231
260
  function projectConfigPath(path) {
232
261
  return projectPath(`config/${path || ""}`);
@@ -249,7 +278,10 @@ function queuePath(path) {
249
278
  function realtimePath(path) {
250
279
  return corePath(`realtime/${path || ""}`);
251
280
  }
252
- function resourcesPath(path) {
281
+ function resourcesPath(path, options) {
282
+ const absolutePath = projectStoragePath(`resources/${path || ""}`);
283
+ if (options?.relative)
284
+ return relative(process.cwd(), absolutePath);
253
285
  return projectPath(`resources/${path || ""}`);
254
286
  }
255
287
  function replPath(path) {
@@ -276,9 +308,6 @@ function scriptsPath(path) {
276
308
  function schedulerPath(path) {
277
309
  return corePath(`scheduler/${path || ""}`);
278
310
  }
279
- function signalsPath(path) {
280
- return corePath(`signals/${path || ""}`);
281
- }
282
311
  function slugPath(path) {
283
312
  return corePath(`slug/${path || ""}`);
284
313
  }
@@ -303,6 +332,9 @@ function serverlessPath(path) {
303
332
  function stacksPath(path) {
304
333
  return frameworkPath(`src/${path || ""}`);
305
334
  }
335
+ function shellPath(path) {
336
+ return corePath(`shell/${path || ""}`);
337
+ }
306
338
  function stringsPath(path) {
307
339
  return corePath(`strings/${path || ""}`);
308
340
  }
@@ -333,6 +365,9 @@ function vitePath(path) {
333
365
  function xRayPath(path) {
334
366
  return frameworkPath(`stacks/x-ray/${path || ""}`);
335
367
  }
368
+ function homeDir(path) {
369
+ return os.homedir() + (path ? (path.startsWith("/") ? "" : "/") + path : "~");
370
+ }
336
371
  var path = {
337
372
  actionsPath,
338
373
  userActionsPath,
@@ -396,6 +431,7 @@ var path = {
396
431
  pathPath,
397
432
  paymentsPath,
398
433
  projectPath,
434
+ findProjectPath,
399
435
  projectStoragePath,
400
436
  publicPath,
401
437
  pushPath,
@@ -411,7 +447,6 @@ var path = {
411
447
  schedulerPath,
412
448
  settingsPath,
413
449
  smsPath,
414
- signalsPath,
415
450
  slugPath,
416
451
  scriptsPath,
417
452
  securityPath,
@@ -419,6 +454,7 @@ var path = {
419
454
  serverlessPath,
420
455
  stacksPath,
421
456
  stringsPath,
457
+ shellPath,
422
458
  storesPath,
423
459
  testingPath,
424
460
  testsPath,
@@ -435,21 +471,23 @@ var path = {
435
471
  validationPath,
436
472
  vitePath,
437
473
  xRayPath,
474
+ homeDir,
438
475
  basename,
439
476
  delimiter,
440
477
  dirname,
441
478
  extname,
442
- format,
443
479
  isAbsolute,
444
480
  join,
445
481
  normalize,
446
- normalizeString,
447
- parse,
448
482
  relative,
449
483
  resolve,
484
+ parse,
450
485
  sep,
451
486
  toNamespacedPath
452
487
  };
488
+
489
+ // src/index.ts
490
+ var src_default = path;
453
491
  export {
454
492
  xRayPath,
455
493
  vitePath,
@@ -475,7 +513,7 @@ export {
475
513
  stacksPath,
476
514
  smsPath,
477
515
  slugPath,
478
- signalsPath,
516
+ shellPath,
479
517
  settingsPath,
480
518
  serverlessPath,
481
519
  serverPath,
@@ -503,13 +541,11 @@ export {
503
541
  paymentsPath,
504
542
  pathPath,
505
543
  path,
506
- parse,
507
544
  packageJsonPath,
508
545
  ormPath,
509
546
  onboardingPath,
510
547
  objectsPath,
511
548
  notificationsPath,
512
- normalizeString,
513
549
  normalize,
514
550
  modulesPath,
515
551
  modelsPath,
@@ -525,12 +561,13 @@ export {
525
561
  join,
526
562
  jobsPath,
527
563
  isAbsolute,
564
+ homeDir,
528
565
  healthPath,
529
566
  gitPath,
530
567
  functionsPath,
531
568
  frameworkPath,
532
569
  frameworkCloudPath,
533
- format,
570
+ findProjectPath,
534
571
  fakerPath,
535
572
  extname,
536
573
  examplesPath,
@@ -545,6 +582,7 @@ export {
545
582
  developmentPath,
546
583
  desktopPath,
547
584
  delimiter,
585
+ src_default as default,
548
586
  datetimePath,
549
587
  databasePath,
550
588
  customElementsDataPath,