From 8e58d9ec6f6720ff94821dd7d9009abc87dd6387 Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 26 Jun 2023 10:38:37 -0400 Subject: [PATCH 01/27] added the readline-debug.mjs --- dev/node-fs-utils-dev/readline-debug.mjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 dev/node-fs-utils-dev/readline-debug.mjs diff --git a/dev/node-fs-utils-dev/readline-debug.mjs b/dev/node-fs-utils-dev/readline-debug.mjs new file mode 100644 index 0000000..fcef59b --- /dev/null +++ b/dev/node-fs-utils-dev/readline-debug.mjs @@ -0,0 +1,14 @@ +import readline from 'node:readline' +import { stdin as input, stdout as output } from 'node:process'; +import {promisify} from 'node:util'; + +let rl = readline.createInterface({ + input, + output, + prompt:'hit enter to continue' +}); +const question = promisify(rl.question).bind(rl); +const tmp = await question('What is your name?') +console.log('tmp is ',tmp); + +rl.close(); From 898f0659076a44d5155916b1dfd698307aaf4fba Mon Sep 17 00:00:00 2001 From: JC Date: Wed, 28 Jun 2023 00:02:54 -0400 Subject: [PATCH 02/27] updated notes on paths --- docs/src/readme_vite_press.md | 43 ++++++++++++++++--- docs/src/vitepress/readme_vite_press_paths.md | 8 +++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/docs/src/readme_vite_press.md b/docs/src/readme_vite_press.md index c80a414..a78cb7d 100644 --- a/docs/src/readme_vite_press.md +++ b/docs/src/readme_vite_press.md @@ -2,6 +2,43 @@ 1. Need to use vscode / webstorm to inject the header or w/e * i think there is also called a snippet / wrapper / file template + +## Install +```bash +pnpm add -D vitepress +pnpm dlx vitepress init +``` +```gitignore +/docs/.vitepress/cache/ +/docs/.vitepress/dist/ +``` +```js +import { defineConfig } from 'vitepress' +//append to generated: +export default defineConfig({ + base:"/material-design-3-import-export-ext/", + srcDir: './src',//relative to the package.json vitepress dev + lang: 'en-ca', + //section inside + themeConfig: { + //add better search. https://vitepress.dev/reference/default-theme-search#local-search + search: { + provider: 'local' + }, + socialLinks: [ + { icon: 'github', link: 'https://github.com/codeforwings/material-design-3-import-export-ext' } + ], + markdown:{ + //https://vitepress.dev/reference/site-config#markdown + lineNumbers: true, + space_size: 2,//not sure if this works + } + } +}) + +``` + + # Concepts * "On this page" * Edit on GitHub @@ -29,11 +66,7 @@ Notes --- -## Git Ignore -```gitignore -/docs/.vitepress/cache/ -/docs/.vitepress/dist/ -``` + # Syntax Highlighting [https://github.com/shikijs/shiki/blob/main/docs/languages.md](https://github.com/shikijs/shiki/blob/main/docs/languages.md) ```js diff --git a/docs/src/vitepress/readme_vite_press_paths.md b/docs/src/vitepress/readme_vite_press_paths.md index 129aaa2..306f3f3 100644 --- a/docs/src/vitepress/readme_vite_press_paths.md +++ b/docs/src/vitepress/readme_vite_press_paths.md @@ -85,4 +85,10 @@ docs/src/public/ <<< @/public/some_folder/some_file.json -``` \ No newline at end of file +``` + +## Interesting +```ps1 +# mixing paths actually works in powershell and pwd... with no spaces at least and explorer... crazy +cd C:\Users\Public/bins +``` From 8d07eeccccfd3ff67535929f8e0b326a1a59488d Mon Sep 17 00:00:00 2001 From: JC Date: Wed, 28 Jun 2023 01:07:54 -0400 Subject: [PATCH 03/27] updated all of the resolve paths --- .../vite-press-path-utils.test.mjs | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 dev/node-fs-utils-dev/vite-press-path-utils.test.mjs diff --git a/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs b/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs new file mode 100644 index 0000000..82fc57a --- /dev/null +++ b/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs @@ -0,0 +1,111 @@ +/** + * Also in material design 3.. git + */ + +/** + yarn add mocha -D + + package.json + "imports": { + "##/*": { + "default": "./*" + }, + }, + "type": "module", + + jsconfig.json + { + "compilerOptions": { + "baseUrl": ".", + "paths": { + "##/*": ["./*"] + } + }, + "exclude": ["node_modules", ".nuxt", "dist"] +} + + + + */ +// import { createRequire } from 'module'; +// const require = createRequire(import.meta.url); +// const assert = require('assert'); +// const {describe,it} = require('mocha'); +import assert from 'node:assert'; +import { describe, it} from 'mocha'; +/* +1. +yarn add mocha @babel/polyfill @babel/register @babel/preset-env babel-plugin-module-resolver --dev +yarn add @babel/core --dev +2. +-r @babel/register -r babel-plugin-module-resolver + +3. +.babelrc +{ + + "presets": ["@babel/preset-env"], + "plugins": [ + ["module-resolver", { + "root": ["./src"], + "alias": { + "test": "./test", + "underscore": "lodash", + + "~": "./" + } + }] + ] + +} +test specific timeout +this.timeout(500);//500ms +*/ +/** + * Should put this somewhere safe + * todo filepath needs to be initialized as well... + * @param fileName .json + * @param data will automatically be changed + */ +import fs from 'node:fs'; +function writeToFile(fileName,data,space=2){ + const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; + const filePath = `dev/pbs/test/${sFileName}` + fs.writeFileSync(filePath, + typeof data === 'string' ? data :JSON.stringify(data,null,+space) + ); +} +import {relative,resolve,join} from "node:path/posix"; +import {fileURLToPath} from "url"; + +describe('vite-press-path-utils.test.mjs', function(){ + let viteConfigFile; + /** @type {'docs/.vitepress' | string} - .vitepress config */ + viteConfigFile = 'docs/.vitepress'; + + const testMatrix = [ + //"" is cwd + [resolve(""),"../.."],//,cwd, new URL('./',import.meta.url).pathname??? + [resolve("./src"),"../../src"],//cwd/src, cant be ../src + [resolve("src"),"../../src"],//cwd/src, same as above. left is okay to repeat + [resolve("./docs/src"),"../src"], + [resolve("./docs"),"../"], + ] + it('first try', function(){ + for (let i = 0; i < testMatrix.length; i++) { + const [expectedPath,inputRelativePathParam] = testMatrix[i]; + // destDirCWD = ''; + // const out = relative(inputRelativePathParam,viteConfigFile); + /** Resolve docs/.vitepress with relative path to destination dir */ + const out = resolve(viteConfigFile,inputRelativePathParam);//reverse + // const out = resolve('./',viteConfigFile); + // console.log(import.meta.url); + // const tmp = fileURLToPath(new URL('../..', import.meta.url)) + assert.strictEqual(out,expectedPath); + } + + + //assert.strictEqual(1,1);//require assert + }); + +}); From 8222c8ed3ce2de79ba8d66b88d07de3fc0d4ebb8 Mon Sep 17 00:00:00 2001 From: JC Date: Wed, 28 Jun 2023 12:05:53 -0400 Subject: [PATCH 04/27] updated all of the resolve paths --- .../vite-press-path-utils.test.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs b/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs index 82fc57a..c8f710f 100644 --- a/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs +++ b/dev/node-fs-utils-dev/vite-press-path-utils.test.mjs @@ -89,7 +89,8 @@ describe('vite-press-path-utils.test.mjs', function(){ [resolve("./src"),"../../src"],//cwd/src, cant be ../src [resolve("src"),"../../src"],//cwd/src, same as above. left is okay to repeat [resolve("./docs/src"),"../src"], - [resolve("./docs"),"../"], + // [resolve("./docs"),"../"],//'../' also works and is more clear + [resolve("./docs"),".."],//'../' also works and is more clear ] it('first try', function(){ for (let i = 0; i < testMatrix.length; i++) { @@ -105,6 +106,16 @@ describe('vite-press-path-utils.test.mjs', function(){ } + //assert.strictEqual(1,1);//require assert + }); + it('reverse use case', function(){ + for (let i = 0; i < testMatrix.length; i++) { + const [inputDestinationPath,expectedRelativePath] = testMatrix[i]; //reversed + const out = relative(viteConfigFile, inputDestinationPath);// some of the relative paths may not work + assert.strictEqual(out,expectedRelativePath); + } + + //assert.strictEqual(1,1);//require assert }); From a5644268559bc065df77aedc0aefc446ea679cf2 Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 30 Jun 2023 00:24:22 -0400 Subject: [PATCH 05/27] read --- docs/src/readme_vite_press.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/src/readme_vite_press.md b/docs/src/readme_vite_press.md index a78cb7d..af98a84 100644 --- a/docs/src/readme_vite_press.md +++ b/docs/src/readme_vite_press.md @@ -37,8 +37,6 @@ export default defineConfig({ }) ``` - - # Concepts * "On this page" * Edit on GitHub From 590dd83c8333408df88387894f2647713359be26 Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 30 Jun 2023 23:29:16 -0400 Subject: [PATCH 06/27] updated the function to try with cli --- package.json | 4 +- pnpm-lock.yaml | 272 ------------------------------------- src/cli/cli-index.test.mjs | 100 ++++++++++++++ src/cli/index.mjs | 17 +++ 4 files changed, 119 insertions(+), 274 deletions(-) create mode 100644 src/cli/cli-index.test.mjs create mode 100644 src/cli/index.mjs diff --git a/package.json b/package.json index 96d6488..06766f2 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", "docs:preview": "vitepress preview docs", - "build-rollup:vite": "vite build --mode production" + "build-rollup:vite": "vite build --mode production", + "build-rollup:pkg": "pkg lib/dist/index.js --out-path lib/dist/bins" }, "devDependencies": { "gh-pages": "^4.0.0", "mocha": "^10.2.0", "nuxt": "3.0.0", - "pkg": "^5.8.1", "vite": "^4.3.9", "vitepress": "1.0.0-beta.2", "vitepress-plugin-auto-sidebar": "^1.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 404a25b..87bdae9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,6 @@ devDependencies: nuxt: specifier: 3.0.0 version: 3.0.0(rollup@2.79.1) - pkg: - specifier: ^5.8.1 - version: 5.8.1 vite: specifier: ^4.3.9 version: 4.3.9 @@ -244,15 +241,6 @@ packages: - supports-color dev: true - /@babel/generator@7.18.2: - resolution: {integrity: sha512-W1lG5vUwFvfMd8HVXqdfbuG7RuaSrTCCD8cl8fP8wOivdbtbIg2Db3IWUcgvfxKbbn6ZBGYRW/Zk1MIwK49mgw==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.20.7 - '@jridgewell/gen-mapping': 0.3.2 - jsesc: 2.5.2 - dev: true - /@babel/generator@7.20.7: resolution: {integrity: sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw==} engines: {node: '>=6.9.0'} @@ -434,14 +422,6 @@ packages: js-tokens: 4.0.0 dev: true - /@babel/parser@7.18.4: - resolution: {integrity: sha512-FDge0dFazETFcxGw/EXzOkN8uJp0PC7Qbm+Pe9T+av2zlBpOgunFHkQPPn+eRuClU73JF+98D531UgayY89tow==} - engines: {node: '>=6.0.0'} - hasBin: true - dependencies: - '@babel/types': 7.20.7 - dev: true - /@babel/parser@7.22.5: resolution: {integrity: sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==} engines: {node: '>=6.0.0'} @@ -516,15 +496,6 @@ packages: - supports-color dev: true - /@babel/types@7.19.0: - resolution: {integrity: sha512-YuGopBq3ke25BVSiS6fgF49Ul9gH1x70Bcr6bqRLjWCkcX8Hre1/5+z+IiWOIerRMSSEfGZVB9z9kyq7wVs9YA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-string-parser': 7.19.4 - '@babel/helper-validator-identifier': 7.19.1 - to-fast-properties: 2.0.0 - dev: true - /@babel/types@7.20.7: resolution: {integrity: sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg==} engines: {node: '>=6.9.0'} @@ -1635,11 +1606,6 @@ packages: array-uniq: 1.0.3 dev: true - /array-union@2.1.0: - resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} - engines: {node: '>=8'} - dev: true - /array-uniq@1.0.3: resolution: {integrity: sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==} engines: {node: '>=0.10.0'} @@ -1659,11 +1625,6 @@ packages: resolution: {integrity: sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==} dev: true - /at-least-node@1.0.0: - resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} - engines: {node: '>= 4.0.0'} - dev: true - /autoprefixer@10.4.13(postcss@8.4.21): resolution: {integrity: sha512-49vKpMqcZYsJjwotvt4+h/BCjJVnhGwcLpDt5xkcaOG3eLrG/HUYLagrihYsQ+qrIBgIzX1Rw7a6L8I/ZA1Atg==} engines: {node: ^10 || ^12 || >=14} @@ -1866,10 +1827,6 @@ packages: fsevents: 2.3.2 dev: true - /chownr@1.1.4: - resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} - dev: true - /chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} @@ -2192,18 +2149,6 @@ packages: engines: {node: '>=10'} dev: true - /decompress-response@6.0.0: - resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} - engines: {node: '>=10'} - dependencies: - mimic-response: 3.1.0 - dev: true - - /deep-extend@0.6.0: - resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} - engines: {node: '>=4.0.0'} - dev: true - /deepmerge@4.2.2: resolution: {integrity: sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==} engines: {node: '>=0.10.0'} @@ -2666,11 +2611,6 @@ packages: strip-final-newline: 2.0.0 dev: true - /expand-template@2.0.3: - resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} - engines: {node: '>=6'} - dev: true - /external-editor@3.1.0: resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} engines: {node: '>=4'} @@ -2809,13 +2749,6 @@ packages: engines: {node: '>= 0.6'} dev: true - /from2@2.3.0: - resolution: {integrity: sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==} - dependencies: - inherits: 2.0.4 - readable-stream: 2.3.7 - dev: true - /fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} dev: true @@ -2838,16 +2771,6 @@ packages: universalify: 0.1.2 dev: true - /fs-extra@9.1.0: - resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} - engines: {node: '>=10'} - dependencies: - at-least-node: 1.0.0 - graceful-fs: 4.2.10 - jsonfile: 6.1.0 - universalify: 2.0.0 - dev: true - /fs-memo@1.2.0: resolution: {integrity: sha512-YEexkCpL4j03jn5SxaMHqcO6IuWuqm8JFUYhyCep7Ao89JIYmB8xoKhK7zXXJ9cCaNXpyNH5L3QtAmoxjoHW2w==} dev: true @@ -2958,10 +2881,6 @@ packages: git-up: 7.0.0 dev: true - /github-from-package@0.0.0: - resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} - dev: true - /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -3007,18 +2926,6 @@ packages: engines: {node: '>=4'} dev: true - /globby@11.1.0: - resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} - engines: {node: '>=10'} - dependencies: - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.2.12 - ignore: 5.2.4 - merge2: 1.4.1 - slash: 3.0.0 - dev: true - /globby@13.1.3: resolution: {integrity: sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -3194,14 +3101,6 @@ packages: wrap-ansi: 8.0.1 dev: true - /into-stream@6.0.0: - resolution: {integrity: sha512-XHbaOAvP+uFKUFsOgoNPRjLkwB+I22JFPFe5OjTkQ0nwgj6+pSjb4NmB6VMxaPshLiOf+zcpOCBQuLwC1KHhZA==} - engines: {node: '>=10'} - dependencies: - from2: 2.3.0 - p-is-promise: 3.0.0 - dev: true - /ioredis@5.2.4: resolution: {integrity: sha512-qIpuAEt32lZJQ0XyrloCRdlEdUUNGG9i0UOk6zgzK6igyudNWqEBxfH6OlbnOOoBBvr1WB02mm8fR55CnikRng==} engines: {node: '>=12.22.0'} @@ -3244,12 +3143,6 @@ packages: has: 1.0.3 dev: true - /is-core-module@2.9.0: - resolution: {integrity: sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==} - dependencies: - has: 1.0.3 - dev: true - /is-docker@2.2.1: resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} engines: {node: '>=8'} @@ -3631,11 +3524,6 @@ packages: engines: {node: '>=6'} dev: true - /mimic-response@3.1.0: - resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} - engines: {node: '>=10'} - dev: true - /minimatch@3.0.8: resolution: {integrity: sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==} dependencies: @@ -3662,10 +3550,6 @@ packages: brace-expansion: 2.0.1 dev: true - /minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - dev: true - /minipass@3.3.6: resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} engines: {node: '>=8'} @@ -3697,10 +3581,6 @@ packages: engines: {node: '>=0.4.0'} dev: true - /mkdirp-classic@0.5.3: - resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} - dev: true - /mkdirp@1.0.4: resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} engines: {node: '>=10'} @@ -3761,13 +3641,6 @@ packages: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: true - /multistream@4.1.0: - resolution: {integrity: sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw==} - dependencies: - once: 1.4.0 - readable-stream: 3.6.0 - dev: true - /mute-stream@0.0.8: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} dev: true @@ -3790,10 +3663,6 @@ packages: hasBin: true dev: true - /napi-build-utils@1.0.2: - resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} - dev: true - /nitropack@1.0.0: resolution: {integrity: sha512-788lHgNgC+NKqecwFgMkAQTuTXwuh2hEgOk2sLwV3qPVUogxrl6P3m5eKdt6Mtzx+mlXIw0G/P90B5TNWEqDSQ==} engines: {node: ^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0} @@ -3865,13 +3734,6 @@ packages: - utf-8-validate dev: true - /node-abi@3.43.0: - resolution: {integrity: sha512-QB0MMv+tn9Ur2DtJrc8y09n0n6sw88CyDniWSX2cHW10goQXYPK9ZpFJOktDS4ron501edPX6h9i7Pg+RnH5nQ==} - engines: {node: '>=10'} - dependencies: - semver: 7.3.8 - dev: true - /node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -4119,11 +3981,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /p-is-promise@3.0.0: - resolution: {integrity: sha512-Wo8VsW4IRQSKVXsJCn7TomUaVtyfjVDn3nUP7kE967BQk0CwFpdbZs0X0uk5sW9mkBa9eNM7hCMaG93WUAwxYQ==} - engines: {node: '>=8'} - dev: true - /p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -4251,23 +4108,6 @@ packages: find-up: 4.1.0 dev: true - /pkg-fetch@3.4.2: - resolution: {integrity: sha512-0+uijmzYcnhC0hStDjm/cl2VYdrmVVBpe7Q8k9YBojxmR5tG8mvR9/nooQq3QSXiQqORDVOTY3XqMEqJVIzkHA==} - hasBin: true - dependencies: - chalk: 4.1.2 - fs-extra: 9.1.0 - https-proxy-agent: 5.0.1 - node-fetch: 2.6.7 - progress: 2.0.3 - semver: 7.3.8 - tar-fs: 2.1.1 - yargs: 16.2.0 - transitivePeerDependencies: - - encoding - - supports-color - dev: true - /pkg-types@1.0.1: resolution: {integrity: sha512-jHv9HB+Ho7dj6ItwppRDDl0iZRYBD0jsakHXtFgoLr+cHSF6xC+QL54sJmWxyGxOLYSHm0afhXhXcQDQqH9z8g==} dependencies: @@ -4276,34 +4116,6 @@ packages: pathe: 1.0.0 dev: true - /pkg@5.8.1: - resolution: {integrity: sha512-CjBWtFStCfIiT4Bde9QpJy0KeH19jCfwZRJqHFDFXfhUklCx8JoFmMj3wgnEYIwGmZVNkhsStPHEOnrtrQhEXA==} - hasBin: true - peerDependencies: - node-notifier: '>=9.0.1' - peerDependenciesMeta: - node-notifier: - optional: true - dependencies: - '@babel/generator': 7.18.2 - '@babel/parser': 7.18.4 - '@babel/types': 7.19.0 - chalk: 4.1.2 - fs-extra: 9.1.0 - globby: 11.1.0 - into-stream: 6.0.0 - is-core-module: 2.9.0 - minimist: 1.2.8 - multistream: 4.1.0 - pkg-fetch: 3.4.2 - prebuild-install: 7.1.1 - resolve: 1.22.1 - stream-meter: 1.0.4 - transitivePeerDependencies: - - encoding - - supports-color - dev: true - /postcss-calc@8.2.4(postcss@8.4.21): resolution: {integrity: sha512-SmWMSJmB8MRnnULldx0lQIyhSNvuDl9HfrZkaqqE/WHAhToYsAvDq+yAsA/kIyINDszOp3Rh0GFoNuH5Ypsm3Q==} peerDependencies: @@ -4651,25 +4463,6 @@ packages: resolution: {integrity: sha512-qs2ansoQEwzNiV5eAcRT1p1EC/dmEzaATVDJNiB3g2sRDWdA7b7MurXdJjB2+/WQktGWZwxvDrnuRFbWuIr64g==} dev: true - /prebuild-install@7.1.1: - resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==} - engines: {node: '>=10'} - hasBin: true - dependencies: - detect-libc: 2.0.1 - expand-template: 2.0.3 - github-from-package: 0.0.0 - minimist: 1.2.8 - mkdirp-classic: 0.5.3 - napi-build-utils: 1.0.2 - node-abi: 3.43.0 - pump: 3.0.0 - rc: 1.2.8 - simple-get: 4.0.1 - tar-fs: 2.1.1 - tunnel-agent: 0.6.0 - dev: true - /pretty-bytes@6.0.0: resolution: {integrity: sha512-6UqkYefdogmzqAZWzJ7laYeJnaXDy2/J+ZqiiMtS7t7OfpXWTlaeGMwX8U6EFvPV/YWWEKRkS8hKS4k60WHTOg==} engines: {node: ^14.13.1 || >=16.0.0} @@ -4679,11 +4472,6 @@ packages: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} dev: true - /progress@2.0.3: - resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} - engines: {node: '>=0.4.0'} - dev: true - /protocols@2.0.1: resolution: {integrity: sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==} dev: true @@ -4692,13 +4480,6 @@ packages: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} dev: true - /pump@3.0.0: - resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} - dependencies: - end-of-stream: 1.4.4 - once: 1.4.0 - dev: true - /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -4726,16 +4507,6 @@ packages: flat: 5.0.2 dev: true - /rc@1.2.8: - resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} - hasBin: true - dependencies: - deep-extend: 0.6.0 - ini: 1.3.8 - minimist: 1.2.8 - strip-json-comments: 2.0.1 - dev: true - /read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} dependencies: @@ -5012,23 +4783,6 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true - /simple-concat@1.0.1: - resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} - dev: true - - /simple-get@4.0.1: - resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} - dependencies: - decompress-response: 6.0.0 - once: 1.4.0 - simple-concat: 1.0.1 - dev: true - - /slash@3.0.0: - resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} - engines: {node: '>=8'} - dev: true - /slash@4.0.0: resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==} engines: {node: '>=12'} @@ -5079,12 +4833,6 @@ packages: resolution: {integrity: sha512-3H20QlwQsSm2OvAxWIYhs+j01MzzqwMwGiiO1NQaJYZgJZFPuAbf95/DiKRBSTYIJ2FeGUc+B/6mPGcWP9dO3Q==} dev: true - /stream-meter@1.0.4: - resolution: {integrity: sha512-4sOEtrbgFotXwnEuzzsQBYEV1elAeFSO8rSGeTwabuX1RRn/kEq9JVH7I0MRBhKVRR0sJkr0M0QCH7yOLf9fhQ==} - dependencies: - readable-stream: 2.3.7 - dev: true - /streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} @@ -5139,11 +4887,6 @@ packages: engines: {node: '>=6'} dev: true - /strip-json-comments@2.0.1: - resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} - engines: {node: '>=0.10.0'} - dev: true - /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -5231,15 +4974,6 @@ packages: engines: {node: '>=6'} dev: true - /tar-fs@2.1.1: - resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==} - dependencies: - chownr: 1.1.4 - mkdirp-classic: 0.5.3 - pump: 3.0.0 - tar-stream: 2.2.0 - dev: true - /tar-stream@2.2.0: resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} engines: {node: '>=6'} @@ -5321,12 +5055,6 @@ packages: resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} dev: true - /tunnel-agent@0.6.0: - resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} - dependencies: - safe-buffer: 5.2.1 - dev: true - /type-fest@0.21.3: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs new file mode 100644 index 0000000..d27096d --- /dev/null +++ b/src/cli/cli-index.test.mjs @@ -0,0 +1,100 @@ +/** +yarn add mocha -D + +package.json + "imports": { + "##/*": { + "default": "./*" + }, + }, + "type": "module", + + jsconfig.json + { + "compilerOptions": { + "baseUrl": ".", + "paths": { + "##/*": ["./*"] + } + }, + "exclude": ["node_modules", ".nuxt", "dist"] +} + + + +*/ +// import { createRequire } from 'module'; +// const require = createRequire(import.meta.url); +// const assert = require('assert'); +// const {describe,it} = require('mocha'); +import assert from 'node:assert'; +import { describe, it} from 'mocha'; +/* +1. +yarn add mocha @babel/polyfill @babel/register @babel/preset-env babel-plugin-module-resolver --dev +yarn add @babel/core --dev +2. +-r @babel/register -r babel-plugin-module-resolver + +3. +.babelrc +{ + + "presets": ["@babel/preset-env"], + "plugins": [ + ["module-resolver", { + "root": ["./src"], + "alias": { + "test": "./test", + "underscore": "lodash", + + "~": "./" + } + }] + ] + +} +test specific timeout +this.timeout(500);//500ms +*/ +/** + * Should put this somewhere safe + * todo filepath needs to be initialized as well... + * @param fileName .json + * @param data will automatically be changed + */ +import fs from 'node:fs'; +function writeToFile(fileName,data,space=2){ + const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; + const filePath = `dev/pbs/test/${sFileName}` + fs.writeFileSync(filePath, + typeof data === 'string' ? data :JSON.stringify(data,null,+space) + ); +} +import {spawnSync} from "node:child_process"; + +describe('cli-index.test.mjs', function(){ + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync('node src/cli/index.mjs',["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync('node src/cli/index.mjs',[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); + +}); diff --git a/src/cli/index.mjs b/src/cli/index.mjs new file mode 100644 index 0000000..f3e0728 --- /dev/null +++ b/src/cli/index.mjs @@ -0,0 +1,17 @@ +import {win32ToWin32WSL2} from "##/src/index.mjs"; + +/** + * pnpm install has-flag -D + * https://github.com/sindresorhus/has-flag + * if flags are needed + */ +const args = process.argv; +const [nodePath,scriptPath,...scriptArgs] = args; +// console.log(scriptArgs); +/* lazy validation*/ +if(scriptArgs.length !== 1){ + console.error('error: invalid args'); + process.exit(1); +} +const wslPath = win32ToWin32WSL2(scriptArgs[0]) +console.log(wslPath); From 1ae6cac6aa5f0029d09dd0c651d050e1048bae61 Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 30 Jun 2023 23:50:57 -0400 Subject: [PATCH 07/27] added pkg builder --- src/cli/cli-index.test.mjs | 101 ++++++++++++++++++++++++------------- src/cli/index.mjs | 2 +- src/win32ToWin32WSL2.mjs | 3 ++ vite.config.mjs | 3 +- 4 files changed, 73 insertions(+), 36 deletions(-) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index d27096d..61b994e 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -1,16 +1,16 @@ /** -yarn add mocha -D + yarn add mocha -D -package.json - "imports": { + package.json + "imports": { "##/*": { "default": "./*" }, }, - "type": "module", + "type": "module", - jsconfig.json - { + jsconfig.json + { "compilerOptions": { "baseUrl": ".", "paths": { @@ -22,13 +22,13 @@ package.json -*/ + */ // import { createRequire } from 'module'; // const require = createRequire(import.meta.url); // const assert = require('assert'); // const {describe,it} = require('mocha'); import assert from 'node:assert'; -import { describe, it} from 'mocha'; +import {describe, it} from 'mocha'; /* 1. yarn add mocha @babel/polyfill @babel/register @babel/preset-env babel-plugin-module-resolver --dev @@ -64,37 +64,70 @@ this.timeout(500);//500ms * @param data will automatically be changed */ import fs from 'node:fs'; +import {spawnSync} from "node:child_process"; +import os from "node:os"; + function writeToFile(fileName,data,space=2){ - const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; - const filePath = `dev/pbs/test/${sFileName}` - fs.writeFileSync(filePath, - typeof data === 'string' ? data :JSON.stringify(data,null,+space) - ); + const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; + const filePath = `dev/pbs/test/${sFileName}` + fs.writeFileSync(filePath, + typeof data === 'string' ? data :JSON.stringify(data,null,+space) + ); } -import {spawnSync} from "node:child_process"; describe('cli-index.test.mjs', function(){ - it('verify command line mjs', function(){ - //assert.strictEqual(1,1);//require assert - const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync('node src/cli/index.mjs',["C:\\Users\\Public\\bins"],{shell:true}) - const stdout = out.stdout.toString(); - if(out.status !==0){ - console.error(out.stderr.toString()) - throw out.error; - } - assert.strictEqual(stdout,expected) + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync('node src/cli/index.mjs',["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) - }); + }); it('verify command line mjs error', function(){ - //assert.strictEqual(1,1);//require assert - const out = spawnSync('node src/cli/index.mjs',[],{shell:true}) - // console.log(out.stdout.toString()); - if(out.status !==0){ - assert.ok(true) - // console.error(out.stderr.toString()) - // throw out.error; - } - }); + //assert.strictEqual(1,1);//require assert + const out = spawnSync('node src/cli/index.mjs',[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); }); +describe('cli-index.test.mjs binary win', function(){ + // const binaryPath= "lib/dist/bins" + const binaryCommand = '"lib/dist/bins/index-win.exe"' + if(os.platform() !== 'win32'){ + return true; + } + + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync(binaryCommand,[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); + +}); \ No newline at end of file diff --git a/src/cli/index.mjs b/src/cli/index.mjs index f3e0728..ff6d172 100644 --- a/src/cli/index.mjs +++ b/src/cli/index.mjs @@ -14,4 +14,4 @@ if(scriptArgs.length !== 1){ process.exit(1); } const wslPath = win32ToWin32WSL2(scriptArgs[0]) -console.log(wslPath); +console.log(wslPath);//returns \n, might not want that diff --git a/src/win32ToWin32WSL2.mjs b/src/win32ToWin32WSL2.mjs index 356fda5..f6922a3 100644 --- a/src/win32ToWin32WSL2.mjs +++ b/src/win32ToWin32WSL2.mjs @@ -4,6 +4,9 @@ * * ths might work? * pathWin32ToPosix + * + * doesnt make much sense though... should just convert to ps1 / bash and run test on it. + * exe is too big, also has to go to stdout... */ // import {pathWin32ToPosix} from "./pathReplacement.mjs"; import {pathWin32ToPosix} from "#src/pathReplacement.mjs"; diff --git a/vite.config.mjs b/vite.config.mjs index 2c1888c..8bf46a6 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -34,7 +34,8 @@ export default defineConfig({ formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife') //i lost my jsdocs though... weird entry: [ //"entry" can be a dictionary or array of multiple entry points - fileURLToPath(new URL('./src/index.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/index.mjs', import.meta.url)), + fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs', import.meta.url)), // fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)), // fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)), From ae69b88a796129f120c6f57012478b5ae608e0ac Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 30 Jun 2023 23:53:00 -0400 Subject: [PATCH 08/27] added pkg builder --- src/cli/cli-index.test.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index 61b994e..b0b5642 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -103,6 +103,7 @@ describe('cli-index.test.mjs', function(){ describe('cli-index.test.mjs binary win', function(){ // const binaryPath= "lib/dist/bins" const binaryCommand = '"lib/dist/bins/index-win.exe"' + const binaryCommandWSL = './lib/dist/bins/index-win.exe' if(os.platform() !== 'win32'){ return true; } @@ -118,6 +119,18 @@ describe('cli-index.test.mjs binary win', function(){ } assert.strictEqual(stdout,expected) + }); + it('verify command line wsl', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync('wsl -e',[binaryCommandWSL,"C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + }); it('verify command line mjs error', function(){ //assert.strictEqual(1,1);//require assert From a2fd8405c3a5f50330c8c0f1cac8f9915c2087ae Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 30 Jun 2023 23:57:00 -0400 Subject: [PATCH 09/27] updated to proper binary... --- src/cli/cli-index.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index b0b5642..b1128f8 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -103,7 +103,7 @@ describe('cli-index.test.mjs', function(){ describe('cli-index.test.mjs binary win', function(){ // const binaryPath= "lib/dist/bins" const binaryCommand = '"lib/dist/bins/index-win.exe"' - const binaryCommandWSL = './lib/dist/bins/index-win.exe' + const binaryCommandWSL = './lib/dist/bins/index-linux' if(os.platform() !== 'win32'){ return true; } From 1d34b929695e7863482214e0d13818432c206ec3 Mon Sep 17 00:00:00 2001 From: jasonchan Date: Sat, 1 Jul 2023 00:23:29 -0400 Subject: [PATCH 10/27] updated mac and linux runners --- src/cli/cli-index.test.mjs | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index b1128f8..acbc1ce 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -100,10 +100,14 @@ describe('cli-index.test.mjs', function(){ }); }); +/** + * Didn't even need the index-linux... because it worked with the exe + */ describe('cli-index.test.mjs binary win', function(){ // const binaryPath= "lib/dist/bins" const binaryCommand = '"lib/dist/bins/index-win.exe"' const binaryCommandWSL = './lib/dist/bins/index-linux' + // const binaryCommandWSL = './lib/dist/bins/index-win.exe';//also worked... if(os.platform() !== 'win32'){ return true; } @@ -120,7 +124,7 @@ describe('cli-index.test.mjs binary win', function(){ assert.strictEqual(stdout,expected) }); - it('verify command line wsl', function(){ + it('verify command line wsl', function(){ //assert.strictEqual(1,1);//require assert const expected = "/mnt/c/Users/Public/bins\n" const out = spawnSync('wsl -e',[binaryCommandWSL,"C:\\Users\\Public\\bins"],{shell:true}) @@ -143,4 +147,43 @@ describe('cli-index.test.mjs binary win', function(){ } }); +}); + + +/** + * Don't need this binary. just testing it + * interestingly... it failed + */ +describe('cli-index.test.mjs binary mac', function(){ + // const binaryPath= "lib/dist/bins" + let binaryCommand = './lib/dist/bins/index-macos';// + // binaryCommand = 'lib/dist/bins/index-macos' //this worked too + binaryCommand = './lib/dist/bins/index-macos' //interesting + if(os.platform() !== 'darwin'){ + return true; + } + + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync(binaryCommand,[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); + }); \ No newline at end of file From facd26701af20624eeb457dab69781166fe6f2de Mon Sep 17 00:00:00 2001 From: JC Date: Sat, 1 Jul 2023 00:25:21 -0400 Subject: [PATCH 11/27] updated to proper binary... --- src/cli/cli-index.test.mjs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index acbc1ce..d21bf7e 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -186,4 +186,39 @@ describe('cli-index.test.mjs binary mac', function(){ } }); +}); +/** + * Don't need this binary. just testing it + * interestingly... it failed + */ +describe('cli-index.test.mjs binary deb', function(){ + // const binaryPath= "lib/dist/bins" + let binaryCommand = './lib/dist/bins/index-linux';// + if(os.platform() !== 'linux'){ + return true; + } + + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync(binaryCommand,[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); + }); \ No newline at end of file From 5df654e3b97c688439b57ab18fd747e167595204 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 1 Jul 2023 00:31:05 -0400 Subject: [PATCH 12/27] why can i not edit? --- src/cli/cli-index.test.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index d21bf7e..b819935 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -75,6 +75,9 @@ function writeToFile(fileName,data,space=2){ ); } +/** + * interesting... didnt work for linux and mac... but for wsl? is it the shell? + */ describe('cli-index.test.mjs', function(){ it('verify command line mjs', function(){ //assert.strictEqual(1,1);//require assert From 59f8de158b839d35f16f5c3687842af386017ee6 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 1 Jul 2023 00:39:04 -0400 Subject: [PATCH 13/27] updated unit tests --- src/cli/cli-index.test.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index b819935..8dbe92c 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -66,6 +66,7 @@ this.timeout(500);//500ms import fs from 'node:fs'; import {spawnSync} from "node:child_process"; import os from "node:os"; +import {win32ToWin32WSL2} from "##/src/index.mjs"; function writeToFile(fileName,data,space=2){ const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; @@ -78,6 +79,14 @@ function writeToFile(fileName,data,space=2){ /** * interesting... didnt work for linux and mac... but for wsl? is it the shell? */ +describe('cli-index.test.mjs all',function(){ + it('raw js cmd',function(){ + const sInput = "C:\\Users\\Public\\bins" + const expected = "/mnt/c/Users/Public/bins" + const out = win32ToWin32WSL2(sInput); + assert.strictEqual(out,expected) + }) +}); describe('cli-index.test.mjs', function(){ it('verify command line mjs', function(){ //assert.strictEqual(1,1);//require assert From 0c70a6890e32d2a258d969fb02a71decd8becf62 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 1 Jul 2023 00:42:39 -0400 Subject: [PATCH 14/27] updated unit test --- package.json | 1 + pnpm-lock.yaml | 274 ++++++++++++++++++++++++++++++++++++- src/cli/cli-index.test.mjs | 31 +++-- 3 files changed, 290 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 06766f2..1111532 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "gh-pages": "^4.0.0", "mocha": "^10.2.0", "nuxt": "3.0.0", + "pkg": "^5.8.1", "vite": "^4.3.9", "vitepress": "1.0.0-beta.2", "vitepress-plugin-auto-sidebar": "^1.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 87bdae9..990a2ca 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -14,6 +14,9 @@ devDependencies: nuxt: specifier: 3.0.0 version: 3.0.0(rollup@2.79.1) + pkg: + specifier: ^5.8.1 + version: 5.8.1 vite: specifier: ^4.3.9 version: 4.3.9 @@ -241,6 +244,15 @@ packages: - supports-color dev: true + /@babel/generator@7.18.2: + resolution: {integrity: sha512-W1lG5vUwFvfMd8HVXqdfbuG7RuaSrTCCD8cl8fP8wOivdbtbIg2Db3IWUcgvfxKbbn6ZBGYRW/Zk1MIwK49mgw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.7 + '@jridgewell/gen-mapping': 0.3.2 + jsesc: 2.5.2 + dev: true + /@babel/generator@7.20.7: resolution: {integrity: sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw==} engines: {node: '>=6.9.0'} @@ -422,6 +434,14 @@ packages: js-tokens: 4.0.0 dev: true + /@babel/parser@7.18.4: + resolution: {integrity: sha512-FDge0dFazETFcxGw/EXzOkN8uJp0PC7Qbm+Pe9T+av2zlBpOgunFHkQPPn+eRuClU73JF+98D531UgayY89tow==} + engines: {node: '>=6.0.0'} + hasBin: true + dependencies: + '@babel/types': 7.20.7 + dev: true + /@babel/parser@7.22.5: resolution: {integrity: sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==} engines: {node: '>=6.0.0'} @@ -496,6 +516,15 @@ packages: - supports-color dev: true + /@babel/types@7.19.0: + resolution: {integrity: sha512-YuGopBq3ke25BVSiS6fgF49Ul9gH1x70Bcr6bqRLjWCkcX8Hre1/5+z+IiWOIerRMSSEfGZVB9z9kyq7wVs9YA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.19.4 + '@babel/helper-validator-identifier': 7.19.1 + to-fast-properties: 2.0.0 + dev: true + /@babel/types@7.20.7: resolution: {integrity: sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg==} engines: {node: '>=6.9.0'} @@ -1606,6 +1635,11 @@ packages: array-uniq: 1.0.3 dev: true + /array-union@2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + dev: true + /array-uniq@1.0.3: resolution: {integrity: sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==} engines: {node: '>=0.10.0'} @@ -1625,6 +1659,11 @@ packages: resolution: {integrity: sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==} dev: true + /at-least-node@1.0.0: + resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} + engines: {node: '>= 4.0.0'} + dev: true + /autoprefixer@10.4.13(postcss@8.4.21): resolution: {integrity: sha512-49vKpMqcZYsJjwotvt4+h/BCjJVnhGwcLpDt5xkcaOG3eLrG/HUYLagrihYsQ+qrIBgIzX1Rw7a6L8I/ZA1Atg==} engines: {node: ^10 || ^12 || >=14} @@ -1827,6 +1866,10 @@ packages: fsevents: 2.3.2 dev: true + /chownr@1.1.4: + resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + dev: true + /chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} @@ -2149,6 +2192,18 @@ packages: engines: {node: '>=10'} dev: true + /decompress-response@6.0.0: + resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} + engines: {node: '>=10'} + dependencies: + mimic-response: 3.1.0 + dev: true + + /deep-extend@0.6.0: + resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} + engines: {node: '>=4.0.0'} + dev: true + /deepmerge@4.2.2: resolution: {integrity: sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==} engines: {node: '>=0.10.0'} @@ -2611,6 +2666,11 @@ packages: strip-final-newline: 2.0.0 dev: true + /expand-template@2.0.3: + resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} + engines: {node: '>=6'} + dev: true + /external-editor@3.1.0: resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} engines: {node: '>=4'} @@ -2749,6 +2809,13 @@ packages: engines: {node: '>= 0.6'} dev: true + /from2@2.3.0: + resolution: {integrity: sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==} + dependencies: + inherits: 2.0.4 + readable-stream: 2.3.7 + dev: true + /fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} dev: true @@ -2771,6 +2838,16 @@ packages: universalify: 0.1.2 dev: true + /fs-extra@9.1.0: + resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} + engines: {node: '>=10'} + dependencies: + at-least-node: 1.0.0 + graceful-fs: 4.2.10 + jsonfile: 6.1.0 + universalify: 2.0.0 + dev: true + /fs-memo@1.2.0: resolution: {integrity: sha512-YEexkCpL4j03jn5SxaMHqcO6IuWuqm8JFUYhyCep7Ao89JIYmB8xoKhK7zXXJ9cCaNXpyNH5L3QtAmoxjoHW2w==} dev: true @@ -2881,6 +2958,10 @@ packages: git-up: 7.0.0 dev: true + /github-from-package@0.0.0: + resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} + dev: true + /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2926,6 +3007,18 @@ packages: engines: {node: '>=4'} dev: true + /globby@11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.2.12 + ignore: 5.2.4 + merge2: 1.4.1 + slash: 3.0.0 + dev: true + /globby@13.1.3: resolution: {integrity: sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -3101,6 +3194,14 @@ packages: wrap-ansi: 8.0.1 dev: true + /into-stream@6.0.0: + resolution: {integrity: sha512-XHbaOAvP+uFKUFsOgoNPRjLkwB+I22JFPFe5OjTkQ0nwgj6+pSjb4NmB6VMxaPshLiOf+zcpOCBQuLwC1KHhZA==} + engines: {node: '>=10'} + dependencies: + from2: 2.3.0 + p-is-promise: 3.0.0 + dev: true + /ioredis@5.2.4: resolution: {integrity: sha512-qIpuAEt32lZJQ0XyrloCRdlEdUUNGG9i0UOk6zgzK6igyudNWqEBxfH6OlbnOOoBBvr1WB02mm8fR55CnikRng==} engines: {node: '>=12.22.0'} @@ -3143,6 +3244,12 @@ packages: has: 1.0.3 dev: true + /is-core-module@2.9.0: + resolution: {integrity: sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==} + dependencies: + has: 1.0.3 + dev: true + /is-docker@2.2.1: resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} engines: {node: '>=8'} @@ -3524,6 +3631,11 @@ packages: engines: {node: '>=6'} dev: true + /mimic-response@3.1.0: + resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} + engines: {node: '>=10'} + dev: true + /minimatch@3.0.8: resolution: {integrity: sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==} dependencies: @@ -3550,6 +3662,10 @@ packages: brace-expansion: 2.0.1 dev: true + /minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + dev: true + /minipass@3.3.6: resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} engines: {node: '>=8'} @@ -3581,6 +3697,10 @@ packages: engines: {node: '>=0.4.0'} dev: true + /mkdirp-classic@0.5.3: + resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + dev: true + /mkdirp@1.0.4: resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} engines: {node: '>=10'} @@ -3641,6 +3761,13 @@ packages: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: true + /multistream@4.1.0: + resolution: {integrity: sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw==} + dependencies: + once: 1.4.0 + readable-stream: 3.6.0 + dev: true + /mute-stream@0.0.8: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} dev: true @@ -3663,6 +3790,10 @@ packages: hasBin: true dev: true + /napi-build-utils@1.0.2: + resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} + dev: true + /nitropack@1.0.0: resolution: {integrity: sha512-788lHgNgC+NKqecwFgMkAQTuTXwuh2hEgOk2sLwV3qPVUogxrl6P3m5eKdt6Mtzx+mlXIw0G/P90B5TNWEqDSQ==} engines: {node: ^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0} @@ -3734,6 +3865,13 @@ packages: - utf-8-validate dev: true + /node-abi@3.45.0: + resolution: {integrity: sha512-iwXuFrMAcFVi/ZoZiqq8BzAdsLw9kxDfTC0HMyjXfSL/6CSDAGD5UmR7azrAgWV1zKYq7dUUMj4owusBWKLsiQ==} + engines: {node: '>=10'} + dependencies: + semver: 7.3.8 + dev: true + /node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -3981,6 +4119,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /p-is-promise@3.0.0: + resolution: {integrity: sha512-Wo8VsW4IRQSKVXsJCn7TomUaVtyfjVDn3nUP7kE967BQk0CwFpdbZs0X0uk5sW9mkBa9eNM7hCMaG93WUAwxYQ==} + engines: {node: '>=8'} + dev: true + /p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -4108,6 +4251,23 @@ packages: find-up: 4.1.0 dev: true + /pkg-fetch@3.4.2: + resolution: {integrity: sha512-0+uijmzYcnhC0hStDjm/cl2VYdrmVVBpe7Q8k9YBojxmR5tG8mvR9/nooQq3QSXiQqORDVOTY3XqMEqJVIzkHA==} + hasBin: true + dependencies: + chalk: 4.1.2 + fs-extra: 9.1.0 + https-proxy-agent: 5.0.1 + node-fetch: 2.6.7 + progress: 2.0.3 + semver: 7.3.8 + tar-fs: 2.1.1 + yargs: 16.2.0 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /pkg-types@1.0.1: resolution: {integrity: sha512-jHv9HB+Ho7dj6ItwppRDDl0iZRYBD0jsakHXtFgoLr+cHSF6xC+QL54sJmWxyGxOLYSHm0afhXhXcQDQqH9z8g==} dependencies: @@ -4116,6 +4276,34 @@ packages: pathe: 1.0.0 dev: true + /pkg@5.8.1: + resolution: {integrity: sha512-CjBWtFStCfIiT4Bde9QpJy0KeH19jCfwZRJqHFDFXfhUklCx8JoFmMj3wgnEYIwGmZVNkhsStPHEOnrtrQhEXA==} + hasBin: true + peerDependencies: + node-notifier: '>=9.0.1' + peerDependenciesMeta: + node-notifier: + optional: true + dependencies: + '@babel/generator': 7.18.2 + '@babel/parser': 7.18.4 + '@babel/types': 7.19.0 + chalk: 4.1.2 + fs-extra: 9.1.0 + globby: 11.1.0 + into-stream: 6.0.0 + is-core-module: 2.9.0 + minimist: 1.2.8 + multistream: 4.1.0 + pkg-fetch: 3.4.2 + prebuild-install: 7.1.1 + resolve: 1.22.1 + stream-meter: 1.0.4 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /postcss-calc@8.2.4(postcss@8.4.21): resolution: {integrity: sha512-SmWMSJmB8MRnnULldx0lQIyhSNvuDl9HfrZkaqqE/WHAhToYsAvDq+yAsA/kIyINDszOp3Rh0GFoNuH5Ypsm3Q==} peerDependencies: @@ -4463,6 +4651,25 @@ packages: resolution: {integrity: sha512-qs2ansoQEwzNiV5eAcRT1p1EC/dmEzaATVDJNiB3g2sRDWdA7b7MurXdJjB2+/WQktGWZwxvDrnuRFbWuIr64g==} dev: true + /prebuild-install@7.1.1: + resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==} + engines: {node: '>=10'} + hasBin: true + dependencies: + detect-libc: 2.0.1 + expand-template: 2.0.3 + github-from-package: 0.0.0 + minimist: 1.2.8 + mkdirp-classic: 0.5.3 + napi-build-utils: 1.0.2 + node-abi: 3.45.0 + pump: 3.0.0 + rc: 1.2.8 + simple-get: 4.0.1 + tar-fs: 2.1.1 + tunnel-agent: 0.6.0 + dev: true + /pretty-bytes@6.0.0: resolution: {integrity: sha512-6UqkYefdogmzqAZWzJ7laYeJnaXDy2/J+ZqiiMtS7t7OfpXWTlaeGMwX8U6EFvPV/YWWEKRkS8hKS4k60WHTOg==} engines: {node: ^14.13.1 || >=16.0.0} @@ -4472,6 +4679,11 @@ packages: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} dev: true + /progress@2.0.3: + resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} + engines: {node: '>=0.4.0'} + dev: true + /protocols@2.0.1: resolution: {integrity: sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==} dev: true @@ -4480,6 +4692,13 @@ packages: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} dev: true + /pump@3.0.0: + resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} + dependencies: + end-of-stream: 1.4.4 + once: 1.4.0 + dev: true + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -4507,6 +4726,16 @@ packages: flat: 5.0.2 dev: true + /rc@1.2.8: + resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} + hasBin: true + dependencies: + deep-extend: 0.6.0 + ini: 1.3.8 + minimist: 1.2.8 + strip-json-comments: 2.0.1 + dev: true + /read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} dependencies: @@ -4783,6 +5012,23 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /simple-concat@1.0.1: + resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} + dev: true + + /simple-get@4.0.1: + resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} + dependencies: + decompress-response: 6.0.0 + once: 1.4.0 + simple-concat: 1.0.1 + dev: true + + /slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + dev: true + /slash@4.0.0: resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==} engines: {node: '>=12'} @@ -4833,6 +5079,12 @@ packages: resolution: {integrity: sha512-3H20QlwQsSm2OvAxWIYhs+j01MzzqwMwGiiO1NQaJYZgJZFPuAbf95/DiKRBSTYIJ2FeGUc+B/6mPGcWP9dO3Q==} dev: true + /stream-meter@1.0.4: + resolution: {integrity: sha512-4sOEtrbgFotXwnEuzzsQBYEV1elAeFSO8rSGeTwabuX1RRn/kEq9JVH7I0MRBhKVRR0sJkr0M0QCH7yOLf9fhQ==} + dependencies: + readable-stream: 2.3.7 + dev: true + /streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} @@ -4887,6 +5139,11 @@ packages: engines: {node: '>=6'} dev: true + /strip-json-comments@2.0.1: + resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} + engines: {node: '>=0.10.0'} + dev: true + /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -4974,6 +5231,15 @@ packages: engines: {node: '>=6'} dev: true + /tar-fs@2.1.1: + resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==} + dependencies: + chownr: 1.1.4 + mkdirp-classic: 0.5.3 + pump: 3.0.0 + tar-stream: 2.2.0 + dev: true + /tar-stream@2.2.0: resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} engines: {node: '>=6'} @@ -5055,6 +5321,12 @@ packages: resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} dev: true + /tunnel-agent@0.6.0: + resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} + dependencies: + safe-buffer: 5.2.1 + dev: true + /type-fest@0.21.3: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index 8dbe92c..48c55db 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -3,22 +3,22 @@ package.json "imports": { - "##/*": { - "default": "./*" - }, - }, + "##/*": { + "default": "./*" + }, + }, "type": "module", jsconfig.json { - "compilerOptions": { - "baseUrl": ".", - "paths": { - "##/*": ["./*"] - } - }, - "exclude": ["node_modules", ".nuxt", "dist"] -} + "compilerOptions": { + "baseUrl": ".", + "paths": { + "##/*": ["./*"] + } + }, + "exclude": ["node_modules", ".nuxt", "dist"] + } @@ -139,7 +139,8 @@ describe('cli-index.test.mjs binary win', function(){ it('verify command line wsl', function(){ //assert.strictEqual(1,1);//require assert const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync('wsl -e',[binaryCommandWSL,"C:\\Users\\Public\\bins"],{shell:true}) + // const out = spawnSync('wsl -e',[binaryCommandWSL,"C:\\Users\\Public\\bins"],{shell:true}) + const out = spawnSync('wsl -e',[binaryCommandWSL,"'C:\\Users\\Public\\bins'"],{shell:true}) const stdout = out.stdout.toString(); if(out.status !==0){ console.error(out.stderr.toString()) @@ -178,7 +179,7 @@ describe('cli-index.test.mjs binary mac', function(){ it('verify command line mjs', function(){ //assert.strictEqual(1,1);//require assert const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) + const out = spawnSync(binaryCommand,["'C:\\Users\\Public\\bins'"],{shell:true}) const stdout = out.stdout.toString(); if(out.status !==0){ console.error(out.stderr.toString()) @@ -213,7 +214,7 @@ describe('cli-index.test.mjs binary deb', function(){ it('verify command line mjs', function(){ //assert.strictEqual(1,1);//require assert const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) + const out = spawnSync(binaryCommand,["'C:\\Users\\Public\\bins'"],{shell:true}) const stdout = out.stdout.toString(); if(out.status !==0){ console.error(out.stderr.toString()) From 7aa126627a7f57aafcab43063ab6140f99607a67 Mon Sep 17 00:00:00 2001 From: jasonchan Date: Sat, 1 Jul 2023 00:45:40 -0400 Subject: [PATCH 15/27] just had to single quote for mac and linux to work --- src/cli/cli-index.test.mjs | 262 ++++++++++++++++++------------------- 1 file changed, 131 insertions(+), 131 deletions(-) diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index 48c55db..d701233 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -69,96 +69,96 @@ import os from "node:os"; import {win32ToWin32WSL2} from "##/src/index.mjs"; function writeToFile(fileName,data,space=2){ - const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; - const filePath = `dev/pbs/test/${sFileName}` - fs.writeFileSync(filePath, - typeof data === 'string' ? data :JSON.stringify(data,null,+space) - ); + const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; + const filePath = `dev/pbs/test/${sFileName}` + fs.writeFileSync(filePath, + typeof data === 'string' ? data :JSON.stringify(data,null,+space) + ); } /** * interesting... didnt work for linux and mac... but for wsl? is it the shell? */ describe('cli-index.test.mjs all',function(){ - it('raw js cmd',function(){ - const sInput = "C:\\Users\\Public\\bins" - const expected = "/mnt/c/Users/Public/bins" - const out = win32ToWin32WSL2(sInput); - assert.strictEqual(out,expected) - }) + it('raw js cmd',function(){ + const sInput = "C:\\Users\\Public\\bins" + const expected = "/mnt/c/Users/Public/bins" + const out = win32ToWin32WSL2(sInput); + assert.strictEqual(out,expected) + }) }); describe('cli-index.test.mjs', function(){ - it('verify command line mjs', function(){ - //assert.strictEqual(1,1);//require assert - const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync('node src/cli/index.mjs',["C:\\Users\\Public\\bins"],{shell:true}) - const stdout = out.stdout.toString(); - if(out.status !==0){ - console.error(out.stderr.toString()) - throw out.error; - } - assert.strictEqual(stdout,expected) - - }); - it('verify command line mjs error', function(){ - //assert.strictEqual(1,1);//require assert - const out = spawnSync('node src/cli/index.mjs',[],{shell:true}) - // console.log(out.stdout.toString()); - if(out.status !==0){ - assert.ok(true) - // console.error(out.stderr.toString()) - // throw out.error; - } - }); + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync('node src/cli/index.mjs',["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync('node src/cli/index.mjs',[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); }); /** * Didn't even need the index-linux... because it worked with the exe */ describe('cli-index.test.mjs binary win', function(){ - // const binaryPath= "lib/dist/bins" - const binaryCommand = '"lib/dist/bins/index-win.exe"' - const binaryCommandWSL = './lib/dist/bins/index-linux' - // const binaryCommandWSL = './lib/dist/bins/index-win.exe';//also worked... - if(os.platform() !== 'win32'){ - return true; + // const binaryPath= "lib/dist/bins" + const binaryCommand = '"lib/dist/bins/index-win.exe"' + const binaryCommandWSL = './lib/dist/bins/index-linux' + // const binaryCommandWSL = './lib/dist/bins/index-win.exe';//also worked... + if(os.platform() !== 'win32'){ + return true; + } + + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; } - - it('verify command line mjs', function(){ - //assert.strictEqual(1,1);//require assert - const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync(binaryCommand,["C:\\Users\\Public\\bins"],{shell:true}) - const stdout = out.stdout.toString(); - if(out.status !==0){ - console.error(out.stderr.toString()) - throw out.error; - } - assert.strictEqual(stdout,expected) - - }); - it('verify command line wsl', function(){ - //assert.strictEqual(1,1);//require assert - const expected = "/mnt/c/Users/Public/bins\n" - // const out = spawnSync('wsl -e',[binaryCommandWSL,"C:\\Users\\Public\\bins"],{shell:true}) - const out = spawnSync('wsl -e',[binaryCommandWSL,"'C:\\Users\\Public\\bins'"],{shell:true}) - const stdout = out.stdout.toString(); - if(out.status !==0){ - console.error(out.stderr.toString()) - throw out.error; - } - assert.strictEqual(stdout,expected) - - }); - it('verify command line mjs error', function(){ - //assert.strictEqual(1,1);//require assert - const out = spawnSync(binaryCommand,[],{shell:true}) - // console.log(out.stdout.toString()); - if(out.status !==0){ - assert.ok(true) - // console.error(out.stderr.toString()) - // throw out.error; - } - }); + assert.strictEqual(stdout,expected) + + }); + it('verify command line wsl', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + // const out = spawnSync('wsl -e',[binaryCommandWSL,"C:\\Users\\Public\\bins"],{shell:true}) + const out = spawnSync('wsl -e',[binaryCommandWSL,"'C:\\Users\\Public\\bins'"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; + } + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync(binaryCommand,[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); }); @@ -168,36 +168,36 @@ describe('cli-index.test.mjs binary win', function(){ * interestingly... it failed */ describe('cli-index.test.mjs binary mac', function(){ - // const binaryPath= "lib/dist/bins" - let binaryCommand = './lib/dist/bins/index-macos';// - // binaryCommand = 'lib/dist/bins/index-macos' //this worked too - binaryCommand = './lib/dist/bins/index-macos' //interesting - if(os.platform() !== 'darwin'){ - return true; + // const binaryPath= "lib/dist/bins" + let binaryCommand = './lib/dist/bins/index-macos';// + // binaryCommand = 'lib/dist/bins/index-macos' //this worked too + binaryCommand = './lib/dist/bins/index-macos' //interesting + if(os.platform() !== 'darwin'){ + return true; + } + + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync(binaryCommand,["'C:\\Users\\Public\\bins'"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; } - - it('verify command line mjs', function(){ - //assert.strictEqual(1,1);//require assert - const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync(binaryCommand,["'C:\\Users\\Public\\bins'"],{shell:true}) - const stdout = out.stdout.toString(); - if(out.status !==0){ - console.error(out.stderr.toString()) - throw out.error; - } - assert.strictEqual(stdout,expected) - - }); - it('verify command line mjs error', function(){ - //assert.strictEqual(1,1);//require assert - const out = spawnSync(binaryCommand,[],{shell:true}) - // console.log(out.stdout.toString()); - if(out.status !==0){ - assert.ok(true) - // console.error(out.stderr.toString()) - // throw out.error; - } - }); + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync(binaryCommand,[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); }); /** @@ -205,33 +205,33 @@ describe('cli-index.test.mjs binary mac', function(){ * interestingly... it failed */ describe('cli-index.test.mjs binary deb', function(){ - // const binaryPath= "lib/dist/bins" - let binaryCommand = './lib/dist/bins/index-linux';// - if(os.platform() !== 'linux'){ - return true; + // const binaryPath= "lib/dist/bins" + let binaryCommand = './lib/dist/bins/index-linux';// + if(os.platform() === 'linux'){ + return true; + } + + it('verify command line mjs', function(){ + //assert.strictEqual(1,1);//require assert + const expected = "/mnt/c/Users/Public/bins\n" + const out = spawnSync(binaryCommand,["'C:\\Users\\Public\\bins'"],{shell:true}) + const stdout = out.stdout.toString(); + if(out.status !==0){ + console.error(out.stderr.toString()) + throw out.error; } - - it('verify command line mjs', function(){ - //assert.strictEqual(1,1);//require assert - const expected = "/mnt/c/Users/Public/bins\n" - const out = spawnSync(binaryCommand,["'C:\\Users\\Public\\bins'"],{shell:true}) - const stdout = out.stdout.toString(); - if(out.status !==0){ - console.error(out.stderr.toString()) - throw out.error; - } - assert.strictEqual(stdout,expected) - - }); - it('verify command line mjs error', function(){ - //assert.strictEqual(1,1);//require assert - const out = spawnSync(binaryCommand,[],{shell:true}) - // console.log(out.stdout.toString()); - if(out.status !==0){ - assert.ok(true) - // console.error(out.stderr.toString()) - // throw out.error; - } - }); + assert.strictEqual(stdout,expected) + + }); + it('verify command line mjs error', function(){ + //assert.strictEqual(1,1);//require assert + const out = spawnSync(binaryCommand,[],{shell:true}) + // console.log(out.stdout.toString()); + if(out.status !==0){ + assert.ok(true) + // console.error(out.stderr.toString()) + // throw out.error; + } + }); }); \ No newline at end of file From eb6ea06556a02a3412ec862f4d9fb32e3adb0dfa Mon Sep 17 00:00:00 2001 From: JC Date: Sat, 1 Jul 2023 00:54:20 -0400 Subject: [PATCH 16/27] do i need a path / cmd execute wiki? --- pnpm-lock.yaml | 2 +- src/cli/cli-index.test.mjs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 990a2ca..fc6fbdf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true diff --git a/src/cli/cli-index.test.mjs b/src/cli/cli-index.test.mjs index d701233..d394b6d 100644 --- a/src/cli/cli-index.test.mjs +++ b/src/cli/cli-index.test.mjs @@ -78,6 +78,14 @@ function writeToFile(fileName,data,space=2){ /** * interesting... didnt work for linux and mac... but for wsl? is it the shell? + * + lib/dist/bins/index-win.exe C:\\Users\\Public\\bins #pwsh + "lib/dist/bins/index-win.exe" "C:\\Users\\Public\\bins" #cmd + "./lib/dist/bins/index-win.exe" "C:\\Users\\Public\\bins" #cmd + ./"lib/dist/bins/index-win.exe" "C:\\Users\\Public\\bins" #wsl fish ? + lib/dist/bins/index-linux "'C:\\Users\\Public\\bins'" # wsl / linux + lib/dist/bins/index-macos "'C:\\Users\\Public\\bins'" # macos + * */ describe('cli-index.test.mjs all',function(){ it('raw js cmd',function(){ From 997e9a24e7b381c1f55522e4d5f2364b8c48ec1e Mon Sep 17 00:00:00 2001 From: JC Date: Sun, 2 Jul 2023 01:47:47 -0400 Subject: [PATCH 17/27] updated paths to full --- tests/concepts/nodePath.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/concepts/nodePath.test.mjs b/tests/concepts/nodePath.test.mjs index 841f6a6..44219be 100644 --- a/tests/concepts/nodePath.test.mjs +++ b/tests/concepts/nodePath.test.mjs @@ -78,8 +78,8 @@ function writeToFile(fileName,data,space=2){ import {posix,win32,sep} from 'node:path' -import {pathWin32ToPosix,pathPosixToWin32} from "../../src/pathReplacement.mjs" -import {posixTests, win32Tests} from "../../lib/nodePathTestExamples.mjs"; +import {pathWin32ToPosix,pathPosixToWin32} from "##/src/pathReplacement.mjs" +import {posixTests, win32Tests} from "##/lib/nodePathTestExamples.mjs"; /** * mobaxterm is /drives/c or cd c:/ From b78e777bbb232dccccf1fd48f315662ad62596cd Mon Sep 17 00:00:00 2001 From: JC Date: Sun, 2 Jul 2023 02:12:45 -0400 Subject: [PATCH 18/27] updated SpawnCmd.mjs --- dev/node-fs-utils-dev/SpawnCmd.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/node-fs-utils-dev/SpawnCmd.mjs b/dev/node-fs-utils-dev/SpawnCmd.mjs index b36b46d..bd828a5 100644 --- a/dev/node-fs-utils-dev/SpawnCmd.mjs +++ b/dev/node-fs-utils-dev/SpawnCmd.mjs @@ -11,23 +11,26 @@ import { spawn } from 'node:child_process' import {stdout,stderr} from 'node:process' /** might be better just to use buffer like they are */ -export function spawnExecCmd(cmd,...args){ +export function spawnExecCmd(cmd,args=[],opts={}){ + const actual = {shell:true,...opts} return new Promise((resolve, reject) => { let code, stdouts = [], stderrs = [], signal; - let spawnCmd = spawn(cmd,[],{shell:true}); + // let spawnCmd = spawn(cmd,[],{shell:true}); + let spawnCmd = spawn(cmd,args,actual); //i think on error need to double check spawnCmd.on('error',(err)=>{ reject(err); }); + spawnCmd.stdout.pipe(stdout);//works spawnCmd.stdout.on('data', (data) => { // console.log(`stdout: ${data}`); stdouts.push(data); }); - spawnCmd.stdout.pipe(stdout);//works /* doesnt work pipe on chai, but two on's work n*/ + spawnCmd.stderr.pipe(stderr) spawnCmd.stderr.on('data', (data) => { // console.error(`stderr: ${data}`); stderrs.push(data); From 686cf15c8f94f7165f1782c0ccdeb64112ebed41 Mon Sep 17 00:00:00 2001 From: JC Date: Sun, 2 Jul 2023 02:13:55 -0400 Subject: [PATCH 19/27] updated paths --- app.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.vue b/app.vue index 1c6fa79..2b57b65 100644 --- a/app.vue +++ b/app.vue @@ -55,7 +55,7 @@ import {posixTests, win32Tests} from "~/lib/nodePathTestExamples.mjs"; // import {posixTests, win32Tests} from "##/lib/nodePathTestExamples.mjs"; // import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "##/lib/dist/index.mjs"; -import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "~/lib/dist/index.mjs"; +import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "##/lib/dist/index.mjs"; export default { name:'app', mounted(){ From d2e0e623e393bef6e2066eeb418730797a14029e Mon Sep 17 00:00:00 2001 From: JC Date: Sun, 2 Jul 2023 02:14:43 -0400 Subject: [PATCH 20/27] reverted vite.config.mjsi --- vite.config.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vite.config.mjs b/vite.config.mjs index 8bf46a6..d85887d 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -34,8 +34,8 @@ export default defineConfig({ formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife') //i lost my jsdocs though... weird entry: [ //"entry" can be a dictionary or array of multiple entry points - // fileURLToPath(new URL('./src/index.mjs', import.meta.url)), - fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), + fileURLToPath(new URL('./src/index.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs', import.meta.url)), // fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)), // fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)), From 58023ee00a9186c864bd19f33119f60da92287d7 Mon Sep 17 00:00:00 2001 From: JC Date: Sun, 2 Jul 2023 02:34:39 -0400 Subject: [PATCH 21/27] updated build back... gives index2.mjs --- vite.config.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vite.config.mjs b/vite.config.mjs index d85887d..e26cb8a 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -31,11 +31,12 @@ export default defineConfig({ outDir: fileURLToPath(new URL('./lib/dist/', import.meta.url)), lib: { name: 'nuxt3-win32-posix-path', - formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife') + // formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife') + formats: ['es', 'cjs'],//('es' | 'cjs' | 'umd' | 'iife') //i lost my jsdocs though... weird entry: [ //"entry" can be a dictionary or array of multiple entry points fileURLToPath(new URL('./src/index.mjs', import.meta.url)), - // fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), + fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs', import.meta.url)), // fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)), // fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)), From b659cb6819f106475204c3ea2486ea9618de004e Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Jul 2023 02:16:56 -0400 Subject: [PATCH 22/27] failing two tests... might be how im calling the script as well --- lib/test-utils/pwsh-test-mocha.ps1 | 16 ++++++ src/index.mjs | 2 +- .../win32ToWin32WSL2.mjs | 0 src/win32ToWin32WSL/win32ToWin32WSL2.ps1 | 17 +++++++ tests/concepts/nodePath.test.mjs | 41 ++++++++++++++++ tests/unit/win32ToWin32WSL2.test.mjs | 49 ++++++++++++++++++- vite.config.mjs | 9 ++-- 7 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 lib/test-utils/pwsh-test-mocha.ps1 rename src/{ => win32ToWin32WSL}/win32ToWin32WSL2.mjs (100%) create mode 100644 src/win32ToWin32WSL/win32ToWin32WSL2.ps1 diff --git a/lib/test-utils/pwsh-test-mocha.ps1 b/lib/test-utils/pwsh-test-mocha.ps1 new file mode 100644 index 0000000..7350ff4 --- /dev/null +++ b/lib/test-utils/pwsh-test-mocha.ps1 @@ -0,0 +1,16 @@ +#!pwsh.exe +<# +todo move this somewhere +Test powershell inside of mocha... source and import? +cd C:\Users\Jason\WebstormProjects\nuxt3-win32-posix-path +pwsh.exe -File pwsh-test-mocha.ps1 c:\hi +pwsh.exe -File lib/test-utils/pwsh-test-mocha.ps1 c:\hi s +#> + +# import-module -Name ./src/win32ToWin32WSL/win32ToWin32WSL2.ps1 -Function pathWin32ToPosix +# source +# powershell -Command ./src/win32ToWin32WSL/win32ToWin32WSL2.ps1; pathWin32ToPosix 'c:\hi' +#write-host -NoNewline $args[0] +. ./src/win32ToWin32WSL/win32ToWin32WSL2.ps1; +$tmp=pathWin32ToPosix $args[0] +write-host -NoNewline $tmp diff --git a/src/index.mjs b/src/index.mjs index 912bbc4..8aeb80c 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -6,7 +6,7 @@ import {pathWin32ToPosix,pathPosixToWin32} from "#src/pathReplacement.mjs"; export {pathWin32ToPosix,pathPosixToWin32} -import {win32ToWin32WSL2,win32ToWin32Slash} from "#src/win32ToWin32WSL2.mjs"; +import {win32ToWin32WSL2,win32ToWin32Slash} from "#src/win32ToWin32WSL/win32ToWin32WSL2.mjs"; export {win32ToWin32WSL2,win32ToWin32Slash} import {win32ToWin32JS} from "#src/win32ToWin32JS.mjs"; diff --git a/src/win32ToWin32WSL2.mjs b/src/win32ToWin32WSL/win32ToWin32WSL2.mjs similarity index 100% rename from src/win32ToWin32WSL2.mjs rename to src/win32ToWin32WSL/win32ToWin32WSL2.mjs diff --git a/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 b/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 new file mode 100644 index 0000000..97694a0 --- /dev/null +++ b/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 @@ -0,0 +1,17 @@ +<# +#> +function pathWin32ToPosix { # + param($inPathWin32,$spaceEscape = "\ ") # + $inPathWin32 = $inPathWin32.trim() # + $inPathWin32 = $inPathWin32.Replace('\\','\') + $inPathWin32 = $inPathWin32.Replace('\','/') + $inPathWin32 = $inPathWin32.Replace(' ',$spaceEscape) # space escape + $inPathWin32 = $inPathWin32 -replace "^[`"`']", '' # remove leading quotes + $inPathWin32 = $inPathWin32 -replace "[`"`']$", '' # remove ending quotes + + # .replace(/^["']/,'') # + # .replace(/["']$/,'') # + return $inPathWin32 # +} +#clear-host +#pathWin32ToPosix 'C:/Users/username/Downloads/' # "C:/Users/username/Downloads/" \ No newline at end of file diff --git a/tests/concepts/nodePath.test.mjs b/tests/concepts/nodePath.test.mjs index 44219be..4fd4383 100644 --- a/tests/concepts/nodePath.test.mjs +++ b/tests/concepts/nodePath.test.mjs @@ -80,6 +80,7 @@ import {posix,win32,sep} from 'node:path' import {pathWin32ToPosix,pathPosixToWin32} from "##/src/pathReplacement.mjs" import {posixTests, win32Tests} from "##/lib/nodePathTestExamples.mjs"; +import {spawnSync} from "node:child_process"; /** * mobaxterm is /drives/c or cd c:/ @@ -131,3 +132,43 @@ describe('nodePath.test.mjs', function(){ assert.strictEqual(sep,"\\") }) }); + +const PathWin32ToPosixTests = [ + ["C:\\Users\\Public\\Documents","C:/Users/Public/Documents"],//maybe append with quotes instead? + ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","C:/Users/Public/temp\\ spaces/a/b\\ c/d"], + ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","C:/Users/Public/temp\\ spaces/a/b\\ c/d"], + ["C:\\\\Users\\\\Public\\\\Documents","C:/Users/Public/Documents"] +]; +const ogLength = PathWin32ToPosixTests.length +for (let i = 0; i < ogLength; i++) { + const row = PathWin32ToPosixTests[i]; + row[2] = i; + PathWin32ToPosixTests.push([`'${row[0]}'`,row[1],`${i}1`]);//append with single quotes + PathWin32ToPosixTests.push([`"${row[0]}"`,row[1],`${i}2`]);//append with double quotes + +} +describe('PathWin32ToPosixTests', function(){ + for (let i = 0; i < PathWin32ToPosixTests.length; i++) { + // for (let i = 0; i < 1; i++) { //run only 1 + const [inputWinPath, expectedMntPath, win32ToPosixIndex] = PathWin32ToPosixTests[i]; + it(`PathWin32ToPosixTests MJS ${win32ToPosixIndex}`, function () { + // console.log(wslPassTestIndex,inputWinPath); + const actual = pathWin32ToPosix(inputWinPath); + assert.strictEqual(actual,expectedMntPath); + }); + it(`PathWin32ToPosixTests ps1 ${win32ToPosixIndex}`, function () { + // console.log(wslPassTestIndex,inputWinPath); + const output = spawnSync(`pwsh.exe -file lib/test-utils/pwsh-test-mocha.ps1`,[`"${inputWinPath}"`],{shell:true}); + // const output = spawnSync(`pwsh.exe -Command write-host ${inputWinPath}`,[],{shell:true}); + if(output.status !== 0){ + console.log(output.stdout.toString()) + console.error(output.stderr.toString()) + console.error(output.error,output.status) + throw output.error + } + const actual = output.stdout.toString() + + assert.strictEqual(actual,expectedMntPath); + }); + } +}); \ No newline at end of file diff --git a/tests/unit/win32ToWin32WSL2.test.mjs b/tests/unit/win32ToWin32WSL2.test.mjs index 0cb791c..f517b25 100644 --- a/tests/unit/win32ToWin32WSL2.test.mjs +++ b/tests/unit/win32ToWin32WSL2.test.mjs @@ -65,10 +65,10 @@ this.timeout(500);//500ms */ import fs from 'node:fs'; // import {win32ToWin32WSL2} from "##/dev/win-to-wsl/win32ToWin32WSL2.mjs"; -import {win32ToWin32Slash, win32ToWin32WSL2} from "#src/win32ToWin32WSL2.mjs";//fixme check the import subpath in package.json in other branch +import {win32ToWin32Slash, win32ToWin32WSL2} from "##/src/win32ToWin32WSL/win32ToWin32WSL2.mjs";//fixme check the import subpath in package.json in other branch function writeToFile(fileName,data,space=2){ const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; - const filePath = `dev/win-to-wsl/${sFileName}` + const filePath = `temp/${sFileName}` fs.writeFileSync(filePath, typeof data === 'string' ? data :JSON.stringify(data,null,+space) ); @@ -77,6 +77,7 @@ function writeToFile(fileName,data,space=2){ /** * To integrate and move with other tests */ + describe('win32ToWin32WSL2.test.mjs', function(){ it('wsl', function(){ //assert.strictEqual(1,1);//require assert @@ -136,3 +137,47 @@ describe('win32ToWin32WSL2.test.mjs', function(){ // because im reallocating and renaming / files and folders with spaces }); + + +/** + * wsl param tests + * + */ +const WSLPassTests = [ + ["C:\\Users\\Public\\Documents","/mnt/c/Users/Public/Documents"],//maybe append with quotes instead? + ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","/mnt/c/Users/Public/temp\\ spaces/a/b\\ c/d"], + ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","/mnt/c/Users/Public/temp\\ spaces/a/b\\ c/d"], + ["C:\\\\Users\\\\Public\\\\Documents","/mnt/c/Users/Public/Documents"], + //todo look into thje backtick + // ["C:\\Users\\Public\\temp` spaces\\a\\b` c\\d","/mnt/c/Users/Public/temp\\ spaces/a/b\\ c/d"], +] +//should work with changing the length of the array +const ogLength = WSLPassTests.length +for (let i = 0; i < ogLength; i++) { + const row = WSLPassTests[i]; + row[2] = i; + WSLPassTests.push([`'${row[0]}'`,row[1],`${i}1`]);//append with single quotes + WSLPassTests.push([`"${row[0]}"`,row[1],`${i}2`]);//append with double quotes + +} +// writeToFile('WSLPassTests.jsonc',WSLPassTests); +/** + * parameterized tests + */ +import {spawnSync} from "node:child_process"; + +describe('WSLPassTests', function(){ + for (let i = 0; i < WSLPassTests.length; i++) { + const [inputWinPath, expectedMntPath, wslPassTestIndex] = WSLPassTests[i]; + it(`WSLPassTests MJS ${wslPassTestIndex}`, function () { + // console.log(wslPassTestIndex,inputWinPath); + const actual = win32ToWin32WSL2(inputWinPath); + assert.strictEqual(actual,expectedMntPath); + }); + it(`WSLPassTests ps1 ${wslPassTestIndex}`, function () { + // console.log(wslPassTestIndex,inputWinPath); + const output = spawnSync(inputWinPath); + assert.strictEqual(actual,expectedMntPath); + }); + } +}); \ No newline at end of file diff --git a/vite.config.mjs b/vite.config.mjs index e26cb8a..aa9beb0 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -35,9 +35,12 @@ export default defineConfig({ formats: ['es', 'cjs'],//('es' | 'cjs' | 'umd' | 'iife') //i lost my jsdocs though... weird entry: [ //"entry" can be a dictionary or array of multiple entry points - fileURLToPath(new URL('./src/index.mjs', import.meta.url)), - fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), - // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/index.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/win32ToWin32WSL/win32ToWin32WSL2.mjs', import.meta.url)), + fileURLToPath(new URL('./temp/toWsl.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), + // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs + // ', import.meta.url)), // fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)), // fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)), // resolve('src/import-theme-chrome-pup.mjs'), From bdca551b01c2399c3edea3384dbf3791b6e9317a Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Jul 2023 02:21:51 -0400 Subject: [PATCH 23/27] updated test file... but still having issues --- src/win32ToWin32WSL/win32ToWin32WSL2.ps1 | 1 + tests/concepts/nodePath.test.mjs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 b/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 index 97694a0..2443f7e 100644 --- a/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 +++ b/src/win32ToWin32WSL/win32ToWin32WSL2.ps1 @@ -1,4 +1,5 @@ <# + pwsh.exe -File src\win32ToWin32WSL\win32ToWin32WSL2.ps1 'C:\Users\username\Downloads\' #> function pathWin32ToPosix { # param($inPathWin32,$spaceEscape = "\ ") # diff --git a/tests/concepts/nodePath.test.mjs b/tests/concepts/nodePath.test.mjs index 4fd4383..d2520e8 100644 --- a/tests/concepts/nodePath.test.mjs +++ b/tests/concepts/nodePath.test.mjs @@ -136,7 +136,7 @@ describe('nodePath.test.mjs', function(){ const PathWin32ToPosixTests = [ ["C:\\Users\\Public\\Documents","C:/Users/Public/Documents"],//maybe append with quotes instead? ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","C:/Users/Public/temp\\ spaces/a/b\\ c/d"], - ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","C:/Users/Public/temp\\ spaces/a/b\\ c/d"], + ["C:\\\\Users\\\\Public\\\\temp spaces\\\\a\\\\b c\\\\d","C:/Users/Public/temp\\ spaces/a/b\\ c/d"], ["C:\\\\Users\\\\Public\\\\Documents","C:/Users/Public/Documents"] ]; const ogLength = PathWin32ToPosixTests.length @@ -158,7 +158,7 @@ describe('PathWin32ToPosixTests', function(){ }); it(`PathWin32ToPosixTests ps1 ${win32ToPosixIndex}`, function () { // console.log(wslPassTestIndex,inputWinPath); - const output = spawnSync(`pwsh.exe -file lib/test-utils/pwsh-test-mocha.ps1`,[`"${inputWinPath}"`],{shell:true}); + const output = spawnSync(`pwsh.exe -file lib/test-utils/pwsh-test-mocha.ps1`,[inputWinPath],{shell:true}); // const output = spawnSync(`pwsh.exe -Command write-host ${inputWinPath}`,[],{shell:true}); if(output.status !== 0){ console.log(output.stdout.toString()) From 745e96c4ca3d6561b739b958554fe34399a561cd Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Jul 2023 02:22:29 -0400 Subject: [PATCH 24/27] updated test file... but still having issues --- tests/concepts/nodePath.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/concepts/nodePath.test.mjs b/tests/concepts/nodePath.test.mjs index d2520e8..f213b83 100644 --- a/tests/concepts/nodePath.test.mjs +++ b/tests/concepts/nodePath.test.mjs @@ -159,6 +159,7 @@ describe('PathWin32ToPosixTests', function(){ it(`PathWin32ToPosixTests ps1 ${win32ToPosixIndex}`, function () { // console.log(wslPassTestIndex,inputWinPath); const output = spawnSync(`pwsh.exe -file lib/test-utils/pwsh-test-mocha.ps1`,[inputWinPath],{shell:true}); + // const output = spawnSync(`pwsh.exe -file lib/test-utils/pwsh-test-mocha.ps1`,[inputWinPath],{shell:false}); // const output = spawnSync(`pwsh.exe -Command write-host ${inputWinPath}`,[],{shell:true}); if(output.status !== 0){ console.log(output.stdout.toString()) From b306d8d2105bd89bbed81305531f7c4137b08b26 Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Jul 2023 13:13:18 -0400 Subject: [PATCH 25/27] updated typedef --- lib/bin_build/bin-vite.config.mjs | 67 +++++++++++++++++++++++++++++++ vite.config.mjs | 16 ++++++-- 2 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 lib/bin_build/bin-vite.config.mjs diff --git a/lib/bin_build/bin-vite.config.mjs b/lib/bin_build/bin-vite.config.mjs new file mode 100644 index 0000000..8c8179e --- /dev/null +++ b/lib/bin_build/bin-vite.config.mjs @@ -0,0 +1,67 @@ +/** + * Bin builder for vite config + */ +// Utilities +import { defineConfig } from 'vite' +import { fileURLToPath, URL } from 'node:url' +// import { resolve } from 'node:path' +// https://vitejs.dev/config/ +export default defineConfig({ + define: { 'process.env': {} }, + resolve: { + alias: { + // https://vitejs.dev/config/shared-options.html#resolve-alias + //https://nodejs.dev/en/api/v18/packages/#subpath-imports + '##': fileURLToPath(new URL('./',import.meta.url)),//might want to try # or @ again + '#src': fileURLToPath(new URL('./src', import.meta.url)), + '#docs': fileURLToPath(new URL('./docs', import.meta.url)),//not sure if vite also needs this but yea + }, + extensions: [ + '.js', + '.json', + '.mjs', + '.vue', + ], + }, + /** + * For experimentation of puppeteer + */ + build: { + //https://vitejs.dev/guide/build.html#library-mode + outDir: fileURLToPath(new URL('./lib/dist/', import.meta.url)), + lib: { + name: 'nuxt3-win32-posix-path', + // formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife') + formats: ['es', 'cjs'],//('es' | 'cjs' | 'umd' | 'iife') + //i lost my jsdocs though... weird + entry: [ //"entry" can be a dictionary or array of multiple entry points + // fileURLToPath(new URL('./src/index.mjs', import.meta.url)), + fileURLToPath(new URL('./src/win32ToWin32WSL/win32ToWin32WSL2.mjs', import.meta.url)), + // fileURLToPath(new URL('./temp/toWsl.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), + // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs + // ', import.meta.url)), + // fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)), + // fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)), + // resolve('src/import-theme-chrome-pup.mjs'), + // Ok... cannot use vite to roll it up... just doesnt work + // resolve('##/src/generate-pupp-json/generate-pupp-json.mjs'),//fixme, this path didnt work? + // fileURLToPath(new URL('./src/generate-pupp-json/generate-pupp-json.mjs', import.meta.url)), + // resolve('##/src/index.mjs'), + ] + }, + rollupOptions: { + // make sure to externalize deps that shouldn't be bundled + // into your library + // external: ['puppeteer',"puppeteer-core","node:path/posix","node*"], + output: { + // Provide global variables to use in the UMD build + // for externalized deps + // globals: { + // vue: 'Vue',//not sure what this means + // }, + }, + }, + }, + +}) diff --git a/vite.config.mjs b/vite.config.mjs index aa9beb0..97a0814 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -3,10 +3,17 @@ */ // Utilities import { defineConfig } from 'vite' + import { fileURLToPath, URL } from 'node:url' // import { resolve } from 'node:path' // https://vitejs.dev/config/ -export default defineConfig({ +/** + * @typedef {import('vite').UserConfigExport} UserConfigExport + */ +/** + * @type {UserConfigExport} + */ +export const viteBaseConfig = { define: { 'process.env': {} }, resolve: { alias: { @@ -35,9 +42,9 @@ export default defineConfig({ formats: ['es', 'cjs'],//('es' | 'cjs' | 'umd' | 'iife') //i lost my jsdocs though... weird entry: [ //"entry" can be a dictionary or array of multiple entry points - // fileURLToPath(new URL('./src/index.mjs', import.meta.url)), + fileURLToPath(new URL('./src/index.mjs', import.meta.url)), // fileURLToPath(new URL('./src/win32ToWin32WSL/win32ToWin32WSL2.mjs', import.meta.url)), - fileURLToPath(new URL('./temp/toWsl.mjs', import.meta.url)), + // fileURLToPath(new URL('./temp/toWsl.mjs', import.meta.url)), // fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs // ', import.meta.url)), @@ -64,4 +71,5 @@ export default defineConfig({ }, }, -}) +} +export default defineConfig(viteBaseConfig) From b58c743b6e3f6cfee109f4bb6d60ef79b470f4f9 Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Jul 2023 13:28:46 -0400 Subject: [PATCH 26/27] updated the vite build process --- lib/bin_build/bin-vite.config.mjs | 41 ++++--------------------------- lib/bin_build/index.mjs | 6 +++++ package.json | 4 ++- vite.config.mjs | 8 ++++-- 4 files changed, 20 insertions(+), 39 deletions(-) create mode 100644 lib/bin_build/index.mjs diff --git a/lib/bin_build/bin-vite.config.mjs b/lib/bin_build/bin-vite.config.mjs index 8c8179e..c98114d 100644 --- a/lib/bin_build/bin-vite.config.mjs +++ b/lib/bin_build/bin-vite.config.mjs @@ -4,50 +4,19 @@ // Utilities import { defineConfig } from 'vite' import { fileURLToPath, URL } from 'node:url' +import {rootFileUrl, viteBaseConfig} from "##/vite.config.mjs"; // import { resolve } from 'node:path' // https://vitejs.dev/config/ export default defineConfig({ - define: { 'process.env': {} }, - resolve: { - alias: { - // https://vitejs.dev/config/shared-options.html#resolve-alias - //https://nodejs.dev/en/api/v18/packages/#subpath-imports - '##': fileURLToPath(new URL('./',import.meta.url)),//might want to try # or @ again - '#src': fileURLToPath(new URL('./src', import.meta.url)), - '#docs': fileURLToPath(new URL('./docs', import.meta.url)),//not sure if vite also needs this but yea - }, - extensions: [ - '.js', - '.json', - '.mjs', - '.vue', - ], - }, - /** - * For experimentation of puppeteer - */ + ...viteBaseConfig, build: { - //https://vitejs.dev/guide/build.html#library-mode - outDir: fileURLToPath(new URL('./lib/dist/', import.meta.url)), + //https://vitejs.dev/guide/build.html#library-mode + outDir: fileURLToPath(new URL('./lib/bin_build/.output/', rootFileUrl)), lib: { name: 'nuxt3-win32-posix-path', - // formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife') formats: ['es', 'cjs'],//('es' | 'cjs' | 'umd' | 'iife') - //i lost my jsdocs though... weird entry: [ //"entry" can be a dictionary or array of multiple entry points - // fileURLToPath(new URL('./src/index.mjs', import.meta.url)), - fileURLToPath(new URL('./src/win32ToWin32WSL/win32ToWin32WSL2.mjs', import.meta.url)), - // fileURLToPath(new URL('./temp/toWsl.mjs', import.meta.url)), - // fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)), - // fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs - // ', import.meta.url)), - // fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)), - // fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)), - // resolve('src/import-theme-chrome-pup.mjs'), - // Ok... cannot use vite to roll it up... just doesnt work - // resolve('##/src/generate-pupp-json/generate-pupp-json.mjs'),//fixme, this path didnt work? - // fileURLToPath(new URL('./src/generate-pupp-json/generate-pupp-json.mjs', import.meta.url)), - // resolve('##/src/index.mjs'), + fileURLToPath(new URL('./lib/bin_build/index.mjs', rootFileUrl)), ] }, rollupOptions: { diff --git a/lib/bin_build/index.mjs b/lib/bin_build/index.mjs new file mode 100644 index 0000000..5c7112f --- /dev/null +++ b/lib/bin_build/index.mjs @@ -0,0 +1,6 @@ +/** + * Bin Build Index Packager + * maybe add cli builder / handler here + */ +import Win32ToWin32WSL2 from "##/src/win32ToWin32WSL/win32ToWin32WSL2.mjs"; +export {Win32ToWin32WSL2} diff --git a/package.json b/package.json index 1111532..5545fed 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "docs:build": "vitepress build docs", "docs:preview": "vitepress preview docs", "build-rollup:vite": "vite build --mode production", - "build-rollup:pkg": "pkg lib/dist/index.js --out-path lib/dist/bins" + "build-rollup:pkg": "pkg lib/dist/index.js --out-path lib/dist/bins", + "build-bins:rollup": "vite build --mode production --config lib/bin_build/bin-vite.config.mjs", + "build-bins:pkg": "pkg lib/bin_build/.output/index.js --out-path lib/bin_build/dist/" }, "devDependencies": { "gh-pages": "^4.0.0", diff --git a/vite.config.mjs b/vite.config.mjs index 97a0814..cd04089 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -13,7 +13,8 @@ import { fileURLToPath, URL } from 'node:url' /** * @type {UserConfigExport} */ -export const viteBaseConfig = { +export const viteBaseConfig = (()=>{ + return { define: { 'process.env': {} }, resolve: { alias: { @@ -71,5 +72,8 @@ export const viteBaseConfig = { }, }, -} +}})(); +export const rootFilePath = fileURLToPath(new URL('./', import.meta.url)); +/** @type {string|URL} */ +export const rootFileUrl = import.meta.url; export default defineConfig(viteBaseConfig) From 14d929f5369449781364e3d182b503ec136f0376 Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Jul 2023 14:23:13 -0400 Subject: [PATCH 27/27] fixed the exe... might want to change the order again though --- lib/bin_build/index.mjs | 20 ++++++- lib/test-utils/mocha-cli-exec.mjs | 37 ++++++++++++ package.json | 1 + tests/unit/mocha-cli-exec.mjs | 89 ++++++++++++++++++++++++++++ tests/unit/win32ToWin32WSL2.test.mjs | 43 ++++++++++++-- 5 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 lib/test-utils/mocha-cli-exec.mjs create mode 100644 tests/unit/mocha-cli-exec.mjs diff --git a/lib/bin_build/index.mjs b/lib/bin_build/index.mjs index 5c7112f..2188fd3 100644 --- a/lib/bin_build/index.mjs +++ b/lib/bin_build/index.mjs @@ -1,6 +1,22 @@ /** * Bin Build Index Packager * maybe add cli builder / handler here + lib/bin_build/dist/index-win.exe c:/Users/Public/Documents + + node lib/bin_build/index.mjs c:/Users/Public/Documents + node lib/bin_build/index.mjs "c:/Users/Public/Docum ents" + node lib/bin_build/index.mjs c:/Users/Public/Docum ents + * + * todo think about how to test this properly performance wise + * it's surprisingly not bad. powershell was much slower... */ -import Win32ToWin32WSL2 from "##/src/win32ToWin32WSL/win32ToWin32WSL2.mjs"; -export {Win32ToWin32WSL2} +// import process from "node:process"; +import {win32ToWin32WSL2} from "##/src/win32ToWin32WSL/win32ToWin32WSL2.mjs"; +// export {win32ToWin32WSL2} + +/* take arguments from command line */ +const args = process.argv.slice(2); +// console.log(args); +// console.log(win32ToWin32WSL2(args[0])) +console.log(win32ToWin32WSL2(args.join(' '))) +process.exit(0) diff --git a/lib/test-utils/mocha-cli-exec.mjs b/lib/test-utils/mocha-cli-exec.mjs new file mode 100644 index 0000000..e888e02 --- /dev/null +++ b/lib/test-utils/mocha-cli-exec.mjs @@ -0,0 +1,37 @@ +import {spawnSync} from "node:child_process"; +import assert from "node:assert"; + +/** + * factory function + */ +/** + * + * @param pathToExe + * @param args + * @param options + * @return {(function(*, *): void)|*} + * @example + * const assertW2Wb = createMochaCliExe(W2WB);1 + */ +export function createMochaCliExe(pathToExe,args=[],options={}){ + //todo add better defaulting etc... didnt think i neeeded to modify the input + const actualOptions = {shell:true,...options} + + return function(expectedValue,...inputToTest){ + const output = spawnSync( + // `"${W2WB}" [C:\\` //cmd needs to double quote + // `"${pathToExe}"`,[WSLPassTests[0][0]],actualOptions + `"${pathToExe}"`,[...inputToTest],actualOptions + ); + if(output.status !== 0){ + console.error(output); + console.log(output.stdout.toString()) + console.error(output.stderr.toString()) + throw new Error("status not 0"); + } + const actual = output.stdout.toString().trim(); + console.assert(actual === expectedValue,`inputToTest: ${inputToTest}`) + assert.strictEqual(actual,expectedValue); + } + +} \ No newline at end of file diff --git a/package.json b/package.json index 5545fed..eccb171 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "docs:preview": "vitepress preview docs", "build-rollup:vite": "vite build --mode production", "build-rollup:pkg": "pkg lib/dist/index.js --out-path lib/dist/bins", + "build-bins" : "pnpm run /build-bins:.*/", "build-bins:rollup": "vite build --mode production --config lib/bin_build/bin-vite.config.mjs", "build-bins:pkg": "pkg lib/bin_build/.output/index.js --out-path lib/bin_build/dist/" }, diff --git a/tests/unit/mocha-cli-exec.mjs b/tests/unit/mocha-cli-exec.mjs new file mode 100644 index 0000000..aea332c --- /dev/null +++ b/tests/unit/mocha-cli-exec.mjs @@ -0,0 +1,89 @@ +/** +yarn add mocha -D + +package.json + "imports": { + "##/*": { + "default": "./*" + }, + }, + "type": "module", + + jsconfig.json + { + "compilerOptions": { + "baseUrl": ".", + "paths": { + "##/*": ["./*"] + } + }, + "exclude": ["node_modules", ".nuxt", "dist"] +} + + + +*/ +// import { createRequire } from 'module'; +// const require = createRequire(import.meta.url); +// const assert = require('assert'); +// const {describe,it} = require('mocha'); +import assert from 'node:assert'; +import { describe, it} from 'mocha'; +/* +1. +yarn add mocha @babel/polyfill @babel/register @babel/preset-env babel-plugin-module-resolver --dev +yarn add @babel/core --dev +2. +-r @babel/register -r babel-plugin-module-resolver + +3. +.babelrc +{ + + "presets": ["@babel/preset-env"], + "plugins": [ + ["module-resolver", { + "root": ["./src"], + "alias": { + "test": "./test", + "underscore": "lodash", + + "~": "./" + } + }] + ] + +} +test specific timeout +this.timeout(500);//500ms +*/ +/** + * Should put this somewhere safe + * todo filepath needs to be initialized as well... + * @param fileName .json + * @param data will automatically be changed + */ +import fs from 'node:fs'; +import {createMochaCliExe} from "##/lib/test-utils/mocha-cli-exec.mjs"; +function writeToFile(fileName,data,space=2){ + const sFileName = /\./.test(fileName) ? fileName : fileName + '.json'; + const filePath = `dev/pbs/test/${sFileName}` + fs.writeFileSync(filePath, + typeof data === 'string' ? data :JSON.stringify(data,null,+space) + ); +} +describe('tests/unit/mocha-cli-exec.mjs', function(){ + const assertW2bMJS = createMochaCliExe("node.exe") + const pathToJS = "lib/bin_build/index.mjs" + it('Check factory function - createMochaCliExe', function(){ + //assert.strictEqual(1,1);//require assert + const fn = createMochaCliExe() + console.log(fn.toString()); + }); + it('check index.mjs without spaces', function(){ + assertW2bMJS("/mnt/c/Users/Public/Documents",pathToJS,"c:/Users/Public/Documents"); + }); + it('check index.mjs with spaces', function(){ + assertW2bMJS("/mnt/c/Users/Public/Docu\\ ments",pathToJS,"c:/Users/Public/Docu ments"); + }); +}); diff --git a/tests/unit/win32ToWin32WSL2.test.mjs b/tests/unit/win32ToWin32WSL2.test.mjs index f517b25..b3ecf2e 100644 --- a/tests/unit/win32ToWin32WSL2.test.mjs +++ b/tests/unit/win32ToWin32WSL2.test.mjs @@ -143,7 +143,7 @@ describe('win32ToWin32WSL2.test.mjs', function(){ * wsl param tests * */ -const WSLPassTests = [ +export const WSLPassTests = [ ["C:\\Users\\Public\\Documents","/mnt/c/Users/Public/Documents"],//maybe append with quotes instead? ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","/mnt/c/Users/Public/temp\\ spaces/a/b\\ c/d"], ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","/mnt/c/Users/Public/temp\\ spaces/a/b\\ c/d"], @@ -165,8 +165,36 @@ for (let i = 0; i < ogLength; i++) { * parameterized tests */ import {spawnSync} from "node:child_process"; +import {createMochaCliExe} from "##/lib/test-utils/mocha-cli-exec.mjs"; describe('WSLPassTests', function(){ + /** @type {string|'Win32ToWin32WSL2BinaryPath'} */ + const W2WB = "lib/bin_build/dist/index-win.exe"; + const assertW2Wb = createMochaCliExe(W2WB); + /* raw */ + it('WSLPassTests mocha exe', function(){ + const output = spawnSync( + // `"${W2WB}" [C:\\` //cmd needs to double quote + `"${W2WB}"`,[WSLPassTests[0][0]],{shell:true} + ); + if(output.status !== 0){ + console.error(output); + console.log(output.stdout.toString()) + console.error(output.stderr.toString()) + throw new Error("status not 0"); + } + const actual = output.stdout.toString().trim(); + assert.strictEqual(actual,WSLPassTests[0][1]); + }); + /* wrapper note reversed */ + it('WSLPassTests assertW2Wb', function(){ + assertW2Wb(WSLPassTests[0][1],WSLPassTests[0][0]); + }); + /* wrapper note reversed */ + it('WSLPassTests assertW2Wb - spaces', function(){ + assertW2Wb(WSLPassTests[1][1],WSLPassTests[1][0]); + }); + /**/ for (let i = 0; i < WSLPassTests.length; i++) { const [inputWinPath, expectedMntPath, wslPassTestIndex] = WSLPassTests[i]; it(`WSLPassTests MJS ${wslPassTestIndex}`, function () { @@ -174,10 +202,15 @@ describe('WSLPassTests', function(){ const actual = win32ToWin32WSL2(inputWinPath); assert.strictEqual(actual,expectedMntPath); }); - it(`WSLPassTests ps1 ${wslPassTestIndex}`, function () { - // console.log(wslPassTestIndex,inputWinPath); - const output = spawnSync(inputWinPath); - assert.strictEqual(actual,expectedMntPath); + /* scrapping ps1 / sh using exe for now */ + // it(`WSLPassTests ps1 ${wslPassTestIndex}`, function () { + // // console.log(wslPassTestIndex,inputWinPath); + // const output = spawnSync(inputWinPath); + // assert.strictEqual(actual,expectedMntPath); + // }); + it(`WSLPassTests exe ${wslPassTestIndex}`, function(){ + // // console.log(wslPassTestIndex,inputWinPath); + assertW2Wb(expectedMntPath,[inputWinPath]); }); } }); \ No newline at end of file