@vyriy/dist 0.9.2 → 0.9.4
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/assets.d.ts +1 -0
- package/assets.js +28 -1
- package/package.js +2 -1
- package/package.json +1 -1
package/assets.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PackageJson } from './types.js';
|
|
2
2
|
export declare const copyReadme: (packageDirectory: string) => Promise<void>;
|
|
3
3
|
export declare const copyCommonJsAssets: (packageDirectory: string) => Promise<void>;
|
|
4
|
+
export declare const copyPackageAssets: (packageDirectory: string) => Promise<void>;
|
|
4
5
|
export declare const resolveSourceAgentsPath: (packageAgentsPath: string, sharedAgentsPath: string, rootAgentsPath: string) => Promise<string>;
|
|
5
6
|
export declare const copyAgents: (packageDirectory: string, rootPackageJson: PackageJson) => Promise<boolean>;
|
|
6
7
|
export declare const copyLicense: (packageDirectory: string) => Promise<void>;
|
package/assets.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { copyFile, readdir } from 'node:fs/promises';
|
|
1
|
+
import { copyFile, mkdir, readdir } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { AGENTS_FILE, LICENSE_FILE, PACKAGES_DIR, README_FILE } from './constants.js';
|
|
4
4
|
import { hasFile } from './file.js';
|
|
@@ -19,6 +19,33 @@ export const copyCommonJsAssets = async (packageDirectory) => {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
const copyDirectory = async (sourceDirectory, targetDirectory) => {
|
|
23
|
+
const entries = await readdir(sourceDirectory, { withFileTypes: true });
|
|
24
|
+
await mkdir(targetDirectory, { recursive: true });
|
|
25
|
+
await Promise.all(entries.map(async (entry) => {
|
|
26
|
+
const sourcePath = path.join(sourceDirectory, entry.name);
|
|
27
|
+
const targetPath = path.join(targetDirectory, entry.name);
|
|
28
|
+
if (entry.isDirectory()) {
|
|
29
|
+
await copyDirectory(sourcePath, targetPath);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (entry.isFile()) {
|
|
33
|
+
await copyFile(sourcePath, targetPath);
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
export const copyPackageAssets = async (packageDirectory) => {
|
|
38
|
+
const packageName = path.basename(packageDirectory);
|
|
39
|
+
const sourceAssetsPath = path.join(PACKAGES_DIR, packageName, 'assets');
|
|
40
|
+
try {
|
|
41
|
+
await copyDirectory(sourceAssetsPath, path.join(packageDirectory, 'assets'));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error.code !== 'ENOENT') {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
22
49
|
export const resolveSourceAgentsPath = async (packageAgentsPath, sharedAgentsPath, rootAgentsPath) => {
|
|
23
50
|
if (await hasFile(packageAgentsPath)) {
|
|
24
51
|
return packageAgentsPath;
|
package/package.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { copyAgents, copyCommonJsAssets, copyLicense, copyReadme } from './assets.js';
|
|
2
|
+
import { copyAgents, copyCommonJsAssets, copyLicense, copyPackageAssets, copyReadme } from './assets.js';
|
|
3
3
|
import { makePackageBinsExecutable, removePackageBinDeclarationFiles } from './bin.js';
|
|
4
4
|
import { AGENTS_FILE, PACKAGES_DIR } from './constants.js';
|
|
5
5
|
import { removeEmptyJavaScriptFiles } from './cleanup.js';
|
|
@@ -34,6 +34,7 @@ export const distPackage = async (packageJsonPath, rootPackageJson) => {
|
|
|
34
34
|
await copyLicense(packageDirectory);
|
|
35
35
|
await copyReadme(packageDirectory);
|
|
36
36
|
await copyCommonJsAssets(packageDirectory);
|
|
37
|
+
await copyPackageAssets(packageDirectory);
|
|
37
38
|
const hasAgents = await copyAgents(packageDirectory, rootPackageJson);
|
|
38
39
|
delete packageJson.private;
|
|
39
40
|
if (hasAgents && rootPackageJson.agents) {
|