commond line tools auto replace sdk version

This commit is contained in:
pengfei.zhou 2020-03-21 10:26:57 +08:00 committed by osborn
parent f311b21f64
commit 0db94701d6
5 changed files with 20 additions and 10 deletions

View File

@ -6,7 +6,7 @@ require('shelljs/global')
const targetJSPath = `${__dirname}/../target/`
const targetAndroidPath = `${__dirname}/../target/android`
const targetiOSPath = `${__dirname}/../target/iOS`
const currentVersion = fs.readFileSync(`${__dirname}/../version`).toString()
function copyFile(srcPath, tarPath, cb) {
var rs = fs.createReadStream(srcPath)
rs.on('error', function (err) {
@ -66,7 +66,8 @@ function copyFolder(srcDir, tarDir, cb) {
function initJS(path, name) {
console.log(`create dir ${path} success`);
fs.writeFileSync(`${path}/package.json`, fs.readFileSync(`${targetJSPath}/_package.json`).toString().replace(/__\$__/g, name))
fs.writeFileSync(`${path}/package.json`, fs.readFileSync(`${targetJSPath}/_package.json`).toString()
.replace(/__\$__/g, name).replace(/__\$Version__/g, currentVersion))
fs.writeFileSync(`${path}/tsconfig.json`, fs.readFileSync(`${targetJSPath}/_tsconfig.json`))
fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`))
fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`))
@ -91,8 +92,13 @@ function initAndroid(path, name) {
return console.error(err);
}
copyFolder(`${targetAndroidPath}`, `${path}`, () => {
const mainFiles = `app/src/main/java/pub/doric/example/MainActivity.java`
fs.writeFileSync(`${path}/${mainFiles}`, fs.readFileSync(`${targetAndroidPath}/${mainFiles}`).toString().replace(/__\$__/g, name))
['app/src/main/java/pub/doric/example/MainActivity.java', 'app/build.gradle'].forEach(e => {
fs.writeFileSync(`${path}/${e}`,
fs.readFileSync(`${targetiOSPath}/${e}`).toString()
.replace(/__\$__/g, name)
.replace(/__\$Version__/g, currentVersion))
})
console.log(`Create Doric Android Project Success`)
})
})
@ -108,8 +114,11 @@ function initiOS(path, name) {
return console.error(err);
}
copyFolder(`${targetiOSPath}`, `${path}`, () => {
['Example/SceneDelegate.m', 'Example/AppDelegate.m'].forEach(e => {
fs.writeFileSync(`${path}/${e}`, fs.readFileSync(`${targetiOSPath}/${e}`).toString().replace(/__\$__/g, name))
['Example/SceneDelegate.m', 'Example/AppDelegate.m', 'Podfile'].forEach(e => {
fs.writeFileSync(`${path}/${e}`,
fs.readFileSync(`${targetiOSPath}/${e}`).toString()
.replace(/__\$__/g, name)
.replace(/__\$Version__/g, currentVersion))
})
console.log(`Create Doric iOS Project Success`)
})

View File

@ -10,7 +10,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"doric": "0.3.8",
"doric": "__$Version__",
"reflect-metadata": "^0.1.13",
"rollup": "^1.27.14",
"tslib": "^1.10.0",

View File

@ -28,8 +28,8 @@ android {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "pub.doric:core:0.3.8"
debugImplementation "pub.doric:devkit:0.3.8"
implementation "pub.doric:core:__$Version__"
debugImplementation "pub.doric:devkit:__$Version__"
}
}

View File

@ -6,5 +6,5 @@ target 'Example' do
use_frameworks!
# Pods for Example
pod 'DoricCore', '~>0.3.8'
pod 'DoricCore', '~>__$Version__'
end

1
doric-cli/target/version Normal file
View File

@ -0,0 +1 @@
0.3.10