@stacksjs/path 0.58.73 → 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,10 +1,25 @@
1
1
  // @bun
2
- // src/index.ts
2
+ // src/paths.ts
3
3
  import process from "process";
4
4
  import os from "os";
5
- import {basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath} from "pathe";
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";
6
21
  function actionsPath(path) {
7
- return corePath(`actions/src/${path || ""}`);
22
+ return corePath(`actions/${path || ""}`);
8
23
  }
9
24
  function relativeActionsPath(path) {
10
25
  return relative(projectPath(), actionsPath(path));
@@ -223,11 +238,24 @@ function pathPath(path) {
223
238
  function paymentsPath(path) {
224
239
  return corePath(`payments/${path || ""}`);
225
240
  }
226
- function projectPath(filePath = "") {
241
+ function projectPath(filePath = "", options) {
227
242
  let path = process.cwd();
228
243
  while (path.includes("storage"))
229
244
  path = resolve(path, "..");
230
- 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}`;
231
259
  }
232
260
  function projectConfigPath(path) {
233
261
  return projectPath(`config/${path || ""}`);
@@ -280,9 +308,6 @@ function scriptsPath(path) {
280
308
  function schedulerPath(path) {
281
309
  return corePath(`scheduler/${path || ""}`);
282
310
  }
283
- function signalsPath(path) {
284
- return corePath(`signals/${path || ""}`);
285
- }
286
311
  function slugPath(path) {
287
312
  return corePath(`slug/${path || ""}`);
288
313
  }
@@ -406,6 +431,7 @@ var path = {
406
431
  pathPath,
407
432
  paymentsPath,
408
433
  projectPath,
434
+ findProjectPath,
409
435
  projectStoragePath,
410
436
  publicPath,
411
437
  pushPath,
@@ -421,7 +447,6 @@ var path = {
421
447
  schedulerPath,
422
448
  settingsPath,
423
449
  smsPath,
424
- signalsPath,
425
450
  slugPath,
426
451
  scriptsPath,
427
452
  securityPath,
@@ -451,17 +476,18 @@ var path = {
451
476
  delimiter,
452
477
  dirname,
453
478
  extname,
454
- format,
455
479
  isAbsolute,
456
480
  join,
457
481
  normalize,
458
- normalizeString,
459
- parse,
460
482
  relative,
461
483
  resolve,
484
+ parse,
462
485
  sep,
463
486
  toNamespacedPath
464
487
  };
488
+
489
+ // src/index.ts
490
+ var src_default = path;
465
491
  export {
466
492
  xRayPath,
467
493
  vitePath,
@@ -487,7 +513,6 @@ export {
487
513
  stacksPath,
488
514
  smsPath,
489
515
  slugPath,
490
- signalsPath,
491
516
  shellPath,
492
517
  settingsPath,
493
518
  serverlessPath,
@@ -516,13 +541,11 @@ export {
516
541
  paymentsPath,
517
542
  pathPath,
518
543
  path,
519
- parse,
520
544
  packageJsonPath,
521
545
  ormPath,
522
546
  onboardingPath,
523
547
  objectsPath,
524
548
  notificationsPath,
525
- normalizeString,
526
549
  normalize,
527
550
  modulesPath,
528
551
  modelsPath,
@@ -544,7 +567,7 @@ export {
544
567
  functionsPath,
545
568
  frameworkPath,
546
569
  frameworkCloudPath,
547
- format,
570
+ findProjectPath,
548
571
  fakerPath,
549
572
  extname,
550
573
  examplesPath,
@@ -559,6 +582,7 @@ export {
559
582
  developmentPath,
560
583
  desktopPath,
561
584
  delimiter,
585
+ src_default as default,
562
586
  datetimePath,
563
587
  databasePath,
564
588
  customElementsDataPath,