codify-plugin-lib 1.0.182-beta34 → 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.
- package/dist/plugin/plugin.js +1 -3
- package/dist/utils/load-resources.js +12 -12
- package/package.json +1 -1
- package/src/plugin/plugin.ts +0 -1
- package/src/utils/load-resources.ts +12 -12
package/dist/plugin/plugin.js
CHANGED
|
@@ -5,10 +5,9 @@ import { getPty } from '../pty/index.js';
|
|
|
5
5
|
import { SequentialPty } from '../pty/seqeuntial-pty.js';
|
|
6
6
|
import { ResourceController } from '../resource/resource-controller.js';
|
|
7
7
|
import { listAllResources } from '../utils/load-resources.js';
|
|
8
|
-
import {
|
|
8
|
+
import { readNearestPackageJson } from '../utils/package-json-utils.js';
|
|
9
9
|
import { ptyLocalStorage } from '../utils/pty-local-storage.js';
|
|
10
10
|
import { VerbosityLevel } from '../utils/verbosity-level.js';
|
|
11
|
-
import path from 'node:path';
|
|
12
11
|
export class Plugin {
|
|
13
12
|
name;
|
|
14
13
|
version;
|
|
@@ -27,7 +26,6 @@ export class Plugin {
|
|
|
27
26
|
throw new Error('Failed to read nearest package.json');
|
|
28
27
|
}
|
|
29
28
|
const { name, version } = packageJson;
|
|
30
|
-
const root = path.dirname(findNearestPackageJson());
|
|
31
29
|
const resourceLocations = await listAllResources();
|
|
32
30
|
const resources = await Promise.all(resourceLocations.map((l) => {
|
|
33
31
|
return import(l);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
export const listAllResources = async (root = process.cwd()) => {
|
|
4
|
-
|
|
5
|
-
const resourceDir = await fs.readdir(
|
|
4
|
+
const resourcesPath = path.join(root, 'src', 'resources');
|
|
5
|
+
const resourceDir = await fs.readdir(resourcesPath);
|
|
6
6
|
const dedupSet = new Set();
|
|
7
7
|
const result = new Set();
|
|
8
8
|
for (const folder of resourceDir) {
|
|
9
|
-
if (await fs.stat(path.join(
|
|
10
|
-
for (const folderContents of await fs.readdir(path.join(
|
|
11
|
-
const isDirectory = await fs.stat(path.join(
|
|
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());
|
|
12
12
|
// console.log(folderContents, isDirectory);
|
|
13
13
|
if (isDirectory) {
|
|
14
|
-
for (const innerContents of await fs.readdir(path.join(
|
|
15
|
-
if (!dedupSet.has(path.join(
|
|
16
|
-
dedupSet.add(path.join(
|
|
17
|
-
addResourceFromDir(path.join(
|
|
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);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
if (!dedupSet.has(path.join(
|
|
23
|
-
dedupSet.add(path.join(
|
|
24
|
-
addResourceFromDir(path.join(
|
|
22
|
+
if (!dedupSet.has(path.join(resourcesPath, folder))) {
|
|
23
|
+
dedupSet.add(path.join(resourcesPath, folder));
|
|
24
|
+
addResourceFromDir(path.join(resourcesPath, folder), result);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
package/package.json
CHANGED
package/src/plugin/plugin.ts
CHANGED
|
@@ -49,7 +49,6 @@ export class Plugin {
|
|
|
49
49
|
|
|
50
50
|
const { name, version } = packageJson;
|
|
51
51
|
|
|
52
|
-
const root = path.dirname(findNearestPackageJson()!);
|
|
53
52
|
const resourceLocations = await listAllResources();
|
|
54
53
|
const resources = await Promise.all(resourceLocations.map((l) => {
|
|
55
54
|
return import(l);
|
|
@@ -2,29 +2,29 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
export const listAllResources = async (root = process.cwd()) => {
|
|
5
|
-
|
|
5
|
+
const resourcesPath = path.join(root, 'src', 'resources')
|
|
6
6
|
|
|
7
|
-
const resourceDir = await fs.readdir(
|
|
7
|
+
const resourceDir = await fs.readdir(resourcesPath);
|
|
8
8
|
const dedupSet = new Set();
|
|
9
9
|
const result = new Set<string>();
|
|
10
10
|
|
|
11
11
|
for (const folder of resourceDir) {
|
|
12
|
-
if (await fs.stat(path.join(
|
|
13
|
-
for (const folderContents of await fs.readdir(path.join(
|
|
14
|
-
const isDirectory = await fs.stat(path.join(
|
|
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());
|
|
15
15
|
|
|
16
16
|
// console.log(folderContents, isDirectory);
|
|
17
17
|
if (isDirectory) {
|
|
18
|
-
for (const innerContents of await fs.readdir(path.join(
|
|
19
|
-
if (!dedupSet.has(path.join(
|
|
20
|
-
dedupSet.add(path.join(
|
|
21
|
-
addResourceFromDir(path.join(
|
|
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);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
} else {
|
|
25
|
-
if (!dedupSet.has(path.join(
|
|
26
|
-
dedupSet.add(path.join(
|
|
27
|
-
addResourceFromDir(path.join(
|
|
25
|
+
if (!dedupSet.has(path.join(resourcesPath, folder))) {
|
|
26
|
+
dedupSet.add(path.join(resourcesPath, folder));
|
|
27
|
+
addResourceFromDir(path.join(resourcesPath, folder), result);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|