-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(vue): switch type files for vue2/vue3 in postinstall (#2640)
* refactor(vue): switch type files for vue2/vue3 in postinstall * fix(vue): fix postinstall error
- Loading branch information
1 parent
ff69314
commit 6015b7c
Showing
24 changed files
with
619 additions
and
730 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
require('../scripts/postinstall') |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
require('../scripts/switch-cli') |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { switchVersion, loadModule } = require('./utils.js') | ||
|
||
const Vue = loadModule('vue') | ||
|
||
try { | ||
if (Vue.version.startsWith('2.')) { | ||
switchVersion(2) | ||
} else if (Vue.version.startsWith('3.')) { | ||
switchVersion(3) | ||
} | ||
} catch (err) { | ||
// nothing to do | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { switchVersion } = require('./utils.js') | ||
const { | ||
switchVersion: switchVueDemiVersion, | ||
} = require('vue-demi/scripts/utils.js') | ||
|
||
const version = process.argv[2] | ||
const vueEntry = process.argv[3] || 'vue' | ||
|
||
if (version == '2') { | ||
switchVersion(2) | ||
console.log(`[formily-vue] Switched types for Vue 2`) | ||
switchVueDemiVersion(2, vueEntry) | ||
console.log(`[vue-demi] Switched for Vue 2 (entry: "${vueEntry}")`) | ||
} else if (version == '3') { | ||
switchVersion(3) | ||
console.log(`[formily-vue] Switched types for Vue 3`) | ||
switchVueDemiVersion(3, vueEntry) | ||
console.log(`[vue-demi] Switched for Vue 3 (entry: "${vueEntry}")`) | ||
} else { | ||
console.warn( | ||
`[formily-vue] expecting version "2" or "3" but got "${version}"` | ||
) | ||
process.exit(1) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { loadModule } = require('vue-demi/scripts/utils.js') | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
|
||
const dir = path.resolve(__dirname, '..', 'type-artefacts') | ||
|
||
function switchVersion(version) { | ||
fs.emptyDirSync(`${dir}/cur`) | ||
fs.copySync(`${dir}/v${version}`, `${dir}/cur`) | ||
} | ||
|
||
module.exports.loadModule = loadModule | ||
module.exports.switchVersion = switchVersion |
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
Oops, something went wrong.