zephyr-cli 0.1.16 → 0.2.0-next.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/dist/lib/extract-assets.js +14 -34
- package/dist/lib/extract-assets.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +2 -2
- package/src/lib/extract-assets.ts +21 -37
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractAssetsFromDirectory = extractAssetsFromDirectory;
|
|
4
|
-
const promises_1 = require("node:fs/promises");
|
|
5
4
|
const node_path_1 = require("node:path");
|
|
6
5
|
const zephyr_agent_1 = require("zephyr-agent");
|
|
7
6
|
function extractBuffer(asset) {
|
|
@@ -20,42 +19,23 @@ function normalizePath(filePath) {
|
|
|
20
19
|
*/
|
|
21
20
|
async function extractAssetsFromDirectory(buildDir) {
|
|
22
21
|
const assets = {};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const fullPath = (0, node_path_1.join)(dirPath, entry.name);
|
|
30
|
-
if (entry.isDirectory()) {
|
|
31
|
-
await walkDir(fullPath);
|
|
32
|
-
}
|
|
33
|
-
else if (entry.isFile()) {
|
|
34
|
-
// Get relative path from build directory
|
|
35
|
-
const relativePath = normalizePath((0, node_path_1.relative)(buildDir, fullPath));
|
|
36
|
-
// Skip certain files that shouldn't be uploaded
|
|
37
|
-
if (shouldSkipFile(relativePath)) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
const content = await (0, promises_1.readFile)(fullPath);
|
|
42
|
-
const fileType = getFileType(relativePath);
|
|
43
|
-
assets[relativePath] = {
|
|
44
|
-
content,
|
|
45
|
-
type: fileType,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
catch (readError) {
|
|
49
|
-
(0, zephyr_agent_1.logFn)('warn', `Failed to read file ${fullPath}: ${readError}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
22
|
+
try {
|
|
23
|
+
const files = await (0, zephyr_agent_1.readDirRecursiveWithContents)(buildDir);
|
|
24
|
+
for (const file of files) {
|
|
25
|
+
const relativePath = normalizePath(file.relativePath);
|
|
26
|
+
if (shouldSkipFile(relativePath)) {
|
|
27
|
+
continue;
|
|
52
28
|
}
|
|
29
|
+
const fileType = getFileType(relativePath);
|
|
30
|
+
assets[relativePath] = {
|
|
31
|
+
content: file.content,
|
|
32
|
+
type: fileType,
|
|
33
|
+
};
|
|
53
34
|
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
(0, zephyr_agent_1.logFn)('warn', `Failed to walk directory ${dirPath}: ${error}`);
|
|
56
|
-
}
|
|
57
35
|
}
|
|
58
|
-
|
|
36
|
+
catch (error) {
|
|
37
|
+
(0, zephyr_agent_1.logFn)('warn', `Failed to read build directory ${buildDir}: ${error}`);
|
|
38
|
+
}
|
|
59
39
|
return (0, zephyr_agent_1.buildAssetsMap)(assets, extractBuffer, getAssetType);
|
|
60
40
|
}
|
|
61
41
|
function shouldSkipFile(filePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-assets.js","sourceRoot":"","sources":["../../src/lib/extract-assets.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"extract-assets.js","sourceRoot":"","sources":["../../src/lib/extract-assets.ts"],"names":[],"mappings":";;AA8BA,gEA0BC;AAxDD,yCAAgC;AAChC,+CAKsB;AAOtB,SAAS,aAAa,CAAC,KAAqB;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC;AAED,SAAS,YAAY,CAAC,KAAqB;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,kFAAkF;AAClF,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,QAAQ,CAAC,KAAK,CAAC,eAAG,CAAC,CAAC,IAAI,CAA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CAAC,CAAC,GAAG,EAAE,0CAAE,WAAW,EAAE,KAAI,EAAE,CAAC;IAEjE,MAAM,OAAO,GAA2B;QACtC,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,UAAU;QACf,EAAE,EAAE,wBAAwB;QAC5B,GAAG,EAAE,wBAAwB;QAC7B,IAAI,EAAE,kBAAkB;QACxB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,eAAe;QACpB,GAAG,EAAE,cAAc;QACnB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;QACnB,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,+BAA+B;QACpC,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,YAAY;KAClB,CAAC;IAEF,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,0BAA0B,CAAC;AAC1D,CAAC"}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.0-next.1",
|
|
4
4
|
"description": "CLI tool for running build commands and uploading assets to Zephyr",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zephyr",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"cosmiconfig": "^9.0.0",
|
|
30
30
|
"jsonc-parser": "^3.3.1",
|
|
31
31
|
"tslib": "^2.8.1",
|
|
32
|
-
"zephyr-agent": "0.1
|
|
32
|
+
"zephyr-agent": "0.2.0-next.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "29.5.14",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { sep } from 'node:path';
|
|
2
|
+
import {
|
|
3
|
+
buildAssetsMap,
|
|
4
|
+
logFn,
|
|
5
|
+
readDirRecursiveWithContents,
|
|
6
|
+
type ZeBuildAssetsMap,
|
|
7
|
+
} from 'zephyr-agent';
|
|
4
8
|
|
|
5
9
|
interface DirectoryAsset {
|
|
6
10
|
content: Buffer | string;
|
|
@@ -29,46 +33,26 @@ export async function extractAssetsFromDirectory(
|
|
|
29
33
|
): Promise<ZeBuildAssetsMap> {
|
|
30
34
|
const assets: Record<string, DirectoryAsset> = {};
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
async function walkDir(dirPath: string): Promise<void> {
|
|
35
|
-
try {
|
|
36
|
-
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
36
|
+
try {
|
|
37
|
+
const files = await readDirRecursiveWithContents(buildDir);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
const relativePath = normalizePath(file.relativePath);
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} else if (entry.isFile()) {
|
|
44
|
-
// Get relative path from build directory
|
|
45
|
-
const relativePath = normalizePath(relative(buildDir, fullPath));
|
|
46
|
-
|
|
47
|
-
// Skip certain files that shouldn't be uploaded
|
|
48
|
-
if (shouldSkipFile(relativePath)) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const content = await readFile(fullPath);
|
|
54
|
-
const fileType = getFileType(relativePath);
|
|
55
|
-
|
|
56
|
-
assets[relativePath] = {
|
|
57
|
-
content,
|
|
58
|
-
type: fileType,
|
|
59
|
-
};
|
|
60
|
-
} catch (readError) {
|
|
61
|
-
logFn('warn', `Failed to read file ${fullPath}: ${readError}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
42
|
+
if (shouldSkipFile(relativePath)) {
|
|
43
|
+
continue;
|
|
64
44
|
}
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
|
|
46
|
+
const fileType = getFileType(relativePath);
|
|
47
|
+
assets[relativePath] = {
|
|
48
|
+
content: file.content,
|
|
49
|
+
type: fileType,
|
|
50
|
+
};
|
|
67
51
|
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
logFn('warn', `Failed to read build directory ${buildDir}: ${error}`);
|
|
68
54
|
}
|
|
69
55
|
|
|
70
|
-
await walkDir(buildDir);
|
|
71
|
-
|
|
72
56
|
return buildAssetsMap(assets, extractBuffer, getAssetType);
|
|
73
57
|
}
|
|
74
58
|
|