commond line tools auto replace sdk version
This commit is contained in:
parent
f311b21f64
commit
0db94701d6
@ -6,7 +6,7 @@ require('shelljs/global')
|
|||||||
const targetJSPath = `${__dirname}/../target/`
|
const targetJSPath = `${__dirname}/../target/`
|
||||||
const targetAndroidPath = `${__dirname}/../target/android`
|
const targetAndroidPath = `${__dirname}/../target/android`
|
||||||
const targetiOSPath = `${__dirname}/../target/iOS`
|
const targetiOSPath = `${__dirname}/../target/iOS`
|
||||||
|
const currentVersion = fs.readFileSync(`${__dirname}/../version`).toString()
|
||||||
function copyFile(srcPath, tarPath, cb) {
|
function copyFile(srcPath, tarPath, cb) {
|
||||||
var rs = fs.createReadStream(srcPath)
|
var rs = fs.createReadStream(srcPath)
|
||||||
rs.on('error', function (err) {
|
rs.on('error', function (err) {
|
||||||
@ -66,7 +66,8 @@ function copyFolder(srcDir, tarDir, cb) {
|
|||||||
|
|
||||||
function initJS(path, name) {
|
function initJS(path, name) {
|
||||||
console.log(`create dir ${path} success`);
|
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}/tsconfig.json`, fs.readFileSync(`${targetJSPath}/_tsconfig.json`))
|
||||||
fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`))
|
fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`))
|
||||||
fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`))
|
fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`))
|
||||||
@ -91,8 +92,13 @@ function initAndroid(path, name) {
|
|||||||
return console.error(err);
|
return console.error(err);
|
||||||
}
|
}
|
||||||
copyFolder(`${targetAndroidPath}`, `${path}`, () => {
|
copyFolder(`${targetAndroidPath}`, `${path}`, () => {
|
||||||
const mainFiles = `app/src/main/java/pub/doric/example/MainActivity.java`
|
['app/src/main/java/pub/doric/example/MainActivity.java', 'app/build.gradle'].forEach(e => {
|
||||||
fs.writeFileSync(`${path}/${mainFiles}`, fs.readFileSync(`${targetAndroidPath}/${mainFiles}`).toString().replace(/__\$__/g, name))
|
fs.writeFileSync(`${path}/${e}`,
|
||||||
|
fs.readFileSync(`${targetiOSPath}/${e}`).toString()
|
||||||
|
.replace(/__\$__/g, name)
|
||||||
|
.replace(/__\$Version__/g, currentVersion))
|
||||||
|
})
|
||||||
|
|
||||||
console.log(`Create Doric Android Project Success`)
|
console.log(`Create Doric Android Project Success`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -108,8 +114,11 @@ function initiOS(path, name) {
|
|||||||
return console.error(err);
|
return console.error(err);
|
||||||
}
|
}
|
||||||
copyFolder(`${targetiOSPath}`, `${path}`, () => {
|
copyFolder(`${targetiOSPath}`, `${path}`, () => {
|
||||||
['Example/SceneDelegate.m', 'Example/AppDelegate.m'].forEach(e => {
|
['Example/SceneDelegate.m', 'Example/AppDelegate.m', 'Podfile'].forEach(e => {
|
||||||
fs.writeFileSync(`${path}/${e}`, fs.readFileSync(`${targetiOSPath}/${e}`).toString().replace(/__\$__/g, name))
|
fs.writeFileSync(`${path}/${e}`,
|
||||||
|
fs.readFileSync(`${targetiOSPath}/${e}`).toString()
|
||||||
|
.replace(/__\$__/g, name)
|
||||||
|
.replace(/__\$Version__/g, currentVersion))
|
||||||
})
|
})
|
||||||
console.log(`Create Doric iOS Project Success`)
|
console.log(`Create Doric iOS Project Success`)
|
||||||
})
|
})
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"doric": "0.3.8",
|
"doric": "__$Version__",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rollup": "^1.27.14",
|
"rollup": "^1.27.14",
|
||||||
"tslib": "^1.10.0",
|
"tslib": "^1.10.0",
|
||||||
|
@ -28,8 +28,8 @@ android {
|
|||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation "pub.doric:core:0.3.8"
|
implementation "pub.doric:core:__$Version__"
|
||||||
debugImplementation "pub.doric:devkit:0.3.8"
|
debugImplementation "pub.doric:devkit:__$Version__"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ target 'Example' do
|
|||||||
use_frameworks!
|
use_frameworks!
|
||||||
|
|
||||||
# Pods for Example
|
# Pods for Example
|
||||||
pod 'DoricCore', '~>0.3.8'
|
pod 'DoricCore', '~>__$Version__'
|
||||||
end
|
end
|
||||||
|
1
doric-cli/target/version
Normal file
1
doric-cli/target/version
Normal file
@ -0,0 +1 @@
|
|||||||
|
0.3.10
|
Reference in New Issue
Block a user