@eclipse-docks/extension-utils 0.7.96 → 0.7.97

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
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=unzip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unzip.d.ts","sourceRoot":"","sources":["../../src/commands/unzip.ts"],"names":[],"mappings":""}
@@ -0,0 +1,123 @@
1
+ import { FileContentType, activeSelectionSignal, registerAll, taskService, toastError, toastInfo, workspaceService } from "@eclipse-docks/core";
2
+ import { PyEnv } from "@eclipse-docks/extension-python-runtime/api";
3
+ import JSZip from "jszip";
4
+ //#region src/commands/p12split.ts
5
+ registerAll({
6
+ command: {
7
+ id: "p12split",
8
+ name: ".p12 file splitter",
9
+ description: "Splits a .p12 file into private/public and additional .pem files",
10
+ parameters: [
11
+ {
12
+ name: "p12_path",
13
+ description: "Path of the .p12 file to split",
14
+ required: true
15
+ },
16
+ {
17
+ name: "password",
18
+ description: "The password of the .p12 file, will prompt for input if not specified, use empty string for no password",
19
+ required: false
20
+ },
21
+ {
22
+ name: "output_path",
23
+ description: "Directory path of the files to write to, if not provided, will be parent directory of p12_path",
24
+ required: false
25
+ }
26
+ ]
27
+ },
28
+ handler: { execute: async ({ params: { p12_path, password, output_path } }) => {
29
+ const workspace = await workspaceService.getWorkspace();
30
+ if (!workspace) {
31
+ toastError("No Workspace selected!");
32
+ return;
33
+ }
34
+ await taskService.runAsync("Splitting .p12 certificate file", async () => {
35
+ const pyEnv = new PyEnv();
36
+ await pyEnv.init(workspace);
37
+ await pyEnv.loadPackages(["cryptography"]);
38
+ const pyModule = await import("./p12splitter-CFxn-nyT.js");
39
+ const pyScript = pyModule.default ?? pyModule;
40
+ await pyEnv.execCode(pyScript);
41
+ await pyEnv.runFunction("p12splitter", {
42
+ p12_path,
43
+ password: password === "\"\"" ? void 0 : password,
44
+ output_path: output_path === "\"\"" ? "" : output_path
45
+ });
46
+ toastInfo(".p12 file successfully splitted");
47
+ });
48
+ } }
49
+ });
50
+ //#endregion
51
+ //#region src/commands/unzip.ts
52
+ registerAll({
53
+ command: {
54
+ id: "unzip",
55
+ name: "Unzip Archive",
56
+ description: "Extract a zip archive from the workspace",
57
+ parameters: [{
58
+ name: "file",
59
+ description: "the zip file to extract, if not provided, the current selection will be used",
60
+ required: false
61
+ }, {
62
+ name: "target",
63
+ description: "target folder to extract into, defaults to the zip filename without extension",
64
+ required: false
65
+ }]
66
+ },
67
+ handler: {
68
+ canExecute: (context) => {
69
+ let filePath = context.params?.file;
70
+ if (!filePath) {
71
+ const selectedItem = activeSelectionSignal.get();
72
+ if (!selectedItem || !("path" in selectedItem)) return false;
73
+ filePath = selectedItem.path;
74
+ }
75
+ return filePath.toLowerCase().endsWith(".zip");
76
+ },
77
+ execute: async (context) => {
78
+ let filePath = context.params?.file;
79
+ if (!filePath) filePath = activeSelectionSignal.get().path;
80
+ const workspaceDir = await workspaceService.getWorkspace();
81
+ if (!workspaceDir) {
82
+ toastError("No workspace selected.");
83
+ return;
84
+ }
85
+ await taskService.runAsync("Extracting archive", async (progress) => {
86
+ try {
87
+ const fileResource = await workspaceDir.getResource(filePath);
88
+ if (!fileResource) {
89
+ toastError("File not found: " + filePath);
90
+ return;
91
+ }
92
+ let targetFolder = context.params?.target;
93
+ if (!targetFolder) targetFolder = (filePath.split("/").pop() || "extracted").replace(/\.zip$/i, "") + "/";
94
+ progress.message = "Loading archive...";
95
+ progress.progress = 0;
96
+ await workspaceDir.getResource(targetFolder, { create: true });
97
+ const blob = await fileResource.getContents({ blob: true });
98
+ const zip = await JSZip.loadAsync(blob);
99
+ const totalFiles = Object.values(zip.files).filter((entry) => !entry.dir).length;
100
+ let extractedCount = 0;
101
+ progress.message = `Extracting to ${targetFolder.replace(/\/$/, "")}...`;
102
+ for (const [relativePath, zipEntry] of Object.entries(zip.files)) {
103
+ if (zipEntry.dir) continue;
104
+ const entryBlob = await zipEntry.async("blob");
105
+ const fullPath = `${targetFolder}${relativePath}`;
106
+ await (await workspaceDir.getResource(fullPath, { create: true })).saveContents(entryBlob, { contentType: FileContentType.BINARY });
107
+ extractedCount++;
108
+ progress.progress = Math.round(extractedCount / totalFiles * 100);
109
+ progress.message = `Extracting ${extractedCount}/${totalFiles} files...`;
110
+ }
111
+ progress.progress = 100;
112
+ toastInfo(`Archive extracted to ${targetFolder.replace(/\/$/, "")}: ${extractedCount} file(s)`);
113
+ } catch (err) {
114
+ toastError("Failed to extract archive: " + err);
115
+ throw err;
116
+ }
117
+ });
118
+ }
119
+ }
120
+ });
121
+ //#endregion
122
+
123
+ //# sourceMappingURL=commands-CvhhmqU3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-CvhhmqU3.js","names":[],"sources":["../src/commands/p12split.ts","../src/commands/unzip.ts"],"sourcesContent":["import { workspaceService, taskService, toastError, toastInfo, registerAll } from \"@eclipse-docks/core\";\nimport { PyEnv } from \"@eclipse-docks/extension-python-runtime/api\";\n\nregisterAll({\n command: {\n id: \"p12split\",\n name: \".p12 file splitter\",\n description: \"Splits a .p12 file into private/public and additional .pem files\",\n parameters: [\n {\n name: \"p12_path\",\n description: \"Path of the .p12 file to split\",\n required: true\n },\n {\n name: \"password\",\n description:\n \"The password of the .p12 file, will prompt for input if not specified, use empty string for no password\",\n required: false\n },\n {\n name: \"output_path\",\n description:\n \"Directory path of the files to write to, if not provided, will be parent directory of p12_path\",\n required: false\n }\n ]\n },\n handler: {\n execute: async ({ params: { p12_path, password, output_path } }: any) => {\n const workspace = await workspaceService.getWorkspace();\n if (!workspace) {\n toastError(\"No Workspace selected!\");\n return;\n }\n\n await taskService.runAsync(\"Splitting .p12 certificate file\", async () => {\n const pyEnv = new PyEnv();\n await pyEnv.init(workspace);\n await pyEnv.loadPackages([\"cryptography\"]);\n const pyModule = await import(\"../p12splitter.py?raw\");\n const pyScript = (pyModule as any).default ?? pyModule;\n await pyEnv.execCode(pyScript as string);\n await pyEnv.runFunction(\"p12splitter\", {\n p12_path,\n password: password === '\"\"' ? undefined : password,\n output_path: output_path === '\"\"' ? \"\" : output_path\n });\n toastInfo(\".p12 file successfully splitted\");\n });\n }\n }\n});\n\n","import JSZip from \"jszip\";\nimport {\n registerAll,\n activeSelectionSignal,\n File,\n FileContentType,\n workspaceService,\n taskService,\n toastError,\n toastInfo,\n} from \"@eclipse-docks/core\";\n\nregisterAll({\n command: {\n id: \"unzip\",\n name: \"Unzip Archive\",\n description: \"Extract a zip archive from the workspace\",\n parameters: [\n {\n name: \"file\",\n description: \"the zip file to extract, if not provided, the current selection will be used\",\n required: false,\n },\n {\n name: \"target\",\n description: \"target folder to extract into, defaults to the zip filename without extension\",\n required: false,\n },\n ],\n },\n handler: {\n canExecute: (context: any) => {\n let filePath: string = context.params?.file;\n if (!filePath) {\n const selectedItem = activeSelectionSignal.get() as any;\n if (!selectedItem || !(\"path\" in selectedItem)) return false;\n filePath = selectedItem.path;\n }\n return filePath.toLowerCase().endsWith(\".zip\");\n },\n execute: async (context: any) => {\n let filePath: string = context.params?.file;\n if (!filePath) {\n const selectedItem = activeSelectionSignal.get() as any;\n filePath = selectedItem.path;\n }\n\n const workspaceDir = await workspaceService.getWorkspace();\n if (!workspaceDir) {\n toastError(\"No workspace selected.\");\n return;\n }\n\n await taskService.runAsync(\"Extracting archive\", async (progress: any) => {\n try {\n const fileResource = await workspaceDir.getResource(filePath);\n if (!fileResource) {\n toastError(\"File not found: \" + filePath);\n return;\n }\n\n let targetFolder = context.params?.target;\n if (!targetFolder) {\n const fileName = filePath.split(\"/\").pop() || \"extracted\";\n targetFolder = fileName.replace(/\\.zip$/i, \"\") + \"/\";\n }\n\n progress.message = \"Loading archive...\";\n progress.progress = 0;\n await workspaceDir.getResource(targetFolder, { create: true });\n\n const file = fileResource as File;\n const blob = await file.getContents({ blob: true });\n const zip = await JSZip.loadAsync(blob);\n const totalFiles = Object.values(zip.files).filter((entry) => !entry.dir).length;\n let extractedCount = 0;\n\n progress.message = `Extracting to ${targetFolder.replace(/\\/$/, \"\")}...`;\n\n for (const [relativePath, zipEntry] of Object.entries(zip.files)) {\n if (zipEntry.dir) continue;\n\n const entryBlob = await zipEntry.async(\"blob\");\n const fullPath = `${targetFolder}${relativePath}`;\n const entryResource = await workspaceDir.getResource(fullPath, { create: true });\n const newFile = entryResource as File;\n await newFile.saveContents(entryBlob, { contentType: FileContentType.BINARY });\n\n extractedCount++;\n progress.progress = Math.round((extractedCount / totalFiles) * 100);\n progress.message = `Extracting ${extractedCount}/${totalFiles} files...`;\n }\n\n progress.progress = 100;\n toastInfo(`Archive extracted to ${targetFolder.replace(/\\/$/, \"\")}: ${extractedCount} file(s)`);\n } catch (err: any) {\n toastError(\"Failed to extract archive: \" + err);\n throw err;\n }\n });\n },\n },\n});\n"],"mappings":";;;;AAGA,YAAY;CACV,SAAS;EACP,IAAI;EACJ,MAAM;EACN,aAAa;EACb,YAAY;GACV;IACE,MAAM;IACN,aAAa;IACb,UAAU;IACX;GACD;IACE,MAAM;IACN,aACE;IACF,UAAU;IACX;GACD;IACE,MAAM;IACN,aACE;IACF,UAAU;IACX;GACF;EACF;CACD,SAAS,EACP,SAAS,OAAO,EAAE,QAAQ,EAAE,UAAU,UAAU,oBAAyB;EACvE,MAAM,YAAY,MAAM,iBAAiB,cAAc;AACvD,MAAI,CAAC,WAAW;AACd,cAAW,yBAAyB;AACpC;;AAGF,QAAM,YAAY,SAAS,mCAAmC,YAAY;GACxE,MAAM,QAAQ,IAAI,OAAO;AACzB,SAAM,MAAM,KAAK,UAAU;AAC3B,SAAM,MAAM,aAAa,CAAC,eAAe,CAAC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MAAM,CAAC;KAG9D,MAAM,OAAO,MADA,aACW,YAAY,EAAE,MAAM,MAAM,CAAC;KACnD,MAAM,MAAM,MAAM,MAAM,UAAU,KAAK;KACvC,MAAM,aAAa,OAAO,OAAO,IAAI,MAAM,CAAC,QAAQ,UAAU,CAAC,MAAM,IAAI,CAAC;KAC1E,IAAI,iBAAiB;AAErB,cAAS,UAAU,iBAAiB,aAAa,QAAQ,OAAO,GAAG,CAAC;AAEpE,UAAK,MAAM,CAAC,cAAc,aAAa,OAAO,QAAQ,IAAI,MAAM,EAAE;AAChE,UAAI,SAAS,IAAK;MAElB,MAAM,YAAY,MAAM,SAAS,MAAM,OAAO;MAC9C,MAAM,WAAW,GAAG,eAAe;AAGnC,aAFsB,MAAM,aAAa,YAAY,UAAU,EAAE,QAAQ,MAAM,CAAC,EAElE,aAAa,WAAW,EAAE,aAAa,gBAAgB,QAAQ,CAAC;AAE9E;AACA,eAAS,WAAW,KAAK,MAAO,iBAAiB,aAAc,IAAI;AACnE,eAAS,UAAU,cAAc,eAAe,GAAG,WAAW;;AAGhE,cAAS,WAAW;AACpB,eAAU,wBAAwB,aAAa,QAAQ,OAAO,GAAG,CAAC,IAAI,eAAe,UAAU;aACxF,KAAU;AACjB,gBAAW,gCAAgC,IAAI;AAC/C,WAAM;;KAER;;EAEL;CACF,CAAC"}
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ extensionRegistry.registerExtension({
9
9
  id: pkg.name,
10
10
  name: t.EXT_UTILS_NAME,
11
11
  description: t.EXT_UTILS_DESC,
12
- loader: () => import("./commands-DXblDlOb.js"),
12
+ loader: () => import("./commands-CvhhmqU3.js"),
13
13
  icon: "toolbox",
14
14
  dependencies: ["@eclipse-docks/extension-python-runtime"]
15
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-docks/extension-utils",
3
- "version": "0.7.96",
3
+ "version": "0.7.97",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -15,9 +15,12 @@
15
15
  "jszip": "^3.10.1"
16
16
  },
17
17
  "devDependencies": {
18
+ "fake-indexeddb": "^6.2.5",
19
+ "jsdom": "^25.0.0",
18
20
  "typescript": "^6.0.0",
19
21
  "vite": "^8.0.0",
20
- "vite-plugin-dts": "^4.5.4"
22
+ "vite-plugin-dts": "^4.5.4",
23
+ "vitest": "^4.0.18"
21
24
  },
22
25
  "module": "./dist/index.js",
23
26
  "types": "./dist/index.d.ts",
@@ -25,7 +28,8 @@
25
28
  "dist"
26
29
  ],
