From 0db94701d6a8cd868e69da5da0d50bc64e37ab33 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Sat, 21 Mar 2020 10:26:57 +0800 Subject: [PATCH] commond line tools auto replace sdk version --- doric-cli/scripts/init.js | 21 +++++++++++++++------ doric-cli/target/_package.json | 2 +- doric-cli/target/android/app/build.gradle | 4 ++-- doric-cli/target/iOS/Podfile | 2 +- doric-cli/target/version | 1 + 5 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 doric-cli/target/version diff --git a/doric-cli/scripts/init.js b/doric-cli/scripts/init.js index ae0f75ee..3b5895fd 100644 --- a/doric-cli/scripts/init.js +++ b/doric-cli/scripts/init.js @@ -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`) }) diff --git a/doric-cli/target/_package.json b/doric-cli/target/_package.json index dd1b7dbe..6e5b7f3b 100644 --- a/doric-cli/target/_package.json +++ b/doric-cli/target/_package.json @@ -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", diff --git a/doric-cli/target/android/app/build.gradle b/doric-cli/target/android/app/build.gradle index bf183ec1..7aeabb9a 100644 --- a/doric-cli/target/android/app/build.gradle +++ b/doric-cli/target/android/app/build.gradle @@ -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__" } } diff --git a/doric-cli/target/iOS/Podfile b/doric-cli/target/iOS/Podfile index 23ef7f81..e3bb9056 100644 --- a/doric-cli/target/iOS/Podfile +++ b/doric-cli/target/iOS/Podfile @@ -6,5 +6,5 @@ target 'Example' do use_frameworks! # Pods for Example - pod 'DoricCore', '~>0.3.8' + pod 'DoricCore', '~>__$Version__' end diff --git a/doric-cli/target/version b/doric-cli/target/version new file mode 100644 index 00000000..81de5c57 --- /dev/null +++ b/doric-cli/target/version @@ -0,0 +1 @@ +0.3.10 \ No newline at end of file