codify-plugin-lib 1.0.182-beta33 → 1.0.182-beta35

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.
@@ -1 +1 @@
1
- export declare const listAllResources: () => Promise<string[]>;
1
+ export declare const listAllResources: (root?: string) => Promise<string[]>;
@@ -1,26 +1,27 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- export const listAllResources = async () => {
4
- const resourceDir = await fs.readdir('./resources');
3
+ export const listAllResources = async (root = process.cwd()) => {
4
+ const resourcesPath = path.join(root, 'src', 'resources');
5
+ const resourceDir = await fs.readdir(resourcesPath);
5
6
  const dedupSet = new Set();
6
7
  const result = new Set();
7
8
  for (const folder of resourceDir) {
8
- if (await fs.stat(path.join('./resources', folder)).then(s => s.isDirectory()).catch(() => false)) {
9
- for (const folderContents of await fs.readdir(path.join('./resources', folder))) {
10
- const isDirectory = await fs.stat(path.join('./resources', folder, folderContents)).then(s => s.isDirectory());
9
+ if (await fs.stat(path.join(resourcesPath, folder)).then(s => s.isDirectory()).catch(() => false)) {
10
+ for (const folderContents of await fs.readdir(path.join(resourcesPath, folder))) {
11
+ const isDirectory = await fs.stat(path.join(resourcesPath, folder, folderContents)).then(s => s.isDirectory());
11
12
  // console.log(folderContents, isDirectory);
12
13
  if (isDirectory) {
13
- for (const innerContents of await fs.readdir(path.join('./resources', folder, folderContents))) {
14
- if (!dedupSet.has(path.join('./resources', folder, folderContents))) {
15
- dedupSet.add(path.join('./resources', folder, folderContents));
16
- addResourceFromDir(path.join('./resources', folder, folderContents), result);
14
+ for (const innerContents of await fs.readdir(path.join(resourcesPath, folder, folderContents))) {
15
+ if (!dedupSet.has(path.join(resourcesPath, folder, folderContents))) {
16
+ dedupSet.add(path.join(resourcesPath, folder, folderContents));
17
+ addResourceFromDir(path.join(resourcesPath, folder, folderContents), result);
17
18
  }
18
19
  }
19
20
  }
20
21
  else {
21
- if (!dedupSet.has(path.join('./resources', folder))) {
22
- dedupSet.add(path.join('./resources', folder));
23
- addResourceFromDir(path.join('./resources', folder), result);
22
+ if (!dedupSet.has(path.join(resourcesPath, folder))) {
23
+ dedupSet.add(path.join(resourcesPath, folder));
24
+ addResourceFromDir(path.join(resourcesPath, folder), result);
24
25
  }
25
26
  }
26
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta33",
3
+ "version": "1.0.182-beta35",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -24,9 +24,10 @@ import { getPty } from '../pty/index.js';
24
24
  import { SequentialPty } from '../pty/seqeuntial-pty.js';
25
25
  import { ResourceController } from '../resource/resource-controller.js';
26
26
  import { listAllResources } from '../utils/load-resources.js';
27
- import { readNearestPackageJson } from '../utils/package-json-utils.js';
27
+ import { findNearestPackageJson, readNearestPackageJson } from '../utils/package-json-utils.js';
28
28
  import { ptyLocalStorage } from '../utils/pty-local-storage.js';
29
29
  import { VerbosityLevel } from '../utils/verbosity-level.js';
30
+ import path from 'node:path';
30
31
 
31
32
  export class Plugin {
32
33
  planStorage: Map<string, Plan<any>>;
@@ -1,28 +1,30 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
 
4
- export const listAllResources = async () => {
5
- const resourceDir = await fs.readdir('./resources');
4
+ export const listAllResources = async (root = process.cwd()) => {
5
+ const resourcesPath = path.join(root, 'src', 'resources')
6
+
7
+ const resourceDir = await fs.readdir(resourcesPath);
6
8
  const dedupSet = new Set();
7
9
  const result = new Set<string>();
8
10
 
9
11
  for (const folder of resourceDir) {
10
- if (await fs.stat(path.join('./resources', folder)).then(s => s.isDirectory()).catch(() => false)) {
11
- for (const folderContents of await fs.readdir(path.join('./resources', folder))) {
12
- const isDirectory = await fs.stat(path.join('./resources', folder, folderContents)).then(s => s.isDirectory());
12
+ if (await fs.stat(path.join(resourcesPath, folder)).then(s => s.isDirectory()).catch(() => false)) {
13
+ for (const folderContents of await fs.readdir(path.join(resourcesPath, folder))) {
14
+ const isDirectory = await fs.stat(path.join(resourcesPath, folder, folderContents)).then(s => s.isDirectory());
13
15
 
14
16
  // console.log(folderContents, isDirectory);
15
17
  if (isDirectory) {
16
- for (const innerContents of await fs.readdir(path.join('./resources', folder, folderContents))) {
17
- if (!dedupSet.has(path.join('./resources', folder, folderContents))) {
18
- dedupSet.add(path.join('./resources', folder, folderContents));
19
- addResourceFromDir(path.join('./resources', folder,folderContents), result);
18
+ for (const innerContents of await fs.readdir(path.join(resourcesPath, folder, folderContents))) {
19
+ if (!dedupSet.has(path.join(resourcesPath, folder, folderContents))) {
20
+ dedupSet.add(path.join(resourcesPath, folder, folderContents));
21
+ addResourceFromDir(path.join(resourcesPath, folder,folderContents), result);
20
22
  }
21
23
  }
22
24
  } else {
23
- if (!dedupSet.has(path.join('./resources', folder))) {
24
- dedupSet.add(path.join('./resources', folder));
25
- addResourceFromDir(path.join('./resources', folder), result);
25
+ if (!dedupSet.has(path.join(resourcesPath, folder))) {
26
+ dedupSet.add(path.join(resourcesPath, folder));
27
+ addResourceFromDir(path.join(resourcesPath, folder), result);
26
28
  }
27
29
  }
28
30
  }