27
30
  "scripts": {
28
- "build": "vite build"
31
+ "build": "vite build",
32
+ "test": "vitest run"
29
33
  },
30
34
  "repository": {
31
35
  "type": "git",
@@ -1,51 +0,0 @@
1
- import { registerAll, taskService, toastError, toastInfo, workspaceService } from "@eclipse-docks/core";
2
- import { PyEnv } from "@eclipse-docks/extension-python-runtime/api";
3
- //#region src/commands/p12split.ts
4
- registerAll({
5
- command: {
6
- id: "p12split",
7
- name: ".p12 file splitter",
8
- description: "Splits a .p12 file into private/public and additional .pem files",
9
- parameters: [
10
- {
11
- name: "p12_path",
12
- description: "Path of the .p12 file to split",
13
- required: true
14
- },
15
- {
16
- name: "password",
17
- description: "The password of the .p12 file, will prompt for input if not specified, use empty string for no password",
18
- required: false
19
- },
20
- {
21
- name: "output_path",
22
- description: "Directory path of the files to write to, if not provided, will be parent directory of p12_path",
23
- required: false
24
- }
25
- ]
26
- },
27
- handler: { execute: async ({ params: { p12_path, password, output_path } }) => {
28
- const workspace = await workspaceService.getWorkspace();
29
- if (!workspace) {
30
- toastError("No Workspace selected!");
31
- return;
32
- }
33
- await taskService.runAsync("Splitting .p12 certificate file", async () => {
34
- const pyEnv = new PyEnv();
35
- await pyEnv.init(workspace);
36
- await pyEnv.loadPackages(["cryptography"]);
37
- const pyModule = await import("./p12splitter-CFxn-nyT.js");
38
- const pyScript = pyModule.default ?? pyModule;
39
- await pyEnv.execCode(pyScript);
40
- await pyEnv.runFunction("p12splitter", {
41
- p12_path,
42
- password: password === "\"\"" ? void 0 : password,
43
- output_path: output_path === "\"\"" ? "" : output_path
44
- });
45
- toastInfo(".p12 file successfully splitted");
46
- });
47
- } }
48
- });
49
- //#endregion
50
-
51
- //# sourceMappingURL=commands-DXblDlOb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commands-DXblDlOb.js","names":[],"sources":["../src/commands/p12split.ts"],"sourcesContent":["import { workspaceService, taskService, toastError, toastInfo, registerAll } from \"@eclipse-docks/core\";\nimport { PyEnv } from \"@eclipse-docks/extension-python-runtime/api\";\n\nregisterAll({\n command: {\n id: \"p12split\",\n name: \".p12 file splitter\",\n description: \"Splits a .p12 file into private/public and additional .pem files\",\n parameters: [\n {\n name: \"p12_path\",\n description: \"Path of the .p12 file to split\",\n required: true\n },\n {\n name: \"password\",\n description:\n \"The password of the .p12 file, will prompt for input if not specified, use empty string for no password\",\n required: false\n },\n {\n name: \"output_path\",\n description:\n \"Directory path of the files to write to, if not provided, will be parent directory of p12_path\",\n required: false\n }\n ]\n },\n handler: {\n execute: async ({ params: { p12_path, password, output_path } }: any) => {\n const workspace = await workspaceService.getWorkspace();\n if (!workspace) {\n toastError(\"No Workspace selected!\");\n return;\n }\n\n await taskService.runAsync(\"Splitting .p12 certificate file\", async () => {\n const pyEnv = new PyEnv();\n await pyEnv.init(workspace);\n await pyEnv.loadPackages([\"cryptography\"]);\n const pyModule = await import(\"../p12splitter.py?raw\");\n const pyScript = (pyModule as any).default ?? pyModule;\n await pyEnv.execCode(pyScript as string);\n await pyEnv.runFunction(\"p12splitter\", {\n p12_path,\n password: password === '\"\"' ? undefined : password,\n output_path: output_path === '\"\"' ? \"\" : output_path\n });\n toastInfo(\".p12 file successfully splitted\");\n });\n }\n }\n});\n\n"],"mappings":";;;AAGA,YAAY;CACV,SAAS;EACP,IAAI;EACJ,MAAM;EACN,aAAa;EACb,YAAY;GACV;IACE,MAAM;IACN,aAAa;IACb,UAAU;IACX;GACD;IACE,MAAM;IACN,aACE;IACF,UAAU;IACX;GACD;IACE,MAAM;IACN,aACE;IACF,UAAU;IACX;GACF;EACF;CACD,SAAS,EACP,SAAS,OAAO,EAAE,QAAQ,EAAE,UAAU,UAAU,oBAAyB;EACvE,MAAM,YAAY,MAAM,iBAAiB,cAAc;AACvD,MAAI,CAAC,WAAW;AACd,cAAW,yBAAyB;AACpC;;AAGF,QAAM,YAAY,SAAS,mCAAmC,YAAY;GACxE,MAAM,QAAQ,IAAI,OAAO;AACzB,SAAM,MAAM,KAAK,UAAU;AAC3B,SAAM,MAAM,aAAa,CAAC,eAAe,CAAC;GAC1C,MAAM,WAAW,MAAM,OAAO;GAC9B,MAAM,WAAY,SAAiB,WAAW;AAC9C,SAAM,MAAM,SAAS,SAAmB;AACxC,SAAM,MAAM,YAAY,eAAe;IACrC;IACA,UAAU,aAAa,SAAO,KAAA,IAAY;IAC1C,aAAa,gBAAgB,SAAO,KAAK;IAC1C,CAAC;AACF,aAAU,kCAAkC;IAC5C;IAEL;CACF,CAAC"}