-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into release/2.0.0
- Loading branch information
Showing
86 changed files
with
5,461 additions
and
5,646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,66 @@ | ||
import { existsSync, readFileSync } from 'node:fs' | ||
import { existsSync, readFileSync, writeFileSync } from 'node:fs' | ||
import { resolve } from 'node:path' | ||
import type { Plugin } from 'vite' | ||
|
||
function getPkgPath(pkgName: string, fileName) { | ||
return resolve(__dirname, `../../../node_modules/@vue-flow/${pkgName}/dist/${fileName}`) | ||
} | ||
|
||
function getPublicPath(fileName: string) { | ||
return resolve(__dirname, `../../public/${fileName}`) | ||
} | ||
|
||
function copyFiles(emit: any) { | ||
;['core', 'background', 'controls', 'minimap', 'node-resizer', 'node-toolbar'].forEach((name) => { | ||
const fileName = `vue-flow-${name}.mjs` | ||
|
||
const filePath = resolve(__dirname, getPkgPath(name, fileName)) | ||
|
||
console.log(filePath) | ||
|
||
if (!existsSync(filePath)) { | ||
throw new Error(`${name} not built. ` + `Run "pnpm -w build" first.`) | ||
} | ||
|
||
emit({ | ||
type: 'asset', | ||
fileName, | ||
filePath, | ||
source: readFileSync(filePath, 'utf-8'), | ||
}) | ||
|
||
console.log(`Copied ${filePath} to ${getPublicPath(fileName)}`) | ||
}) | ||
|
||
console.log('Copied vue-flow files') | ||
} | ||
export function copyVueFlowPlugin(): Plugin { | ||
return { | ||
name: 'copy-vue-flow', | ||
generateBundle() { | ||
;[ | ||
{ path: '../../../node_modules/@vue-flow/core/dist/', pkgName: 'vue-flow-core.mjs' }, | ||
{ | ||
path: '../../../node_modules/@vue-flow/background/dist/', | ||
pkgName: 'vue-flow-background.mjs', | ||
}, | ||
{ | ||
path: '../../../node_modules/@vue-flow/controls/dist/', | ||
pkgName: 'vue-flow-controls.mjs', | ||
}, | ||
{ | ||
path: '../../../node_modules/@vue-flow/minimap/dist/', | ||
pkgName: 'vue-flow-minimap.mjs', | ||
}, | ||
{ | ||
path: '../../../node_modules/@vue-flow/node-resizer/dist/', | ||
pkgName: 'vue-flow-node-resizer.mjs', | ||
}, | ||
{ | ||
path: '../../../node_modules/@vue-flow/node-toolbar/dist/', | ||
pkgName: 'vue-flow-node-toolbar.mjs', | ||
}, | ||
].forEach(({ path, pkgName }) => { | ||
const filePath = resolve(__dirname, `${path}/${pkgName}`) | ||
if (!existsSync(filePath)) { | ||
throw new Error(`${pkgName} not built. ` + `Run "pnpm -w build" first.`) | ||
buildStart() { | ||
// use fs to copy files | ||
copyFiles((file: any) => { | ||
// remove existing files | ||
if (existsSync(getPublicPath(file.fileName))) { | ||
writeFileSync(getPublicPath(file.fileName), '') | ||
} | ||
|
||
;(this as any).emitFile({ | ||
type: 'asset', | ||
fileName: pkgName, | ||
source: readFileSync(filePath, 'utf-8'), | ||
}) | ||
|
||
console.log(`Copied ${filePath} to ${resolve(__dirname, `../../src/public/${pkgName}`)}`) | ||
writeFileSync(getPublicPath(file.fileName), file.source) | ||
}) | ||
}, | ||
watchChange() { | ||
// use fs to copy files | ||
copyFiles((file: any) => { | ||
// remove existing files | ||
if (existsSync(getPublicPath(file.fileName))) { | ||
writeFileSync(getPublicPath(file.fileName), '') | ||
} | ||
|
||
console.log('Copied vue-flow files') | ||
writeFileSync(getPublicPath(file.fileName), file.source) | ||
}) | ||
}, | ||
generateBundle() { | ||
copyFiles((file: any) => this.emitFile(file)) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.