[update] ci

This commit is contained in:
陶林 2022-05-24 14:49:24 +08:00
commit 155bc5399e
16 changed files with 3665 additions and 0 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https://alicdn.taoya.art/test/gradle-7.1.1-all.zip

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
Jenkinsfile
.DS_Store
node_modules/
/plugins/
/platforms/
www/*

5
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

13
.idea/icordova.iml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/platforms" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/icordova.iml" filepath="$PROJECT_DIR$/.idea/icordova.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

5
README.md Normal file
View File

@ -0,0 +1,5 @@
## 功能
- 修改名称
- 修改包名

31
cmd/dev.js Normal file
View File

@ -0,0 +1,31 @@
/**
* @author Taoya
* @date 2022/5/23
* @Description: 构建开发环境包
*/
const fs = require('fs')
const { resolve } = require('path')
var child_process = require('child_process')
const chalk = require('chalk');
const logger = require('./utils/logger.js');
function main() {
let baseDir = resolve('./');
let packageName = 'dev.apk';
let revRun = child_process.exec('npx cordova run android', function (e, res) {
if(res.indexOf('BUILD SUCCESSFUL')!=-1){
logger.log('info', '构建成功')
if(fs.existsSync(`./dist/${packageName}`)) {
fs.unlinkSync(`./dist/${packageName}`)
}
fs.renameSync('./platforms/android/app/build/outputs/apk/debug/app-debug.apk', './dist/dev.apk')
}else{
logger.log('info', '构建失败')
}
});
revRun.stdout.on('data', function (data) {
console.log(chalk.green(data));
})
}
main();

21
cmd/init.js Normal file
View File

@ -0,0 +1,21 @@
const fs = require('fs')
var child_process = require('child_process')
const chalk = require('chalk');
const logger = require('./utils/logger.js');
const DotEnv = require('dotenv')
const parsedEnv = DotEnv.config({
path: `.env`
}).parsed
function main() {
let revRun = child_process.exec('cordova platform add android', function (e, res) {
// 修改gradle镜像地址
let gradle_cdn = 'https://alicdn.taoya.art/test/gradle-7.1.1-all.zip';
console.log(process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL);
});
revRun.stdout.on('data', function (data) {
console.log(chalk.green(data));
})
}
main();

30
cmd/logo.js Normal file
View File

@ -0,0 +1,30 @@
/**
* @author Taoya
* @date 2022/5/23
* @Description: 一键替换Logo
*/
const fs = require('fs')
const { resolve } = require('path')
const exec = require('child_process').execSync
let path = require('path');
const chalk = require('chalk');
const logger = require('./utils/logger.js');
function icopy(file1,file2) {
exec(`cp ${file1} ${file2}`)
}
function main() {
let baseDir = resolve('./')
let logoFile = baseDir+'/logo.png'
logger.log('info', "一键替换Logo")
logger.log('info', 'BaseDir: '+ baseDir);
if(fs.existsSync(logoFile)){
icopy(logoFile, './res/icon/android/logo.png')
}else{
logger.log('info', '文件不存在');
return ;
}
}
main();

22
cmd/utils/logger.js Normal file
View File

@ -0,0 +1,22 @@
const { createLogger, format, transports } = require('winston');
const path = require('path');
const env = process.env.NODE_ENV || 'development';
const logger = createLogger({
level: env === 'production' ? 'info' : 'debug',
format: format.combine(
format.label({ label: path.basename(process.mainModule.filename) }),
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' })
),
transports: [
new transports.Console({
format: format.combine(
format.colorize(),
format.printf(
info =>
`${info.timestamp} ${info.level} [${info.label}]: ${info.message}`
)
)
}),
]
});
module.exports = logger;

31
config.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.tao" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>APP</name>
<description>app</description>
<author email="dev@cordova.apache.org" href="https://cordova.apache.org">
</author>
<content src="https://www.baidu.com" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="market:*" />
<platform name="android">
<preference name="Fullscreen" value="true" />
</platform>
</widget>

BIN
dist/dev.apk vendored Normal file

Binary file not shown.

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

38
package.json Normal file
View File

@ -0,0 +1,38 @@
{
"name": "com.example.tao",
"displayName": "",
"version": "1.0.0",
"description": "Auto Package",
"main": "index.js",
"scripts": {
"initial": "node cmd/init.js",
"build": "cordova build android",
"dev": "node cmd/dev.js",
"logo": "node cmd/logo.js"
},
"keywords": [
"ecosystem:cordova"
],
"author": "taoya7",
"license": "Apache-2.0",
"devDependencies": {
"cordova-android": "^10.1.2",
"cordova-plugin-splashscreen": "^6.0.1"
},
"cordova": {
"platforms": [
"android",
"browser"
],
"plugins": {
"cordova-plugin-splashscreen": {}
}
},
"dependencies": {
"chalk": "4.1.2",
"cordova": "^11.0.0",
"cross-env": "^7.0.3",
"dotenv": "^16.0.1",
"winston": "^3.7.2"
}
}

3448
yarn.lock Normal file

File diff suppressed because it is too large Load Diff