diff --git a/.github/workflows/deploy-BETA.yml b/.github/workflows/deploy-BETA.yml index c3435f1..552df43 100644 --- a/.github/workflows/deploy-BETA.yml +++ b/.github/workflows/deploy-BETA.yml @@ -48,8 +48,7 @@ jobs: run: | npm ci npm run build - npm run cp:files - npm run cp:types + npm run tsc:cp:files - name: Semantic Release Dependency run: npm install -g @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/git @semantic-release/npm conventional-changelog-conventionalcommits semantic-release - name: Publish Beta diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml index a25ff3a..4e97a53 100644 --- a/.github/workflows/deploy-RELEASE.yml +++ b/.github/workflows/deploy-RELEASE.yml @@ -41,9 +41,8 @@ jobs: run: | npm ci npm run build - npm run cp:files - npm run cp:types - cd out/src + npm run tsc:cp:files + cd out npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKENX }} diff --git a/.swcrc b/.swcrc index d151b06..4199eb9 100644 --- a/.swcrc +++ b/.swcrc @@ -5,7 +5,8 @@ "type": "es6", "strictMode": true, "noInterop": false, - "resolveFully": true + "resolveFully": true, + "importInterop": "babel" }, "jsc": { "externalHelpers": false, diff --git a/package-lock.json b/package-lock.json index 668035f..66a64ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,22 +92,22 @@ } }, "node_modules/@babel/core": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz", - "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.7.tgz", + "integrity": "sha512-SRijHmF0PSPgLIBYlWnG0hyeJLwXE2CgpsXaMOrtt2yp9/86ALw6oUlj9KYuZ0JN07T4eBMVIW4li/9S1j2BGA==", "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.26.0", - "@babel/generator": "^7.26.0", - "@babel/helper-compilation-targets": "^7.25.9", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.5", + "@babel/helper-compilation-targets": "^7.26.5", "@babel/helper-module-transforms": "^7.26.0", - "@babel/helpers": "^7.26.0", - "@babel/parser": "^7.26.0", + "@babel/helpers": "^7.26.7", + "@babel/parser": "^7.26.7", "@babel/template": "^7.25.9", - "@babel/traverse": "^7.25.9", - "@babel/types": "^7.26.0", + "@babel/traverse": "^7.26.7", + "@babel/types": "^7.26.7", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -122,13 +122,6 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/core/node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, "node_modules/@babel/core/node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -267,27 +260,27 @@ } }, "node_modules/@babel/helpers": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", - "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.7.tgz", + "integrity": "sha512-8NHiL98vsi0mbPQmYAGWwfcFaOy4j2HY49fXJCfuDcdE7fMIsH9a7GdaeXpIBsbT7307WU8KCMp5pUVDNL4f9A==", "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.25.9", - "@babel/types": "^7.26.0" + "@babel/types": "^7.26.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.26.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.5.tgz", - "integrity": "sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.7.tgz", + "integrity": "sha512-kEvgGGgEjRUutvdVvZhbn/BxVt+5VSpwXz1j3WYXQbXDo8KzFOPNG2GQbdAiNq8g6wn1yKk7C/qrke03a84V+w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.26.5" + "@babel/types": "^7.26.7" }, "bin": { "parser": "bin/babel-parser.js" @@ -551,17 +544,17 @@ } }, "node_modules/@babel/traverse": { - "version": "7.26.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.5.tgz", - "integrity": "sha512-rkOSPOw+AXbgtwUga3U4u8RpoK9FEFWBNAlTpcnkLFjL5CT+oyHNuUUC/xx6XefEJ16r38r8Bc/lfp6rYuHeJQ==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.7.tgz", + "integrity": "sha512-1x1sgeyRLC3r5fQOM0/xtQKsYjyxmFjaOrLJNtZ81inNjyJHGIolTULPiSc/2qe1/qfpFLisLQYFnnZl7QoedA==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.26.2", "@babel/generator": "^7.26.5", - "@babel/parser": "^7.26.5", + "@babel/parser": "^7.26.7", "@babel/template": "^7.25.9", - "@babel/types": "^7.26.5", + "@babel/types": "^7.26.7", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -580,9 +573,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.5.tgz", - "integrity": "sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.7.tgz", + "integrity": "sha512-t8kDRGrKXyp6+tjUh7hw2RLyclsW4TRoRvRHtSyAX9Bb5ldlFh+90YAYY6awRXrlB4G5G2izNeGySpATlFzmOg==", "dev": true, "license": "MIT", "dependencies": { @@ -1149,28 +1142,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@jest/reporters/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -1280,13 +1251,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@jest/transform/node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, "node_modules/@jest/transform/node_modules/write-file-atomic": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", @@ -3646,6 +3610,24 @@ "node": ">=10" } }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/ci-info": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", @@ -3776,6 +3758,13 @@ "node": ">= 0.6" } }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -4655,6 +4644,28 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "6.0.2", "dev": true, @@ -5306,28 +5317,6 @@ } } }, - "node_modules/jest-config/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/jest-config/node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -5643,28 +5632,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-runtime/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/jest-runtime/node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -6921,6 +6888,22 @@ "dev": true, "license": "MIT" }, + "node_modules/readdirp": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.1.tgz", + "integrity": "sha512-h80JrZu/MHUZCyHu5ciuoI0+WxsCxzxJTILn6Fs8rxSnFPh+UVHYfeIxK1nVGugMqkfC4vJcBOYbkfkwYK0+gw==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/require-directory": { "version": "2.1.1", "dev": true, @@ -7557,28 +7540,6 @@ "node": ">=8" } }, - "node_modules/test-exclude/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/text-decoder": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.3.tgz", @@ -7893,13 +7854,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/v8-to-istanbul/node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index 59bdca0..3ca0247 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,13 @@ "scripts": { "test": "jest", "test:cov": "jest --coverage", - "build": "swc src --out-dir out", - "build:link": "npm run prepack && npm run cp:files && npm link ./out/src", - "gen:types": "tsc -p tsconfig.cjs.json --declaration --emitDeclarationOnly", - "cp:types": "npm run gen:types && cp -R ./types/* ./out/src", - "cp:files": "cp ./readme.md ./package*.json ./out/src && cp -R ./media ./out/src", + "build": "tsc -p tsconfig.cjs.json", + "tsc:cp:files": "cp ./readme.md ./package*.json ./out/ && cp -R ./media ./out/", + "swc:build": "swc src --out-dir out", + "swc:build:link": "npm run prepack && npm run cp:files && npm link ./out/src", + "swc:gen:types": "tsc -p tsconfig.cjs.json --declaration --emitDeclarationOnly", + "swc:cp:types": "npm run gen:types && cp -R ./types/* ./out/src", + "swc:cp:files": "cp ./readme.md ./package*.json ./out/src && cp -R ./media ./out/src", "sim:pack": "npm run build && npm run cp:files && npm run cp:types", "prepare": "husky", "precommit": "lint-staged", diff --git a/release.config.mjs b/release.config.mjs index a2fcba5..52c0b69 100644 --- a/release.config.mjs +++ b/release.config.mjs @@ -32,7 +32,7 @@ export default { changelogFile: "CHANGELOG.md", }, ], - ["@semantic-release/npm", { pkgRoot: "out/src" }], + ["@semantic-release/npm", { pkgRoot: "out" }], [ "@semantic-release/git", { diff --git a/src/main/libs/DynamicRule.ts b/src/main/libs/DynamicRule.ts index 54b7cf6..ee846e5 100644 --- a/src/main/libs/DynamicRule.ts +++ b/src/main/libs/DynamicRule.ts @@ -1,6 +1,6 @@ import { DefaultRuleStore } from "../store/DefaultRuleStore"; import { RuleLoader } from "./RuleLoader"; -import * as p from "node:path"; +import * as p from "path-browserify"; export class DynamicRule { constructor(className: string) { if (DefaultRuleStore[className] === undefined || DefaultRuleStore[className] === null) { diff --git a/src/main/libs/ParseFlows.ts b/src/main/libs/ParseFlows.ts index b831177..17b8326 100644 --- a/src/main/libs/ParseFlows.ts +++ b/src/main/libs/ParseFlows.ts @@ -1,20 +1,19 @@ import { Flow } from "../models/Flow"; -import { readFile } from "fs/promises"; -import { fileURLToPath } from "url"; -import { convert } from "xmlbuilder2"; -import { realpath } from "fs/promises"; import { ParsedFlow } from "../models/ParsedFlow"; +import p from "path-browserify"; +import fs from "fs"; +import { convert } from "xmlbuilder2"; + export async function ParseFlows(selectedUris: string[]): Promise { const parseResults: ParsedFlow[] = []; for (const uri of selectedUris) { try { - const resolvePath = await realpath(uri); - const absoluteFilePath = fileURLToPath(`file:${resolvePath}`); - const content = await readFile(absoluteFilePath); + const normalizedURI = p.normalize(uri); + const content = await fs.readFileSync(normalizedURI); const xmlString = content.toString(); const flowObj = convert(xmlString, { format: "object" }); - parseResults.push(new ParsedFlow(uri, new Flow(absoluteFilePath, flowObj))); + parseResults.push(new ParsedFlow(uri, new Flow(uri, flowObj))); } catch (e) { parseResults.push(new ParsedFlow(uri, undefined, e)); } diff --git a/src/main/libs/RuleLoader.ts b/src/main/libs/RuleLoader.ts index 5008553..cb1bbc3 100644 --- a/src/main/libs/RuleLoader.ts +++ b/src/main/libs/RuleLoader.ts @@ -1,4 +1,4 @@ -import * as p from "node:path"; +import * as p from "path-browserify"; import type IRuleDefinition from "../interfaces/IRuleDefinition"; export class RuleLoader { diff --git a/src/main/models/Flow.ts b/src/main/models/Flow.ts index be701b5..6b449f7 100644 --- a/src/main/models/Flow.ts +++ b/src/main/models/Flow.ts @@ -4,8 +4,9 @@ import { FlowElement } from "./FlowElement"; import { FlowVariable } from "./FlowVariable"; import { FlowResource } from "./FlowResource"; import { XMLSerializedAsObject } from "xmlbuilder2/lib/interfaces"; + import { create } from "xmlbuilder2"; -import * as p from "node:path"; +import * as p from "path-browserify"; export class Flow { public label: string; @@ -68,9 +69,8 @@ export class Flow { constructor(path?: string, data?: unknown); constructor(path: string, data?: unknown) { if (path) { - const fsProp = p.parse(path); - this.fsPath = p.format(fsProp); - let flowName = p.basename(fsProp["name"]); + this.fsPath = p.resolve(path); + let flowName = p.basename(p.basename(this.fsPath), p.extname(this.fsPath)); if (flowName.includes(".")) { flowName = flowName.split(".")[0]; } diff --git a/tests/models/Flow.test.ts b/tests/models/Flow.test.ts index 160a09e..9677bf4 100644 --- a/tests/models/Flow.test.ts +++ b/tests/models/Flow.test.ts @@ -4,8 +4,6 @@ import { XMLBuilder } from "xmlbuilder2/lib/interfaces"; import { Flow } from "../../src/main/models/Flow"; -// import { readFileSync } from "node:fs"; - import { parse, ParsedFlow } from "../../src"; describe("Flow Model", () => { diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 65d50e6..fbb8733 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "resolveJsonModule": true, - "outDir": "types", + "outDir": "out", "lib": ["es2020.string", "es6"], "experimentalDecorators": true, "sourceMap": false,