From d851d0a6d46963e36e9a48118fa5f9784c1555dc Mon Sep 17 00:00:00 2001 From: Robert Strickland Date: Fri, 27 Mar 2026 13:59:46 -0500 Subject: [PATCH 1/4] Searching results highlighting appear as expected. adding TDML zipping Bump actions/setup-node from 6.2.0 to 6.3.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...53b83947a5a98c8d113130e565377fae1a50d02f) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump sbt/setup-sbt from 1.1.18 to 1.1.22 Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1.1.18 to 1.1.22. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](https://github.com/sbt/setup-sbt/compare/1cad58d595b729a71ca2254cdf5b43dd6f42d4bb...508b753e53cb6095967669e0911487d2b9bc9f41) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.1.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump xml-formatter from 3.6.7 to 3.7.0 Bumps [xml-formatter](https://github.com/chrisbottin/xml-formatter) from 3.6.7 to 3.7.0. - [Commits](https://github.com/chrisbottin/xml-formatter/compare/3.6.7...3.7.0) --- updated-dependencies: - dependency-name: xml-formatter dependency-version: 3.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump @tsconfig/svelte from 5.0.5 to 5.0.8 Bumps [@tsconfig/svelte](https://github.com/tsconfig/bases/tree/HEAD/bases) from 5.0.5 to 5.0.8. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/svelte" dependency-version: 5.0.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump fast-xml-parser from 5.5.6 to 5.5.9 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.9. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.5.6...v5.5.9) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Update sbt, scripted-plugin to 1.12.9 Bump protobufjs from 7.5.4 to 7.5.5 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.4 to 7.5.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.5.4...protobufjs-v7.5.5) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 7.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Bump vite from 6.4.1 to 6.4.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.1 to 6.4.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.4.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] fixed 'targetResource' is possibly 'undefined' error Add zipping instructions for TDML files Added instructions for zipping TDML files and associated test cases, including details on file organization and error handling. Update destination paths to use base file names As file are being copied in to the temp file system in preparation for zipping, the destination path was incorrect if the schema file was in a different folder. Update known issues section to v1.6.0 Document path formatting issues in TDML files Adding note about path formatting issues in TDML files when moving between Windows and Linux. Refactor path replacement for schema file. Fix path formatting in TDML file updates Fix regex for targetZip file extension replacement adding TDML zipping Bump actions/setup-node from 6.2.0 to 6.3.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...53b83947a5a98c8d113130e565377fae1a50d02f) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump sbt/setup-sbt from 1.1.18 to 1.1.22 Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1.1.18 to 1.1.22. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](https://github.com/sbt/setup-sbt/compare/1cad58d595b729a71ca2254cdf5b43dd6f42d4bb...508b753e53cb6095967669e0911487d2b9bc9f41) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.1.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump xml-formatter from 3.6.7 to 3.7.0 Bumps [xml-formatter](https://github.com/chrisbottin/xml-formatter) from 3.6.7 to 3.7.0. - [Commits](https://github.com/chrisbottin/xml-formatter/compare/3.6.7...3.7.0) --- updated-dependencies: - dependency-name: xml-formatter dependency-version: 3.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump @tsconfig/svelte from 5.0.5 to 5.0.8 Bumps [@tsconfig/svelte](https://github.com/tsconfig/bases/tree/HEAD/bases) from 5.0.5 to 5.0.8. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/svelte" dependency-version: 5.0.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump fast-xml-parser from 5.5.6 to 5.5.9 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.9. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.5.6...v5.5.9) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Update sbt, scripted-plugin to 1.12.9 Bump protobufjs from 7.5.4 to 7.5.5 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.4 to 7.5.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.5.4...protobufjs-v7.5.5) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 7.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Bump vite from 6.4.1 to 6.4.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.1 to 6.4.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.4.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] fixed 'targetResource' is possibly 'undefined' error Add zipping instructions for TDML files Added instructions for zipping TDML files and associated test cases, including details on file organization and error handling. Update destination paths to use base file names As file are being copied in to the temp file system in preparation for zipping, the destination path was incorrect if the schema file was in a different folder. Update known issues section to v1.6.0 Document path formatting issues in TDML files Adding note about path formatting issues in TDML files when moving between Windows and Linux. Refactor path replacement for schema file. Fix path formatting in TDML file updates Fix regex for targetZip file extension replacement updated documentation CI --- .github/workflows/CI.yml | 8 +- .github/workflows/documentaion.yml | 2 +- .github/workflows/licenses.yml | 4 +- .github/workflows/nightly.yml | 4 +- .github/workflows/release-candidate.yml | 2 +- doc/Wiki.md | 23 ++- package.json | 22 ++- project/build.properties | 2 +- src/adapter/activateDaffodilDebug.ts | 222 +++++++++++++++++++++++- src/svelte/src/utilities/highlights.ts | 12 +- yarn.lock | 64 +++---- 11 files changed, 296 insertions(+), 69 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9d1b203f3..ccf981f3e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,14 +80,14 @@ jobs: java-version: ${{ matrix.java_version }} - name: Install Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ matrix.node }} cache: yarn cache-dependency-path: yarn.lock - name: Setup sbt - uses: sbt/setup-sbt@1cad58d595b729a71ca2254cdf5b43dd6f42d4bb # v1 + uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # v1 ############################################################ # Lint/format checks @@ -151,10 +151,10 @@ jobs: # some runner oses don't have sbt by default - name: Setup sbt - uses: sbt/setup-sbt@1cad58d595b729a71ca2254cdf5b43dd6f42d4bb # v1 + uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # v1 - name: Install Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ matrix.node }} cache: yarn diff --git a/.github/workflows/documentaion.yml b/.github/workflows/documentaion.yml index d82e14ee6..5e416b320 100644 --- a/.github/workflows/documentaion.yml +++ b/.github/workflows/documentaion.yml @@ -40,7 +40,7 @@ jobs: script: | const prBody = context.payload.pull_request.body || ""; const checkbox1Text = "- [x] I have determined that no documentation updates are needed for these changes"; - const checkbox2Text = "- [x] I have added following documentation for these changes"; + const checkbox2Text = "- [x] I have added the following documentation for these changes"; if (!prBody.includes(checkbox1Text) && !prBody.includes(checkbox2Text)) { core.setFailed("❌ Required documentation checkbox not checked. Please check one of the the box before merging."); diff --git a/.github/workflows/licenses.yml b/.github/workflows/licenses.yml index 7e282e3ca..b9aea3d0a 100644 --- a/.github/workflows/licenses.yml +++ b/.github/workflows/licenses.yml @@ -83,7 +83,7 @@ jobs: fetch-depth: 0 - name: Install Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ matrix.node }} cache: yarn @@ -121,7 +121,7 @@ jobs: fetch-depth: 0 - name: Install Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ matrix.node }} cache: yarn diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 305afb769..b959fbdee 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -80,13 +80,13 @@ jobs: java-version: ${{ matrix.java_version }} - name: Install Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ matrix.node }} # some runner oses don't have sbt by default - name: Setup sbt - uses: sbt/setup-sbt@1cad58d595b729a71ca2254cdf5b43dd6f42d4bb # v1 + uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # v1 ############################################################ # Build & Package diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index f8abddf54..3c5601522 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -59,7 +59,7 @@ jobs: java-version: 17 - name: Install Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v4.4.0 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v4.4.0 with: node-version: 20 cache: yarn diff --git a/doc/Wiki.md b/doc/Wiki.md index 33de4d37b..7d1c27a05 100644 --- a/doc/Wiki.md +++ b/doc/Wiki.md @@ -60,9 +60,8 @@ The purpose of Apache Daffodil™ Extension for Visual Studio Code is to ease th - [Data Editor](#data-editor-1) * [Navigation](#navigation) * [Keyboard Shortcuts](#keyboard-shortcuts) -- [Known Issues in v1.4.1](#known-issues-in-v141) +- [Known Issues in v1.6.0](#known-issues-in-v160) * [General Issues](#general-issues) - * [Debugger Issues Originating from 1.4.0](#debugger-issues-originating-from-140) - [Reporting Problems and Requesting New Features](#reporting-problems-and-requesting-new-features) - [Getting Help](#getting-help) - [Contributing](#contributing) @@ -468,7 +467,16 @@ The original default test case from the temp directory will be appended to the s -Once the Daffodil Parse has finished, an infoset will be created, and a test case will be added to the existing TDML file. To create an archive for a TDML file with multiple test cases, the same guidelines for creating an archive from a TDML file created from a 'Generate TDML' operation should be followed. All DFDL schema files, input data files, the TDML file, and, optionally, the infosets should be added to the archive. Additionally, any directory structure should be preserved in the archive to allow for the relative paths in the TDML file to be resolved. +### Zipping the TDML file & associated files + +To generate a compressed archive of the TDML test cases, you simply need to have the TDML file opened (and in the active tab) in either the TDML editor or a text editor. Then you open the command pallet and find the "Zip TDML file" command and execute it. +The system will automatically collect the appropriate files: first the TDML file itself, then the files specified by the test case(s) in the file. Each test case will have it's associated schema, data, and infoset files placed into a folder with the name of the test case. The TDML file contents will be automatically edited to show the updated location of these files. + +The zip file created will be in the same location as the TDML file and will have the same name as the TDML file with the added extension ".zip" This file can then be transmitted to other users. + +If the execution of the test case contained an error or failed to complete parsing for any reason, the associated infoset will be a zero length file. + +**Note:** The TDML function does not currently support other, local, schema files included into a primary or base schema. Further development will be required to scan the primary schema file to identify these types of files so that they are included into the TDML file and any zipped archive created for that TDML file. When running a zip archive created by another user, extract the archive into your workspace folder. If there is an infoset in the zip archive that you wish to compare with your infoset, make sure that the infoset from the zip archive is not located at the same place as the default infoset for the Daffodil Parse that will be run when executing a test case from the TDML file. This is because the Daffodil Parse run by executing the TDML test case uses the default location for its infoset and will overwrite anything that already exists there. @@ -624,15 +632,12 @@ When using `Single Byte Editing Mode`, `CTRL-ENTER` will insert a byte to the le When browsing the data in the `Physical` or `Logical` viewports, `Home` will take you to the top of the edited file, `End` will take you to the end of the edited file, `Page-Up` will give you the previous page of the edited file, `Page-Down` will give you the next page of the edited file, `Arrow-Up` will give you the previous line of the edited file, and `Arrow-Down` will give you the next line of the edited file. -# Known Issues in v1.4.1 +# Known Issues in v1.6.0 ## General Issues * Some nightly tests are still failing intermittently due to GitHub runners. -* TDML Copy, Execute, and Append Functionality is currently not working on the MacOS Platform - -## Debugger Issues Originating from 1.4.0 - -* At this time the debugger step into and step out actions have no code behind them, using either button results in an unrecoverable error. We have not found a way to disable the step into and step out buttons. This problem occurs in all Operating Systems. This is [noted as a GitHub Issue](https://github.com/apache/daffodil-vscode/issues/5). +* TDML Zipping does not support nested/included schema files. +* Users may encounter issues with path formatting in the TDML file if zip files are moved between Windows & Linux OSs. # Reporting Problems and Requesting New Features diff --git a/package.json b/package.json index 7b713a3d9..a4bae281a 100644 --- a/package.json +++ b/package.json @@ -67,14 +67,14 @@ "unzip-stream": "0.3.4", "wait-port": "1.1.0", "xdg-app-paths": "8.3.0", - "xml-formatter": "^3.6.7", + "xml-formatter": "^3.7.0", "xml-js": "^1.6.11" }, "devDependencies": { "@sveltejs/adapter-static": "3.0.8", "@sveltejs/kit": "^2.53.3", "@sveltejs/vite-plugin-svelte": "^5.0.3", - "@tsconfig/svelte": "^5.0.4", + "@tsconfig/svelte": "^5.0.8", "@types/glob": "^8.0.0", "@types/mocha": "^10.0.3", "@types/node": "^24.0.8", @@ -88,7 +88,7 @@ "concurrently": "^9.2.1", "css-loader": "^7.1.2", "esbuild": "^0.25.10", - "fast-xml-parser": "^5.3.8", + "fast-xml-parser": "^5.5.9", "glob": "13.0.0", "mocha": "11.5.0", "picocolors": "^1.1.1", @@ -106,7 +106,7 @@ "tsconfig-paths": "^4.2.0", "tsx": "^4.21.0", "typescript": "5.2.2", - "vite": "^6.4.1", + "vite": "^6.4.2", "vscode-extension-tester": "5.9.1" }, "resolutions": { @@ -267,6 +267,10 @@ { "command": "extension.dfdl-debug.executeTDML", "when": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" + }, + { + "command": "extension.dfdl-debug.zipTDML", + "when": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" } ], "commandPalette": [ @@ -290,6 +294,10 @@ "command": "extension.dfdl-debug.createTDML", "when": "true" }, + { + "command": "extension.dfdl-debug.zipTDML", + "when": "true" + }, { "command": "extension.data.edit", "when": "true" @@ -370,6 +378,12 @@ "category": "Daffodil Debug", "enablement": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" }, + { + "command": "extension.dfdl-debug.zipTDML", + "title": "Zip TDML File", + "category": "Daffodil Debug", + "enablement": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" + }, { "command": "extension.dfdl-debug.createTDML", "title": "Create TDML File", diff --git a/project/build.properties b/project/build.properties index 0166cc57f..2bc9e0ba2 100644 --- a/project/build.properties +++ b/project/build.properties @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -sbt.version = 1.12.7 +sbt.version = 1.12.9 diff --git a/src/adapter/activateDaffodilDebug.ts b/src/adapter/activateDaffodilDebug.ts index 8bcbca7ac..e05bd474e 100644 --- a/src/adapter/activateDaffodilDebug.ts +++ b/src/adapter/activateDaffodilDebug.ts @@ -16,6 +16,8 @@ import * as dataEditClient from '../dataEditor' import * as tdmlEditor from '../tdmlEditor' import * as rootCompletion from '../rootCompletion' import { tmpdir } from 'os' +import JSZip from 'jszip' +import { rm } from 'node:fs/promises' import { CancellationToken, @@ -31,6 +33,7 @@ import { handleDebugEvent } from './daffodilEvent' import { InlineDebugAdapterFactory } from './extension' import { appendTestCase, + readTDMLFileContents, getTmpTDMLFilePath, copyTestCase, TMP_TDML_FILENAME, @@ -39,10 +42,32 @@ import xmlFormat from 'xml-formatter' import { CommandsProvider } from '../views/commands' import * as daffodilDebugErrors from './daffodilDebugErrors' import { TDMLProvider } from '../tdmlEditor/TDMLProvider' +import { getTestCaseDisplayData } from '../tdmlEditor/utilities/tdmlXmlUtils' export const outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel('Daffodil') +async function createDirectory(directoryPath: string): Promise { + try { + await fs.mkdirSync(directoryPath, { recursive: true }) + console.log(`Directory created successfully at ${directoryPath}`) + } catch (error) { + console.error(`Error creating directory:`, error) + } +} + +async function copyFileAsync(src: string, dest: string) { + try { + // Ensure directory exists first + await fs.promises.mkdir(path.dirname(dest), { recursive: true }) + + await fs.promises.copyFile(src, dest) + console.log(`'${src}' was copied to '${dest}'`) + } catch (err) { + console.error('Error copying file:', err) + } +} + /** Method to file path for schema and data * Details: * Required so that the vscode api commands: @@ -153,8 +178,11 @@ async function createDebugRunFileConfigs( if (!targetResource) { if (vscode.window.activeTextEditor) { targetResource = vscode.window.activeTextEditor.document.uri - } else if (TDMLProvider.getDocumentUri()) { - targetResource = TDMLProvider.getDocumentUri() + } else { + const tdmlUri = TDMLProvider.getDocumentUri() + if (tdmlUri) { + targetResource = tdmlUri + } } } @@ -323,12 +351,166 @@ export function activateDaffodilDebug( console.log(reason) }) } + } + ), + vscode.commands.registerCommand( + 'extension.dfdl-debug.zipTDML', + async (resource: vscode.Uri) => { + if (!fs.existsSync(getTmpTDMLFilePath())) { + vscode.window.showErrorMessage( + `TDML ERROR: Test suite not found. Ensure that the TDML action is set to "generate" for your DFDL debugging launch configuration before copying.` + ) + console.error( + `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not found in ${tmpdir()} for Copy TDML operation.` + ) + return + } + let targetResource: vscode.Uri | undefined = resource + + if (!targetResource) { + if (vscode.window.activeTextEditor) { + targetResource = vscode.window.activeTextEditor.document.uri + } else { + const tdmlUri = TDMLProvider.getDocumentUri() + if (tdmlUri) { + targetResource = tdmlUri + } + } + } + + const resolvedResource = targetResource + + // create temp zip folder + let tmpDir = path.dirname(getTmpTDMLFilePath()) + createDirectory(tmpDir + '_zipdir') + let zipDir = path.join(tmpDir, '_zipdir') + + // copy TDML file to zip folder + await copyFileAsync( + resolvedResource.fsPath, + path.join(zipDir, path.basename(resolvedResource.fsPath)) + ) + + // read TDML file to see what files are required... + await readTDMLFileContents( + path.join(zipDir, path.basename(resolvedResource.fsPath)) + ).then(async (xmlBuffer) => { + await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => { + testSuiteData.testCases.forEach((testCase) => { + // create subdir for testcase + let testCaseDir = path.join(zipDir, testCase.testCaseName) + createDirectory(testCaseDir) + // copy schema file + let xsdFile = testCase.testCaseModel + let xsdFileSrc = path.join( + path.dirname(resolvedResource.fsPath), + xsdFile + ) + let xsdFileDest = path.join(testCaseDir, path.basename(xsdFile)) + try { + fs.copyFileSync(xsdFileSrc, xsdFileDest) + console.log(`'${xsdFileSrc}' was copied to '${xsdFileDest}'`) + } catch (err) { + console.error('Error copying file:', err) + } + + // edit path in copied TDML file + let updatedBuffer = xmlBuffer.replace( + `model="${xsdFile}"`, + `model="${path.join(testCase.testCaseName, path.basename(xsdFile))}"` + ) + xmlBuffer = updatedBuffer + + // copy data file + testCase.dataDocuments.forEach((dataDocuments) => { + let dataFile = path.basename(dataDocuments.trim()) + let dataFileSrc = path.join( + path.dirname(resolvedResource.fsPath), + dataDocuments.trim() + ) + let dataFileDest = path.join( + testCaseDir, + path.basename(dataFile) + ) + try { + fs.copyFileSync(dataFileSrc, dataFileDest) + console.log( + `'${dataFileSrc}' was copied to '${dataFileDest}'` + ) + } catch (err) { + console.error(`Error copying file:'${dataFileSrc}'`, err) + } + + // edit path in copied TDML file + let updatedBuffer = xmlBuffer.replace( + dataDocuments.trim(), + path.join(testCase.testCaseName, dataFile) + ) + xmlBuffer = updatedBuffer + }) + + // copy infoset file + testCase.dfdlInfosets.forEach((dfdlInfosets) => { + let infoFile = path.basename(dfdlInfosets.trim()) + let infoSrc = path.join( + path.dirname(resolvedResource.fsPath), + dfdlInfosets.trim() + ) + let infoDest = path.join( + testCaseDir, + path.basename(dfdlInfosets.trim()) + ) + try { + fs.copyFileSync(infoSrc, infoDest) + console.log(`'${infoSrc}' was copied to '${infoDest}'`) + } catch (err) { + console.error(`Error copying file:'${infoSrc}'`, err) + } + // edit path in copied TDML file + let infoUpdatedBuffer = xmlBuffer.replace( + dfdlInfosets.trim(), + path.join(testCase.testCaseName, infoFile) + ) + xmlBuffer = infoUpdatedBuffer + }) + }) + }) + // write updated info back to TDML file + try { + // Synchronously writes data to a file, replacing it if it already exists + fs.writeFileSync( + path.join(zipDir, path.basename(resolvedResource.fsPath)), + xmlBuffer, + { encoding: 'utf8' } + ) + console.log('Updated schema file written successfully') + } catch (err) { + console.error('Error writing updated schema file:', err) + } + }) + + // zip folders + const zip = new JSZip() - // fs.copyFile( - // getTmpTDMLFilePath(), - // targetResource as unknown as string, - // (_) => {} - // ) + // Add the folder content recursively + addFolderToZip(zipDir, zip) + + // Generate and save + let targetZip = targetResource.fsPath.replace(/tdml$/, 'tdml.zip') + zip.generateAsync({ type: 'nodebuffer' }).then((content) => { + fs.writeFileSync(targetZip, content) + }) + console.log(`Zip file written successfully: '${targetZip}'`) + vscode.window.showInformationMessage( + `Zip file successfully created: '${targetZip}'` + ) + // remove temp files + try { + await rm(zipDir, { recursive: true, force: true }) + console.log(`Temp directory successfully removed: '${zipDir}'`) + } catch (err) { + console.error(`Error while deleting '${zipDir}' directory: ${err}`) + } } ), vscode.commands.registerCommand( @@ -677,3 +859,29 @@ export const workspaceFileAccessor: FileAccessor = { } }, } + +/** + * Recursively adds files and folders to a JSZip instance. + * @param dirPath The folder to add + * @param zip The JSZip instance + */ +function addFolderToZip(dirPath: string, zip: JSZip) { + const files = fs.readdirSync(dirPath) + + for (const file of files) { + const filePath = path.join(dirPath, file) + const stats = fs.statSync(filePath) + + if (stats.isDirectory()) { + // Create a subfolder in the ZIP and recurse + const subFolder = zip.folder(file) + if (subFolder) { + addFolderToZip(filePath, subFolder) + } + } else { + // Read file data and add to current zip/folder + const fileData = fs.readFileSync(filePath) + zip.file(file, fileData) + } + } +} diff --git a/src/svelte/src/utilities/highlights.ts b/src/svelte/src/utilities/highlights.ts index e00cca1a8..ce35e2bc8 100644 --- a/src/svelte/src/utilities/highlights.ts +++ b/src/svelte/src/utilities/highlights.ts @@ -99,23 +99,23 @@ class ViewportByteIndications extends SimpleWritable { if (selectionData.active || selectionData.makingSelection()) { const offsetPartitions = [ generateSelectionCategoryParition(0, start, (byte) => { - byte[0] &= ~category1.indexOf('selected') + return (byte &= ~category1.indexOf('selected')) }), generateSelectionCategoryParition(start, editedEnd, (byte) => { - byte[0] |= category1.indexOf('selected') + return (byte |= category1.indexOf('selected')) }), generateSelectionCategoryParition( Math.max(originalEnd, editedEnd), VIEWPORT_CAPACITY_MAX, (byte) => { - byte[0] &= ~category1.indexOf('selected') + return (byte &= ~category1.indexOf('selected')) } ), ] this.store.update((indications) => { for (const partition of offsetPartitions) { for (let i = partition.start; i < partition.end; i++) - partition.assignByte(indications.subarray(i, i + 1)) + indications[i] = partition.assignByte(indications[i]) } return indications }) @@ -137,12 +137,12 @@ export const viewportByteIndicators = new ViewportByteIndications() type CategoryOffsetParition = { start: number end: number - assignByte: (byte: Uint8Array) => void + assignByte: (byte: number) => number } function generateSelectionCategoryParition( start: number, end: number, - assignmentFn: (byte: Uint8Array) => void + assignmentFn: (byte: number) => number ): CategoryOffsetParition { return { start, diff --git a/yarn.lock b/yarn.lock index 98ba31efe..89d0a4d36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1065,10 +1065,10 @@ resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== -"@tsconfig/svelte@^5.0.4": - version "5.0.5" - resolved "https://registry.yarnpkg.com/@tsconfig/svelte/-/svelte-5.0.5.tgz#781df887c6a41b574e6972f9e002cea7edf4f450" - integrity sha512-48fAnUjKye38FvMiNOj0J9I/4XlQQiZlpe9xaNPfe8vy2Y1hFBt8g1yqf2EGjVvHavo4jf2lC+TQyENCr4BJBQ== +"@tsconfig/svelte@^5.0.8": + version "5.0.8" + resolved "https://registry.yarnpkg.com/@tsconfig/svelte/-/svelte-5.0.8.tgz#4c0c85e17cf8efb1e079459e1cebbeed80680509" + integrity sha512-UkNnw1/oFEfecR8ypyHIQuWYdkPvHiwcQ78sh+ymIiYoF+uc5H1UBetbjyqT+vgGJ3qQN6nhucJviX6HesWtKQ== "@types/cookie@^0.6.0": version "0.6.0" @@ -2355,14 +2355,14 @@ fast-xml-builder@^1.1.4: dependencies: path-expression-matcher "^1.1.3" -fast-xml-parser@^5.3.8: - version "5.5.6" - resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-5.5.6.tgz#6fc61f5ae06a55a1f058abd6a4f4b5d3e9972cd0" - integrity sha512-3+fdZyBRVg29n4rXP0joHthhcHdPUHaIC16cuyyd1iLsuaO6Vea36MPrxgAzbZna8lhvZeRL8Bc9GP56/J9xEw== +fast-xml-parser@^5.5.9: + version "5.5.9" + resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-5.5.9.tgz#e59637abebec3dbfbb4053b532d787af6ea11527" + integrity sha512-jldvxr1MC6rtiZKgrFnDSvT8xuH+eJqxqOBThUVjYrxssYTo1avZLGql5l0a0BAERR01CadYzZ83kVEkbyDg+g== dependencies: fast-xml-builder "^1.1.4" - path-expression-matcher "^1.1.3" - strnum "^2.1.2" + path-expression-matcher "^1.2.0" + strnum "^2.2.2" fastq@^1.6.0: version "1.19.1" @@ -3205,9 +3205,9 @@ lodash.truncate@^4.4.2: integrity sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw== lodash@^4.17.21: - version "4.17.23" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.23.tgz#f113b0378386103be4f6893388c73d0bde7f2c5a" - integrity sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w== + version "4.18.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.18.1.tgz#ff2b66c1f6326d59513de2407bf881439812771c" + integrity sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q== log-symbols@^4.1.0: version "4.1.0" @@ -3687,10 +3687,10 @@ path-exists@^4.0.0: resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== -path-expression-matcher@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/path-expression-matcher/-/path-expression-matcher-1.1.3.tgz#8bf7c629dc1b114e42b633c071f06d14625b4e0d" - integrity sha512-qdVgY8KXmVdJZRSS1JdEPOKPdTiEK/pi0RkcT2sw1RhXxohdujUlJFPuS1TSkevZ9vzd3ZlL7ULl1MHGTApKzQ== +path-expression-matcher@^1.1.3, path-expression-matcher@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/path-expression-matcher/-/path-expression-matcher-1.2.0.tgz#9bdae3787f43b0857b0269e9caaa586c12c8abee" + integrity sha512-DwmPWeFn+tq7TiyJ2CxezCAirXjFxvaiD03npak3cRjlP9+OjTmSy1EpIrEbh+l6JgUundniloMLDQ/6VTdhLQ== path-is-absolute@^1.0.0: version "1.0.1" @@ -3895,9 +3895,9 @@ process-warning@^5.0.0: integrity sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA== protobufjs@^7.2.5: - version "7.5.4" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.5.4.tgz#885d31fe9c4b37f25d1bb600da30b1c5b37d286a" - integrity sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg== + version "7.5.5" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.5.5.tgz#b7089ca4410374c75150baf277353ef76db69f96" + integrity sha512-3wY1AxV+VBNW8Yypfd1yQY9pXnqTAN+KwQxL8iYm3/BjKYMNg4i0owhEe26PWDOMaIrzeeF98Lqd5NGz4omiIg== dependencies: "@protobufjs/aspromise" "^1.1.2" "@protobufjs/base64" "^1.1.2" @@ -4519,10 +4519,10 @@ strip-json-comments@~2.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== -strnum@^2.1.2: - version "2.2.0" - resolved "https://registry.yarnpkg.com/strnum/-/strnum-2.2.0.tgz#8b582b637e4621f62ff714493e0ce30846f903a6" - integrity sha512-Y7Bj8XyJxnPAORMZj/xltsfo55uOiyHcU2tnAVzHUnSJR/KsEX+9RoDeXEnsXtl/CX4fAcrt64gZ13aGaWPeBg== +strnum@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/strnum/-/strnum-2.2.2.tgz#f11fd94ab62b536ba2ecc615858f3747c2881b3f" + integrity sha512-DnR90I+jtXNSTXWdwrEy9FakW7UX+qUZg28gj5fk2vxxl7uS/3bpI4fjFYVmdK9etptYBPNkpahuQnEwhwECqA== structured-source@^4.0.0: version "4.0.0" @@ -4972,10 +4972,10 @@ version-range@^4.15.0: resolved "https://registry.yarnpkg.com/version-range/-/version-range-4.15.0.tgz#89df1e921b14d37515aab5e42ed4ac0515cab2c1" integrity sha512-Ck0EJbAGxHwprkzFO966t4/5QkRuzh+/I1RxhLgUKKwEn+Cd8NwM60mE3AqBZg5gYODoXW0EFsQvbZjRlvdqbg== -vite@^6.4.1: - version "6.4.1" - resolved "https://registry.yarnpkg.com/vite/-/vite-6.4.1.tgz#afbe14518cdd6887e240a4b0221ab6d0ce733f96" - integrity sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g== +vite@^6.4.2: + version "6.4.2" + resolved "https://registry.yarnpkg.com/vite/-/vite-6.4.2.tgz#a4e548ca3a90ca9f3724582cab35e1ba15efc6f2" + integrity sha512-2N/55r4JDJ4gdrCvGgINMy+HH3iRpNIz8K6SFwVsA+JbQScLiC+clmAxBgwiSPgcG9U15QmvqCGWzMbqda5zGQ== dependencies: esbuild "^0.25.0" fdir "^6.4.4" @@ -5125,10 +5125,10 @@ xdg-portable@^10.6.0: optionalDependencies: fsevents "*" -xml-formatter@^3.6.7: - version "3.6.7" - resolved "https://registry.yarnpkg.com/xml-formatter/-/xml-formatter-3.6.7.tgz#75d140e6dbe19b3e956ef20ef55f421c52ef8cc0" - integrity sha512-IsfFYJQuoDqtUlKhm4EzeoBOb+fQwzQVeyxxAQ0sThn/nFnQmyLPTplqq4yRhaOENH/tAyujD2TBfIYzUKB6hg== +xml-formatter@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/xml-formatter/-/xml-formatter-3.7.0.tgz#ac6f8c02e2388759652e9d0c8a4b5b3dfc0694e5" + integrity sha512-+8qTc3zv2UcJ1v9IsSIce37Dl4MQG14Cp7tWrwmy202UaI1wqRukw5QMX1JHsV+DX64yw77EgGsj2s5wGvuMbQ== dependencies: xml-parser-xo "^4.1.5" From e45175a71e55505edd9846863c3e9b48806c5d66 Mon Sep 17 00:00:00 2001 From: Larry Barber Date: Tue, 28 Apr 2026 11:58:37 -0400 Subject: [PATCH 2/4] updating after reading comments. --- doc/Wiki.md | 6 +- package.json | 3 +- src/adapter/activateDaffodilDebug.ts | 126 +++++++++++++-------------- 3 files changed, 66 insertions(+), 69 deletions(-) diff --git a/doc/Wiki.md b/doc/Wiki.md index 7d1c27a05..aa6c5307a 100644 --- a/doc/Wiki.md +++ b/doc/Wiki.md @@ -469,8 +469,8 @@ The original default test case from the temp directory will be appended to the s ### Zipping the TDML file & associated files -To generate a compressed archive of the TDML test cases, you simply need to have the TDML file opened (and in the active tab) in either the TDML editor or a text editor. Then you open the command pallet and find the "Zip TDML file" command and execute it. -The system will automatically collect the appropriate files: first the TDML file itself, then the files specified by the test case(s) in the file. Each test case will have it's associated schema, data, and infoset files placed into a folder with the name of the test case. The TDML file contents will be automatically edited to show the updated location of these files. +To generate a compressed archive of the TDML test cases, you simply need to have the TDML file opened (and in the active tab) in either the TDML editor or a text editor. Then you open the command palette and find the "Zip TDML file" command and execute it. +The system will automatically collect the appropriate files: first the TDML file itself, then the files specified by the test case(s) in the file. Each test case will have its associated schema, data, and infoset files placed into a folder with the name of the test case. The TDML file contents will be automatically edited to show the updated location of these files. The zip file created will be in the same location as the TDML file and will have the same name as the TDML file with the added extension ".zip" This file can then be transmitted to other users. @@ -637,7 +637,7 @@ When browsing the data in the `Physical` or `Logical` viewports, `Home` will tak ## General Issues * Some nightly tests are still failing intermittently due to GitHub runners. * TDML Zipping does not support nested/included schema files. -* Users may encounter issues with path formatting in the TDML file if zip files are moved between Windows & Linux OSs. +* TDML cannot handle files that are located on a different drive (Windows). for example, don't run off of C:, then use data or infoset files from D: # Reporting Problems and Requesting New Features diff --git a/package.json b/package.json index a4bae281a..4a61c5e59 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,8 @@ "wait-port": "1.1.0", "xdg-app-paths": "8.3.0", "xml-formatter": "^3.7.0", - "xml-js": "^1.6.11" + "xml-js": "^1.6.11", + "jszip": "^3.10.1" }, "devDependencies": { "@sveltejs/adapter-static": "3.0.8", diff --git a/src/adapter/activateDaffodilDebug.ts b/src/adapter/activateDaffodilDebug.ts index e05bd474e..2821eda40 100644 --- a/src/adapter/activateDaffodilDebug.ts +++ b/src/adapter/activateDaffodilDebug.ts @@ -49,10 +49,11 @@ export const outputChannel: vscode.OutputChannel = async function createDirectory(directoryPath: string): Promise { try { - await fs.mkdirSync(directoryPath, { recursive: true }) + await fs.promises.mkdir(directoryPath, { recursive: true }) console.log(`Directory created successfully at ${directoryPath}`) } catch (error) { console.error(`Error creating directory:`, error) + throw error } } @@ -356,95 +357,85 @@ export function activateDaffodilDebug( vscode.commands.registerCommand( 'extension.dfdl-debug.zipTDML', async (resource: vscode.Uri) => { - if (!fs.existsSync(getTmpTDMLFilePath())) { - vscode.window.showErrorMessage( - `TDML ERROR: Test suite not found. Ensure that the TDML action is set to "generate" for your DFDL debugging launch configuration before copying.` - ) - console.error( - `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not found in ${tmpdir()} for Copy TDML operation.` - ) - return - } let targetResource: vscode.Uri | undefined = resource - - if (!targetResource) { - if (vscode.window.activeTextEditor) { - targetResource = vscode.window.activeTextEditor.document.uri - } else { - const tdmlUri = TDMLProvider.getDocumentUri() - if (tdmlUri) { - targetResource = tdmlUri - } + // + // if (!targetResource) { + if (vscode.window.activeTextEditor) { + targetResource = vscode.window.activeTextEditor.document.uri + } else { + const tdmlUri = TDMLProvider.getDocumentUri() + if (tdmlUri) { + targetResource = tdmlUri } } + // } const resolvedResource = targetResource // create temp zip folder let tmpDir = path.dirname(getTmpTDMLFilePath()) - createDirectory(tmpDir + '_zipdir') - let zipDir = path.join(tmpDir, '_zipdir') + const zipDir = path.posix.join(tmpDir, '_zipdir') + await createDirectory(zipDir) // copy TDML file to zip folder await copyFileAsync( resolvedResource.fsPath, - path.join(zipDir, path.basename(resolvedResource.fsPath)) + path.posix.join(zipDir, path.basename(resolvedResource.fsPath)) ) // read TDML file to see what files are required... await readTDMLFileContents( - path.join(zipDir, path.basename(resolvedResource.fsPath)) + path.posix.join(zipDir, path.basename(resolvedResource.fsPath)) ).then(async (xmlBuffer) => { await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => { testSuiteData.testCases.forEach((testCase) => { // create subdir for testcase - let testCaseDir = path.join(zipDir, testCase.testCaseName) + let testCaseDir = path.posix.join(zipDir, testCase.testCaseName) createDirectory(testCaseDir) // copy schema file let xsdFile = testCase.testCaseModel - let xsdFileSrc = path.join( + let xsdFileSrc = path.posix.join( path.dirname(resolvedResource.fsPath), xsdFile ) - let xsdFileDest = path.join(testCaseDir, path.basename(xsdFile)) - try { - fs.copyFileSync(xsdFileSrc, xsdFileDest) - console.log(`'${xsdFileSrc}' was copied to '${xsdFileDest}'`) - } catch (err) { - console.error('Error copying file:', err) - } + let xsdFileDest = path.posix.join( + testCaseDir, + path.basename(xsdFile) + ) + copyFileAsync(xsdFileSrc, xsdFileDest) // edit path in copied TDML file let updatedBuffer = xmlBuffer.replace( `model="${xsdFile}"`, - `model="${path.join(testCase.testCaseName, path.basename(xsdFile))}"` + `model="${path.posix.join(testCase.testCaseName, path.basename(xsdFile))}"` ) xmlBuffer = updatedBuffer // copy data file testCase.dataDocuments.forEach((dataDocuments) => { let dataFile = path.basename(dataDocuments.trim()) - let dataFileSrc = path.join( + let dataFileSrc = path.posix.join( path.dirname(resolvedResource.fsPath), dataDocuments.trim() ) - let dataFileDest = path.join( + let dataFileDest = path.posix.join( testCaseDir, path.basename(dataFile) ) - try { - fs.copyFileSync(dataFileSrc, dataFileDest) - console.log( - `'${dataFileSrc}' was copied to '${dataFileDest}'` - ) - } catch (err) { - console.error(`Error copying file:'${dataFileSrc}'`, err) - } + copyFileAsync(dataFileSrc, dataFileDest) + // try { + // fs.copyFileSync(dataFileSrc, dataFileDest) + // console.log( + // `'${dataFileSrc}' was copied to '${dataFileDest}'` + // ) + // } catch (err) { + // console.error(`Error copying file:'${dataFileSrc}'`, err) + // } // edit path in copied TDML file let updatedBuffer = xmlBuffer.replace( dataDocuments.trim(), - path.join(testCase.testCaseName, dataFile) + path.posix.join(testCase.testCaseName, dataFile) ) xmlBuffer = updatedBuffer }) @@ -452,24 +443,26 @@ export function activateDaffodilDebug( // copy infoset file testCase.dfdlInfosets.forEach((dfdlInfosets) => { let infoFile = path.basename(dfdlInfosets.trim()) - let infoSrc = path.join( + let infoSrc = path.posix.join( path.dirname(resolvedResource.fsPath), dfdlInfosets.trim() ) - let infoDest = path.join( + let infoDest = path.posix.join( testCaseDir, path.basename(dfdlInfosets.trim()) ) - try { - fs.copyFileSync(infoSrc, infoDest) - console.log(`'${infoSrc}' was copied to '${infoDest}'`) - } catch (err) { - console.error(`Error copying file:'${infoSrc}'`, err) - } + copyFileAsync(infoSrc, infoDest) + // try { + // fs.copyFileSync(infoSrc, infoDest) + // console.log(`'${infoSrc}' was copied to '${infoDest}'`) + // } catch (err) { + // console.error(`Error copying file:'${infoSrc}'`, err) + // } + // edit path in copied TDML file let infoUpdatedBuffer = xmlBuffer.replace( dfdlInfosets.trim(), - path.join(testCase.testCaseName, infoFile) + path.posix.join(testCase.testCaseName, infoFile) ) xmlBuffer = infoUpdatedBuffer }) @@ -479,7 +472,7 @@ export function activateDaffodilDebug( try { // Synchronously writes data to a file, replacing it if it already exists fs.writeFileSync( - path.join(zipDir, path.basename(resolvedResource.fsPath)), + path.posix.join(zipDir, path.basename(resolvedResource.fsPath)), xmlBuffer, { encoding: 'utf8' } ) @@ -495,21 +488,24 @@ export function activateDaffodilDebug( // Add the folder content recursively addFolderToZip(zipDir, zip) - // Generate and save + // Generate, save, and then clean up let targetZip = targetResource.fsPath.replace(/tdml$/, 'tdml.zip') - zip.generateAsync({ type: 'nodebuffer' }).then((content) => { - fs.writeFileSync(targetZip, content) - }) - console.log(`Zip file written successfully: '${targetZip}'`) - vscode.window.showInformationMessage( - `Zip file successfully created: '${targetZip}'` - ) - // remove temp files try { + const content = await zip.generateAsync({ type: 'nodebuffer' }) + fs.writeFileSync(targetZip, content) + console.log(`Zip file written successfully: '${targetZip}'`) + vscode.window.showInformationMessage( + `Zip file successfully created: '${targetZip}'` + ) await rm(zipDir, { recursive: true, force: true }) console.log(`Temp directory successfully removed: '${zipDir}'`) } catch (err) { - console.error(`Error while deleting '${zipDir}' directory: ${err}`) + console.error( + `Error while creating zip file '${targetZip}' or deleting temp directory '${zipDir}': ${err}` + ) + vscode.window.showErrorMessage( + `Failed to create zip file: '${targetZip}'` + ) } } ), @@ -869,7 +865,7 @@ function addFolderToZip(dirPath: string, zip: JSZip) { const files = fs.readdirSync(dirPath) for (const file of files) { - const filePath = path.join(dirPath, file) + const filePath = path.posix.join(dirPath, file) const stats = fs.statSync(filePath) if (stats.isDirectory()) { From 06a697ae3b81ea6f1685295e50659642c0b1d5e3 Mon Sep 17 00:00:00 2001 From: Larry Barber Date: Tue, 28 Apr 2026 12:04:05 -0400 Subject: [PATCH 3/4] clean up comments --- src/adapter/activateDaffodilDebug.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/adapter/activateDaffodilDebug.ts b/src/adapter/activateDaffodilDebug.ts index 2821eda40..62145a8eb 100644 --- a/src/adapter/activateDaffodilDebug.ts +++ b/src/adapter/activateDaffodilDebug.ts @@ -358,8 +358,6 @@ export function activateDaffodilDebug( 'extension.dfdl-debug.zipTDML', async (resource: vscode.Uri) => { let targetResource: vscode.Uri | undefined = resource - // - // if (!targetResource) { if (vscode.window.activeTextEditor) { targetResource = vscode.window.activeTextEditor.document.uri } else { @@ -368,7 +366,6 @@ export function activateDaffodilDebug( targetResource = tdmlUri } } - // } const resolvedResource = targetResource @@ -423,14 +420,6 @@ export function activateDaffodilDebug( path.basename(dataFile) ) copyFileAsync(dataFileSrc, dataFileDest) - // try { - // fs.copyFileSync(dataFileSrc, dataFileDest) - // console.log( - // `'${dataFileSrc}' was copied to '${dataFileDest}'` - // ) - // } catch (err) { - // console.error(`Error copying file:'${dataFileSrc}'`, err) - // } // edit path in copied TDML file let updatedBuffer = xmlBuffer.replace( @@ -452,12 +441,6 @@ export function activateDaffodilDebug( path.basename(dfdlInfosets.trim()) ) copyFileAsync(infoSrc, infoDest) - // try { - // fs.copyFileSync(infoSrc, infoDest) - // console.log(`'${infoSrc}' was copied to '${infoDest}'`) - // } catch (err) { - // console.error(`Error copying file:'${infoSrc}'`, err) - // } // edit path in copied TDML file let infoUpdatedBuffer = xmlBuffer.replace( From 5a0df6fede82e337c4dfead0b1644ac8ef3668ba Mon Sep 17 00:00:00 2001 From: Robert Strickland Date: Fri, 27 Mar 2026 13:59:46 -0500 Subject: [PATCH 4/4] Searching results highlighting appear as expected. adding TDML zipping Bump actions/setup-node from 6.2.0 to 6.3.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...53b83947a5a98c8d113130e565377fae1a50d02f) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump sbt/setup-sbt from 1.1.18 to 1.1.22 Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1.1.18 to 1.1.22. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](https://github.com/sbt/setup-sbt/compare/1cad58d595b729a71ca2254cdf5b43dd6f42d4bb...508b753e53cb6095967669e0911487d2b9bc9f41) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.1.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump xml-formatter from 3.6.7 to 3.7.0 Bumps [xml-formatter](https://github.com/chrisbottin/xml-formatter) from 3.6.7 to 3.7.0. - [Commits](https://github.com/chrisbottin/xml-formatter/compare/3.6.7...3.7.0) --- updated-dependencies: - dependency-name: xml-formatter dependency-version: 3.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump @tsconfig/svelte from 5.0.5 to 5.0.8 Bumps [@tsconfig/svelte](https://github.com/tsconfig/bases/tree/HEAD/bases) from 5.0.5 to 5.0.8. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/svelte" dependency-version: 5.0.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump fast-xml-parser from 5.5.6 to 5.5.9 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.9. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.5.6...v5.5.9) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Update sbt, scripted-plugin to 1.12.9 Bump protobufjs from 7.5.4 to 7.5.5 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.4 to 7.5.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.5.4...protobufjs-v7.5.5) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 7.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Bump vite from 6.4.1 to 6.4.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.1 to 6.4.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.4.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] fixed 'targetResource' is possibly 'undefined' error Add zipping instructions for TDML files Added instructions for zipping TDML files and associated test cases, including details on file organization and error handling. Update destination paths to use base file names As file are being copied in to the temp file system in preparation for zipping, the destination path was incorrect if the schema file was in a different folder. Update known issues section to v1.6.0 Document path formatting issues in TDML files Adding note about path formatting issues in TDML files when moving between Windows and Linux. Refactor path replacement for schema file. Fix path formatting in TDML file updates Fix regex for targetZip file extension replacement adding TDML zipping Bump actions/setup-node from 6.2.0 to 6.3.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...53b83947a5a98c8d113130e565377fae1a50d02f) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump sbt/setup-sbt from 1.1.18 to 1.1.22 Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1.1.18 to 1.1.22. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](https://github.com/sbt/setup-sbt/compare/1cad58d595b729a71ca2254cdf5b43dd6f42d4bb...508b753e53cb6095967669e0911487d2b9bc9f41) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.1.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump xml-formatter from 3.6.7 to 3.7.0 Bumps [xml-formatter](https://github.com/chrisbottin/xml-formatter) from 3.6.7 to 3.7.0. - [Commits](https://github.com/chrisbottin/xml-formatter/compare/3.6.7...3.7.0) --- updated-dependencies: - dependency-name: xml-formatter dependency-version: 3.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump @tsconfig/svelte from 5.0.5 to 5.0.8 Bumps [@tsconfig/svelte](https://github.com/tsconfig/bases/tree/HEAD/bases) from 5.0.5 to 5.0.8. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/svelte" dependency-version: 5.0.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump fast-xml-parser from 5.5.6 to 5.5.9 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.9. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.5.6...v5.5.9) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Update sbt, scripted-plugin to 1.12.9 Bump protobufjs from 7.5.4 to 7.5.5 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.4 to 7.5.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.5.4...protobufjs-v7.5.5) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 7.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Bump vite from 6.4.1 to 6.4.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.1 to 6.4.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.4.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] fixed 'targetResource' is possibly 'undefined' error Add zipping instructions for TDML files Added instructions for zipping TDML files and associated test cases, including details on file organization and error handling. Update destination paths to use base file names As file are being copied in to the temp file system in preparation for zipping, the destination path was incorrect if the schema file was in a different folder. Update known issues section to v1.6.0 Document path formatting issues in TDML files Adding note about path formatting issues in TDML files when moving between Windows and Linux. Refactor path replacement for schema file. Fix path formatting in TDML file updates Fix regex for targetZip file extension replacement updated documentation CI updating after reading comments. clean up comments Searching results highlighting appear as expected. Bump actions/setup-node from 6.2.0 to 6.3.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...53b83947a5a98c8d113130e565377fae1a50d02f) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump sbt/setup-sbt from 1.1.18 to 1.1.22 Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1.1.18 to 1.1.22. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](https://github.com/sbt/setup-sbt/compare/1cad58d595b729a71ca2254cdf5b43dd6f42d4bb...508b753e53cb6095967669e0911487d2b9bc9f41) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.1.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump @tsconfig/svelte from 5.0.5 to 5.0.8 Bumps [@tsconfig/svelte](https://github.com/tsconfig/bases/tree/HEAD/bases) from 5.0.5 to 5.0.8. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/svelte" dependency-version: 5.0.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump fast-xml-parser from 5.5.6 to 5.5.9 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.9. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.5.6...v5.5.9) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Update sbt, scripted-plugin to 1.12.9 Bump protobufjs from 7.5.4 to 7.5.5 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.4 to 7.5.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.5.4...protobufjs-v7.5.5) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 7.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Bump vite from 6.4.1 to 6.4.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.1 to 6.4.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.4.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] change test timeout Update .asf.yaml, remove old ones and add Adedoyin Ogunjobi as a contributor Searching results highlighting appear as expected. Bump actions/setup-node from 6.2.0 to 6.3.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...53b83947a5a98c8d113130e565377fae1a50d02f) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Bump sbt/setup-sbt from 1.1.18 to 1.1.22 Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1.1.18 to 1.1.22. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](https://github.com/sbt/setup-sbt/compare/1cad58d595b729a71ca2254cdf5b43dd6f42d4bb...508b753e53cb6095967669e0911487d2b9bc9f41) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.1.22 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump @tsconfig/svelte from 5.0.5 to 5.0.8 Bumps [@tsconfig/svelte](https://github.com/tsconfig/bases/tree/HEAD/bases) from 5.0.5 to 5.0.8. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/svelte" dependency-version: 5.0.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Bump fast-xml-parser from 5.5.6 to 5.5.9 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.9. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.5.6...v5.5.9) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Update sbt, scripted-plugin to 1.12.9 Bump protobufjs from 7.5.4 to 7.5.5 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.4 to 7.5.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.5.4...protobufjs-v7.5.5) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 7.5.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Bump vite from 6.4.1 to 6.4.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.1 to 6.4.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.4.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] change test timeout Update .asf.yaml, remove old ones and add Adedoyin Ogunjobi as a contributor --- .github/workflows/documentaion.yml | 2 +- doc/Wiki.md | 23 +-- package.json | 17 ++- src/adapter/activateDaffodilDebug.ts | 201 ++++++++++++++++++++++++++- 4 files changed, 225 insertions(+), 18 deletions(-) diff --git a/.github/workflows/documentaion.yml b/.github/workflows/documentaion.yml index d82e14ee6..5e416b320 100644 --- a/.github/workflows/documentaion.yml +++ b/.github/workflows/documentaion.yml @@ -40,7 +40,7 @@ jobs: script: | const prBody = context.payload.pull_request.body || ""; const checkbox1Text = "- [x] I have determined that no documentation updates are needed for these changes"; - const checkbox2Text = "- [x] I have added following documentation for these changes"; + const checkbox2Text = "- [x] I have added the following documentation for these changes"; if (!prBody.includes(checkbox1Text) && !prBody.includes(checkbox2Text)) { core.setFailed("❌ Required documentation checkbox not checked. Please check one of the the box before merging."); diff --git a/doc/Wiki.md b/doc/Wiki.md index 33de4d37b..aa6c5307a 100644 --- a/doc/Wiki.md +++ b/doc/Wiki.md @@ -60,9 +60,8 @@ The purpose of Apache Daffodil™ Extension for Visual Studio Code is to ease th - [Data Editor](#data-editor-1) * [Navigation](#navigation) * [Keyboard Shortcuts](#keyboard-shortcuts) -- [Known Issues in v1.4.1](#known-issues-in-v141) +- [Known Issues in v1.6.0](#known-issues-in-v160) * [General Issues](#general-issues) - * [Debugger Issues Originating from 1.4.0](#debugger-issues-originating-from-140) - [Reporting Problems and Requesting New Features](#reporting-problems-and-requesting-new-features) - [Getting Help](#getting-help) - [Contributing](#contributing) @@ -468,7 +467,16 @@ The original default test case from the temp directory will be appended to the s -Once the Daffodil Parse has finished, an infoset will be created, and a test case will be added to the existing TDML file. To create an archive for a TDML file with multiple test cases, the same guidelines for creating an archive from a TDML file created from a 'Generate TDML' operation should be followed. All DFDL schema files, input data files, the TDML file, and, optionally, the infosets should be added to the archive. Additionally, any directory structure should be preserved in the archive to allow for the relative paths in the TDML file to be resolved. +### Zipping the TDML file & associated files + +To generate a compressed archive of the TDML test cases, you simply need to have the TDML file opened (and in the active tab) in either the TDML editor or a text editor. Then you open the command palette and find the "Zip TDML file" command and execute it. +The system will automatically collect the appropriate files: first the TDML file itself, then the files specified by the test case(s) in the file. Each test case will have its associated schema, data, and infoset files placed into a folder with the name of the test case. The TDML file contents will be automatically edited to show the updated location of these files. + +The zip file created will be in the same location as the TDML file and will have the same name as the TDML file with the added extension ".zip" This file can then be transmitted to other users. + +If the execution of the test case contained an error or failed to complete parsing for any reason, the associated infoset will be a zero length file. + +**Note:** The TDML function does not currently support other, local, schema files included into a primary or base schema. Further development will be required to scan the primary schema file to identify these types of files so that they are included into the TDML file and any zipped archive created for that TDML file. When running a zip archive created by another user, extract the archive into your workspace folder. If there is an infoset in the zip archive that you wish to compare with your infoset, make sure that the infoset from the zip archive is not located at the same place as the default infoset for the Daffodil Parse that will be run when executing a test case from the TDML file. This is because the Daffodil Parse run by executing the TDML test case uses the default location for its infoset and will overwrite anything that already exists there. @@ -624,15 +632,12 @@ When using `Single Byte Editing Mode`, `CTRL-ENTER` will insert a byte to the le When browsing the data in the `Physical` or `Logical` viewports, `Home` will take you to the top of the edited file, `End` will take you to the end of the edited file, `Page-Up` will give you the previous page of the edited file, `Page-Down` will give you the next page of the edited file, `Arrow-Up` will give you the previous line of the edited file, and `Arrow-Down` will give you the next line of the edited file. -# Known Issues in v1.4.1 +# Known Issues in v1.6.0 ## General Issues * Some nightly tests are still failing intermittently due to GitHub runners. -* TDML Copy, Execute, and Append Functionality is currently not working on the MacOS Platform - -## Debugger Issues Originating from 1.4.0 - -* At this time the debugger step into and step out actions have no code behind them, using either button results in an unrecoverable error. We have not found a way to disable the step into and step out buttons. This problem occurs in all Operating Systems. This is [noted as a GitHub Issue](https://github.com/apache/daffodil-vscode/issues/5). +* TDML Zipping does not support nested/included schema files. +* TDML cannot handle files that are located on a different drive (Windows). for example, don't run off of C:, then use data or infoset files from D: # Reporting Problems and Requesting New Features diff --git a/package.json b/package.json index 005ba782c..4a61c5e59 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,8 @@ "wait-port": "1.1.0", "xdg-app-paths": "8.3.0", "xml-formatter": "^3.7.0", - "xml-js": "^1.6.11" + "xml-js": "^1.6.11", + "jszip": "^3.10.1" }, "devDependencies": { "@sveltejs/adapter-static": "3.0.8", @@ -267,6 +268,10 @@ { "command": "extension.dfdl-debug.executeTDML", "when": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" + }, + { + "command": "extension.dfdl-debug.zipTDML", + "when": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" } ], "commandPalette": [ @@ -290,6 +295,10 @@ "command": "extension.dfdl-debug.createTDML", "when": "true" }, + { + "command": "extension.dfdl-debug.zipTDML", + "when": "true" + }, { "command": "extension.data.edit", "when": "true" @@ -370,6 +379,12 @@ "category": "Daffodil Debug", "enablement": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" }, + { + "command": "extension.dfdl-debug.zipTDML", + "title": "Zip TDML File", + "category": "Daffodil Debug", + "enablement": "!inDebugMode && (editorLangId == 'tdml' || activeEditor == 'tdml-editor.editor' || dfdl-debug.tdml-editor-active == 'tdml-editor.editor')" + }, { "command": "extension.dfdl-debug.createTDML", "title": "Create TDML File", diff --git a/src/adapter/activateDaffodilDebug.ts b/src/adapter/activateDaffodilDebug.ts index 8bcbca7ac..62145a8eb 100644 --- a/src/adapter/activateDaffodilDebug.ts +++ b/src/adapter/activateDaffodilDebug.ts @@ -16,6 +16,8 @@ import * as dataEditClient from '../dataEditor' import * as tdmlEditor from '../tdmlEditor' import * as rootCompletion from '../rootCompletion' import { tmpdir } from 'os' +import JSZip from 'jszip' +import { rm } from 'node:fs/promises' import { CancellationToken, @@ -31,6 +33,7 @@ import { handleDebugEvent } from './daffodilEvent' import { InlineDebugAdapterFactory } from './extension' import { appendTestCase, + readTDMLFileContents, getTmpTDMLFilePath, copyTestCase, TMP_TDML_FILENAME, @@ -39,10 +42,33 @@ import xmlFormat from 'xml-formatter' import { CommandsProvider } from '../views/commands' import * as daffodilDebugErrors from './daffodilDebugErrors' import { TDMLProvider } from '../tdmlEditor/TDMLProvider' +import { getTestCaseDisplayData } from '../tdmlEditor/utilities/tdmlXmlUtils' export const outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel('Daffodil') +async function createDirectory(directoryPath: string): Promise { + try { + await fs.promises.mkdir(directoryPath, { recursive: true }) + console.log(`Directory created successfully at ${directoryPath}`) + } catch (error) { + console.error(`Error creating directory:`, error) + throw error + } +} + +async function copyFileAsync(src: string, dest: string) { + try { + // Ensure directory exists first + await fs.promises.mkdir(path.dirname(dest), { recursive: true }) + + await fs.promises.copyFile(src, dest) + console.log(`'${src}' was copied to '${dest}'`) + } catch (err) { + console.error('Error copying file:', err) + } +} + /** Method to file path for schema and data * Details: * Required so that the vscode api commands: @@ -153,8 +179,11 @@ async function createDebugRunFileConfigs( if (!targetResource) { if (vscode.window.activeTextEditor) { targetResource = vscode.window.activeTextEditor.document.uri - } else if (TDMLProvider.getDocumentUri()) { - targetResource = TDMLProvider.getDocumentUri() + } else { + const tdmlUri = TDMLProvider.getDocumentUri() + if (tdmlUri) { + targetResource = tdmlUri + } } } @@ -323,12 +352,144 @@ export function activateDaffodilDebug( console.log(reason) }) } + } + ), + vscode.commands.registerCommand( + 'extension.dfdl-debug.zipTDML', + async (resource: vscode.Uri) => { + let targetResource: vscode.Uri | undefined = resource + if (vscode.window.activeTextEditor) { + targetResource = vscode.window.activeTextEditor.document.uri + } else { + const tdmlUri = TDMLProvider.getDocumentUri() + if (tdmlUri) { + targetResource = tdmlUri + } + } + + const resolvedResource = targetResource + + // create temp zip folder + let tmpDir = path.dirname(getTmpTDMLFilePath()) + const zipDir = path.posix.join(tmpDir, '_zipdir') + await createDirectory(zipDir) + + // copy TDML file to zip folder + await copyFileAsync( + resolvedResource.fsPath, + path.posix.join(zipDir, path.basename(resolvedResource.fsPath)) + ) + + // read TDML file to see what files are required... + await readTDMLFileContents( + path.posix.join(zipDir, path.basename(resolvedResource.fsPath)) + ).then(async (xmlBuffer) => { + await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => { + testSuiteData.testCases.forEach((testCase) => { + // create subdir for testcase + let testCaseDir = path.posix.join(zipDir, testCase.testCaseName) + createDirectory(testCaseDir) + // copy schema file + let xsdFile = testCase.testCaseModel + let xsdFileSrc = path.posix.join( + path.dirname(resolvedResource.fsPath), + xsdFile + ) + let xsdFileDest = path.posix.join( + testCaseDir, + path.basename(xsdFile) + ) + copyFileAsync(xsdFileSrc, xsdFileDest) - // fs.copyFile( - // getTmpTDMLFilePath(), - // targetResource as unknown as string, - // (_) => {} - // ) + // edit path in copied TDML file + let updatedBuffer = xmlBuffer.replace( + `model="${xsdFile}"`, + `model="${path.posix.join(testCase.testCaseName, path.basename(xsdFile))}"` + ) + xmlBuffer = updatedBuffer + + // copy data file + testCase.dataDocuments.forEach((dataDocuments) => { + let dataFile = path.basename(dataDocuments.trim()) + let dataFileSrc = path.posix.join( + path.dirname(resolvedResource.fsPath), + dataDocuments.trim() + ) + let dataFileDest = path.posix.join( + testCaseDir, + path.basename(dataFile) + ) + copyFileAsync(dataFileSrc, dataFileDest) + + // edit path in copied TDML file + let updatedBuffer = xmlBuffer.replace( + dataDocuments.trim(), + path.posix.join(testCase.testCaseName, dataFile) + ) + xmlBuffer = updatedBuffer + }) + + // copy infoset file + testCase.dfdlInfosets.forEach((dfdlInfosets) => { + let infoFile = path.basename(dfdlInfosets.trim()) + let infoSrc = path.posix.join( + path.dirname(resolvedResource.fsPath), + dfdlInfosets.trim() + ) + let infoDest = path.posix.join( + testCaseDir, + path.basename(dfdlInfosets.trim()) + ) + copyFileAsync(infoSrc, infoDest) + + // edit path in copied TDML file + let infoUpdatedBuffer = xmlBuffer.replace( + dfdlInfosets.trim(), + path.posix.join(testCase.testCaseName, infoFile) + ) + xmlBuffer = infoUpdatedBuffer + }) + }) + }) + // write updated info back to TDML file + try { + // Synchronously writes data to a file, replacing it if it already exists + fs.writeFileSync( + path.posix.join(zipDir, path.basename(resolvedResource.fsPath)), + xmlBuffer, + { encoding: 'utf8' } + ) + console.log('Updated schema file written successfully') + } catch (err) { + console.error('Error writing updated schema file:', err) + } + }) + + // zip folders + const zip = new JSZip() + + // Add the folder content recursively + addFolderToZip(zipDir, zip) + + // Generate, save, and then clean up + let targetZip = targetResource.fsPath.replace(/tdml$/, 'tdml.zip') + try { + const content = await zip.generateAsync({ type: 'nodebuffer' }) + fs.writeFileSync(targetZip, content) + console.log(`Zip file written successfully: '${targetZip}'`) + vscode.window.showInformationMessage( + `Zip file successfully created: '${targetZip}'` + ) + await rm(zipDir, { recursive: true, force: true }) + console.log(`Temp directory successfully removed: '${zipDir}'`) + } catch (err) { + console.error( + `Error while creating zip file '${targetZip}' or deleting temp directory '${zipDir}': ${err}` + ) + vscode.window.showErrorMessage( + `Failed to create zip file: '${targetZip}'` + ) + } } ), vscode.commands.registerCommand( @@ -677,3 +838,29 @@ export const workspaceFileAccessor: FileAccessor = { } }, } + +/** + * Recursively adds files and folders to a JSZip instance. + * @param dirPath The folder to add + * @param zip The JSZip instance + */ +function addFolderToZip(dirPath: string, zip: JSZip) { + const files = fs.readdirSync(dirPath) + + for (const file of files) { + const filePath = path.posix.join(dirPath, file) + const stats = fs.statSync(filePath) + + if (stats.isDirectory()) { + // Create a subfolder in the ZIP and recurse + const subFolder = zip.folder(file) + if (subFolder) { + addFolderToZip(filePath, subFolder) + } + } else { + // Read file data and add to current zip/folder + const fileData = fs.readFileSync(filePath) + zip.file(file, fileData) + } + } +}