diff --git a/README.md b/README.md
index e3d98f1..b943dfc 100644
--- a/README.md
+++ b/README.md
@@ -76,6 +76,13 @@ Build the application for production:
```bash
npm run build
+
+
+# "build-bins": "pnpm run /build-bins:.*/",
+# "pwsh:ghGenerateAndDeploy": "c:/progra~1/PowerShell/7/pwsh.exe -File lib/deploy/ghPagesDeploy.ps1",
+# didnt work...
+# https://github.com/codeforwings/nuxt3-win32-posix-path/deployments/activity_log?environment=github-pages
+
```
Locally preview production build:
diff --git a/app.vue b/app.vue
index 08cf949..5980482 100644
--- a/app.vue
+++ b/app.vue
@@ -13,7 +13,8 @@
:value="sOutputWin32ToPosix"
/>
-
+
+
Posix to Win32
-
Win32 to Win32JS
-
Win32 to Win32 WSL mnt
@@ -41,6 +41,15 @@
+ Win32 to Cygwin
+
+
+
+
@@ -51,7 +60,6 @@
-
@@ -67,8 +75,13 @@
// import {win32ToWin32JS} from "~/src/win32ToWin32JS.mjs";
// import {win32ToWin32Slash, win32ToWin32WSL2} from "~/src/win32ToWin32WSL2.mjs";
+//1. ~/lib
import {posixTests, win32Tests} from "~/lib/nodePathTestExamples.mjs";
-import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "~/lib/dist/index.mjs";
+/* from src - dont use until fixed... arg*/
+import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2,win32ToCygwin} from "~/src/index.mjs";
+/* 2.2 from dist... */
+// import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "~/lib/dist/index.mjs";
+
//## not working for some reason
// import {posixTests, win32Tests} from "##/lib/nodePathTestExamples.mjs";
@@ -95,6 +108,12 @@ export default {
"C:\\Users\\Public\\Documents",
"C:\\\\Users\\\\Public\\\\Documents",
].join('\n'),
+ sWin32ToCygwin:[
+ `"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"`,
+ `C:\\progra~1\\PowerShell\\7\\pwsh.exe`,
+ `C:\\cygwin64\\bin\\bash.exe`,
+ //try appdata / localappdata
+ ].join('\n'),
sWin32ToSlash:
[
"C:\\Users\\Public\\Documents",
@@ -131,6 +150,11 @@ export default {
return win32ToWin32WSL2(val);
}).join('\n')
},
+ sOutputWin32ToCygwin() {
+ return this.sWin32ToCygwin.split('\n').map( val =>{
+ return win32ToCygwin(val);
+ }).join('\n')
+ },
sOutputWin32ToSlash(){
return this.sWin32ToSlash.split('\n').map( val =>{
return win32ToWin32Slash(val);
diff --git a/lib/deploy/ghPagesDeploy.ps1 b/lib/deploy/ghPagesDeploy.ps1
index e92efd9..09c7129 100644
--- a/lib/deploy/ghPagesDeploy.ps1
+++ b/lib/deploy/ghPagesDeploy.ps1
@@ -27,7 +27,8 @@ if($pwd -notmatch "nuxt3-win32-posix-path"){
$pwd
exit
}
-# 2. verify node / maybe pnpm
+# 2. verify node / maybe pnpm - if needed
+# fixme. that doesnt sound right for this project... only nuxt3
$isNod316=node -v | Select-String -Pattern "v16" -Quiet
if(!$isNod316){
Write-Host "node version 16 required"
diff --git a/lib/test-utils/ConstPathTests.mjs b/lib/test-utils/ConstPathTests.mjs
index 94c1a9a..3fdcb0a 100644
--- a/lib/test-utils/ConstPathTests.mjs
+++ b/lib/test-utils/ConstPathTests.mjs
@@ -14,4 +14,29 @@ for (let i = 0; i < ogLength; 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
+}
+
+//todo add the ones inside of cygwin64...
+// but should be ok? add issue to github
+export const CygwinPassTests = [
+ ["C:\\cygwin64\\bin\\bash.exe","/cygdrive/c/cygwin64/bin/bash.exe"],
+ ["C:\\Users\\Public\\Documents","/cygdrive/c/Users/Public/Documents"],//maybe append with quotes instead?
+ ["C:\\Users\\Public\\Documents","/cygdrive/c/Users/Public/Documents"],//maybe append with quotes instead?
+ ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","/cygdrive/c/Users/Public/temp\\ spaces/a/b\\ c/d"],
+ ["C:\\Users\\Public\\temp spaces\\a\\b c\\d","/cygdrive/c/Users/Public/temp\\ spaces/a/b\\ c/d"],
+ ["C:\\\\Users\\\\Public\\\\Documents","/cygdrive/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
+//clean up this. maybe convert it to yaml
+{
+ const ogLength = CygwinPassTests.length
+ for (let i = 0; i < ogLength; i++) {
+ const row = CygwinPassTests[i];
+ row[2] = i;
+ CygwinPassTests.push([`'${row[0]}'`, row[1], `${i}1`]);//append with single quotes
+ CygwinPassTests.push([`"${row[0]}"`, row[1], `${i}2`]);//append with double quotes
+
+ }
}
\ No newline at end of file
diff --git a/nuxt.config.mjs b/nuxt.config.mjs
index c8bb51f..23f3d33 100644
--- a/nuxt.config.mjs
+++ b/nuxt.config.mjs
@@ -1,4 +1,13 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
+// const baseURL = process.env.NUXT_APP_BASE_URL || '/'
+process.env.NUXT_APP_BASE_URL = '/nuxt3-win32-posix-path/'
+//this works easiest way fixme
+const baseURL = process.env.NUXT_APP_BASE_URL || '/nuxt3-win32-posix-path/'
export default defineNuxtConfig({
ssr:false,
+ // baseURL,//this breaks it? wth
+ // env: {
+ // NUXT_APP_BASE_URL: process.env.NUXT_APP_BASE_URL || 'http://localhost:3000',
+ // }
+
})
diff --git a/package.json b/package.json
index 3ff6440..7b33c05 100644
--- a/package.json
+++ b/package.json
@@ -5,15 +5,14 @@
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
- "generate": "nuxt generate",
- "pwsh:generate:gh": "set NUXT_APP_BASE_URL=\"/nuxt3-win32-posix-path/\" && nuxt generate",
+ "generate": "nuxt generate --config nuxt.config.mjs",
+ "pwsh:generate:gh": "set NUXT_APP_BASE_URL=\"/nuxt3-win32-posix-path/\" && nuxt generate --config nuxt.config.mjs --no",
+ "gh-pages-deploy": "gh-pages --dotfiles --dist dist",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
- "test:unit": "mocha --recursive --timeout 10000 --exit tests/unit",
+ "test:unit": "mocha --recursive --timeout 10000 --exit --ui bdd tests/unit/",
"testPathSep:os": "node tests/concepts/printSep.dev.mjs",
- "gh-pages-deploy": "gh-pages --dotfiles --dist dist",
"ghGenerateAndDeploy": "node lib/deploy/ghPagesDeploy.mjs",
- "pwsh:ghGenerateAndDeploy": "c:/progra~1/PowerShell/7/pwsh.exe -File lib/deploy/ghPagesDeploy.ps1",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
@@ -21,7 +20,8 @@
"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/"
+ "build-bins:pkg": "pkg lib/bin_build/.output/index.js --out-path lib/bin_build/dist/",
+ "pwsh:ghGenerateAndDeploy": "c:/progra~1/PowerShell/7/pwsh.exe -File lib/deploy/ghPagesDeploy.ps1"
},
"devDependencies": {
"gh-pages": "^4.0.0",
diff --git a/src/index.mjs b/src/index.mjs
index d2d2a48..df789b1 100644
--- a/src/index.mjs
+++ b/src/index.mjs
@@ -3,13 +3,16 @@
* that's one ay of oding it
*/
-import {pathWin32ToPosix,pathPosixToWin32} from "#src/pathReplacement.mjs";
+// import {pathWin32ToPosix,pathPosixToWin32} from "#src/pathReplacement.mjs";
+import {pathWin32ToPosix,pathPosixToWin32} from "~/src/pathReplacement.mjs";
export {pathWin32ToPosix,pathPosixToWin32}
-import {win32ToWin32WSL2,win32ToWin32Slash} from "#src/win32ToWin32WSL/win32ToWin32WSL2.mjs";
-export {win32ToWin32WSL2,win32ToWin32Slash}
+// import {win32ToWin32WSL2,win32ToWin32Slash} from "#src/win32ToWin32WSL/win32ToWin32WSL2.mjs";
+import {win32ToWin32WSL2,win32ToWin32Slash,win32ToCygwin} from "~/src/win32ToWin32WSL/win32ToWin32WSL2.mjs";
+export {win32ToWin32WSL2,win32ToWin32Slash,win32ToCygwin}
-import {win32ToWin32JS} from "#src/win32ToWin32JS.mjs";
+// import {win32ToWin32JS} from "#src/win32ToWin32JS.mjs";
+import {win32ToWin32JS} from "~/src/win32ToWin32JS.mjs";
export {win32ToWin32JS}
//
\ No newline at end of file
diff --git a/src/win32ToWin32WSL/win32ToWin32WSL2.mjs b/src/win32ToWin32WSL/win32ToWin32WSL2.mjs
index f6922a3..6eafa8a 100644
--- a/src/win32ToWin32WSL/win32ToWin32WSL2.mjs
+++ b/src/win32ToWin32WSL/win32ToWin32WSL2.mjs
@@ -1,4 +1,9 @@
/**
+ * Should be renamed i feel to better reflect
+ * wsl / mnt.
+ 1. js c:/
+ 2. wsl
+ 3. cygwin
* Quick and dirty script to convert a Windows path to a WSL2 path
* been doing this manually for too much today.
*
@@ -11,6 +16,28 @@
// import {pathWin32ToPosix} from "./pathReplacement.mjs";
import {pathWin32ToPosix} from "#src/pathReplacement.mjs";
+/**
+ * Generic Function
+ * @param win32Path {string} - Path
+ * @param mntPrefix {string} /mnt/ - to validate
+ * @param options {object} fixme
+ * @param mntPrefix
+ */
+export function win32ToMntPath(win32Path,mntPrefix='/mnt/',options){
+ let slashPath;
+ const {spaceEscape} = options || {spaceEscape:undefined};
+ /* replace \ with / */
+ slashPath = pathWin32ToPosix(win32Path,spaceEscape)
+ /* convert Drive letter to /mnt// */
+ slashPath = slashPath.replace(/^([a-zA-Z]):/,(match,p1)=>{
+ // console.log(match);//match is C:
+ return mntPrefix + p1.toLowerCase();// /mnt/c/... might want to add quote etc.
+ // return '/mnt/' + p1.toLowerCase();// /mnt/c/... might want to add quote etc.
+ })
+ //trim check for quotes / validation later
+
+ return slashPath;
+}
/**
*
* @param win32Path {string} - Windows Path - Example: C:\Users\Public\Documents
@@ -20,14 +47,22 @@ import {pathWin32ToPosix} from "#src/pathReplacement.mjs";
*/
export function win32ToWin32WSL2(win32Path){
let wsl2Path;
- /* replace \ with / */
- wsl2Path = pathWin32ToPosix(win32Path);
- /* convert Drive letter to /mnt// */
- wsl2Path = wsl2Path.replace(/^([a-zA-Z]):/,(match,p1)=>{
- // console.log(match);//match is C:
- return '/mnt/' + p1.toLowerCase();
- })
- //trim check for quotes / validation later
+ wsl2Path = win32ToMntPath(win32Path,'/mnt/')
+ // win32ToMntPath(win32Path,'/mnt/',{spaceEscape:'` '})
+
+ return wsl2Path;
+}
+
+/**
+ * Returns cywin path
+ * @param win32Path {string}
+ * @return {string} - /cygdrive/c/Users/Public/Documents
+ * todo add /usr/bin, pass in options
+ */
+export function win32ToCygwin(win32Path){
+ let wsl2Path;
+ wsl2Path = win32ToMntPath(win32Path,'/cygdrive/')
+ // win32ToMntPath(win32Path,'/mnt/',{spaceEscape:'` '})
return wsl2Path;
}
diff --git a/tests/unit/win32ToWin32WSL2.test.mjs b/tests/unit/win32ToWin32WSL2.test.mjs
index 0bd9734..a6c8a22 100644
--- a/tests/unit/win32ToWin32WSL2.test.mjs
+++ b/tests/unit/win32ToWin32WSL2.test.mjs
@@ -23,7 +23,7 @@
*/
-import {WSLPassTests} from "##/lib/test-utils/ConstPathTests.mjs";
+import {CygwinPassTests, WSLPassTests} from "##/lib/test-utils/ConstPathTests.mjs";
// import { createRequire } from 'module';
// const require = createRequire(import.meta.url);
// const assert = require('assert');
@@ -66,7 +66,7 @@ this.timeout(500);//500ms
*/
import fs from 'node:fs';
// import {win32ToWin32WSL2} from "##/dev/win-to-wsl/win32ToWin32WSL2.mjs";
-import {win32ToWin32Slash, win32ToWin32WSL2} from "##/src/win32ToWin32WSL/win32ToWin32WSL2.mjs";//fixme check the import subpath in package.json in other branch
+import {win32ToCygwin, 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 = `temp/${sFileName}`
@@ -78,7 +78,7 @@ function writeToFile(fileName,data,space=2){
/**
* To integrate and move with other tests
*/
-
+//todo win32ToMntPath
describe('win32ToWin32WSL2.test.mjs', function(){
it('wsl', function(){
//assert.strictEqual(1,1);//require assert
@@ -173,3 +173,18 @@ describe('WSLPassTests', function(){
}
});
+describe('CygwinPassTests', function(){
+ /* if windows */
+ // if(process.platform !== 'win32'){
+ // return;
+ // }
+ /**/
+ for (let i = 0; i < CygwinPassTests.length; i++) {
+ const [inputWinPath, expectedMntPath, wslPassTestIndex] = CygwinPassTests[i];
+ it(`CygwinPassTests MJS ${wslPassTestIndex}`, function () {
+ // console.log(wslPassTestIndex,inputWinPath);
+ const actual = win32ToCygwin(inputWinPath);
+ assert.strictEqual(actual,expectedMntPath);
+ });
+ }
+});
diff --git a/vite.config.mjs b/vite.config.mjs
index cd04089..e9443ad 100644
--- a/vite.config.mjs
+++ b/vite.config.mjs
@@ -31,46 +31,47 @@ export const viteBaseConfig = (()=>{
'.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
- // },
- },
- },
- },
+ //commented out added to bin-
+ // /**
+ // * 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
+ // // },
+ // },
+ // },
+ // },
}})();
export const rootFilePath = fileURLToPath(new URL('./', import.meta.url));