fix(runtime): 修复window系统下npm run playground 出错问题 #29

This commit is contained in:
roymondchen 2022-04-26 17:38:00 +08:00 committed by jia000
parent c8542367db
commit 6df8ce82a5
8 changed files with 16 additions and 5 deletions

View File

@ -5,13 +5,13 @@
"scripts": { "scripts": {
"bootstrap": "lerna bootstrap && npm run prepare", "bootstrap": "lerna bootstrap && npm run prepare",
"clean:lock": "npx shx rm -rf package-lock.json **/package-lock.json **/**/package-lock.json", "clean:lock": "npx shx rm -rf package-lock.json **/package-lock.json **/**/package-lock.json",
"clean:top": "npx rm -rf */**/dist */dist coverage dwt*", "clean:top": "npx shx rm -rf */**/dist */dist coverage dwt*",
"clean:all": "npm run clean:top && npx shx rm -rf node_modules **/node_modules **/**/node_modules", "clean:all": "npm run clean:top && npx shx rm -rf node_modules **/node_modules **/**/node_modules",
"lint": "eslint . --ext .js,.vue,.ts,.tsx", "lint": "eslint . --ext .js,.vue,.ts,.tsx",
"lint-fix": "eslint . --fix --ext .vue,.js,.ts,.tsx", "lint-fix": "eslint . --fix --ext .vue,.js,.ts,.tsx",
"playground": "npx lerna run dev --scope tmagic-playground --scope runtime-vue3 --parallel", "playground": "npx lerna run dev --scope tmagic-playground --scope runtime-vue3 --parallel",
"build": "npx lerna run build --scope tmagic-playground --scope runtime-vue3 --scope runtime-vue2 --scope runtime-react --scope @tmagic/* --parallel", "build": "npx lerna run build --scope tmagic-playground --scope runtime-vue3 --scope runtime-vue2 --scope runtime-react --scope @tmagic/* --parallel",
"postbuild": "npx mkdir playground/dist/runtime && npx cp -r runtime/vue2/dist ./playground/dist/runtime/vue2 && npx cp -r runtime/vue3/dist ./playground/dist/runtime/vue3 && npx cp -r runtime/react/dist ./playground/dist/runtime/react", "postbuild": "npx shx mkdir playground/dist/runtime && npx shx cp -r runtime/vue2/dist ./playground/dist/runtime/vue2 && npx shx cp -r runtime/vue3/dist ./playground/dist/runtime/vue3 && npx cp -r runtime/react/dist ./playground/dist/runtime/react",
"docs": "cd docs && npm run doc:dev", "docs": "cd docs && npm run doc:dev",
"page": "cd page && vite", "page": "cd page && vite",
"page-vue2": "cd page-vue2 && vite", "page-vue2": "cd page-vue2 && vite",

View File

@ -9,6 +9,8 @@
"serve": "vite preview --port 8076" "serve": "vite preview --port 8076"
}, },
"dependencies": { "dependencies": {
"@tmagic/schema": "^1.0.0-beta.13",
"@tmagic/stage": "^1.0.0-beta.13",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2" "react-dom": "^17.0.2"
}, },

View File

@ -38,6 +38,7 @@ export default defineConfig({
}, },
server: { server: {
host: '0.0.0.0',
port: 8090, port: 8090,
}, },

View File

@ -196,7 +196,8 @@ const generateEntryFile = function ({ entries, entryFile, type, componentFileAff
fs.writeFileSync( fs.writeFileSync(
path.resolve(entryPath(), entryFile), path.resolve(entryPath(), entryFile),
prettyPrint(parse(jsString, { parser: require('recast/parsers/typescript') }), { // window下需要将路径中\转换成/
prettyPrint(parse(jsString.replace(/\\/g, '/'), { parser: require('recast/parsers/typescript') }), {
tabWidth: 2, tabWidth: 2,
trailingComma: true, trailingComma: true,
quote: 'single', quote: 'single',
@ -207,9 +208,10 @@ const generateEntryFile = function ({ entries, entryFile, type, componentFileAff
const installPackage = function (package) { const installPackage = function (package) {
try { try {
execSync(`node -e "require.resolve('${package}')"`, { stdio: 'ignore' }); // window下需要将路径中\转换成/
execSync(`node -e "require.resolve('${package.replace(/\\/g, '/')}')"`, { stdio: 'ignore' });
} catch (e) { } catch (e) {
execSync(`npm install ${package} --registry https://mirrors.tencent.com/npm/`, { execSync(`npm install ${package}`, {
stdio: 'inherit', stdio: 'inherit',
cwd: pageRoot(), cwd: pageRoot(),
}); });

View File

@ -9,6 +9,8 @@
"serve": "vite preview --port 8077" "serve": "vite preview --port 8077"
}, },
"dependencies": { "dependencies": {
"@tmagic/schema": "^1.0.0-beta.13",
"@tmagic/stage": "^1.0.0-beta.13",
"@vue/composition-api": "1.0.5", "@vue/composition-api": "1.0.5",
"vue": "^2.6.14" "vue": "^2.6.14"
}, },

View File

@ -37,6 +37,7 @@ export default defineConfig({
}, },
server: { server: {
host: '0.0.0.0',
port: 8089, port: 8089,
}, },
build: { build: {

View File

@ -9,6 +9,8 @@
"serve": "vite preview --port 8078" "serve": "vite preview --port 8078"
}, },
"dependencies": { "dependencies": {
"@tmagic/schema": "^1.0.0-beta.13",
"@tmagic/stage": "^1.0.0-beta.13",
"axios": "^0.25.0", "axios": "^0.25.0",
"vue": "^3.2.0" "vue": "^3.2.0"
}, },

View File

@ -37,6 +37,7 @@ export default defineConfig({
}, },
server: { server: {
host: '0.0.0.0',
port: 8089, port: 8089,
}, },
build: { build: {