|
|
@@ -1,104 +0,0 @@
|
|
|
-#!/usr/bin/env node
|
|
|
-import CodePush from 'code-push'
|
|
|
-import { build } from 'vite'
|
|
|
-import { MobileProject } from '@trapezedev/project'
|
|
|
-import fs from 'fs'
|
|
|
-import path from 'path'
|
|
|
-import inquirer from 'inquirer'
|
|
|
-import { sync } from '@capacitor/cli/dist/tasks/sync.js'
|
|
|
-import { loadConfig } from '@capacitor/cli/dist/config.js'
|
|
|
-import ProgressBar from 'progress'
|
|
|
-
|
|
|
-const token = '064853a8cdbfb94ed9b62ce30da17f162a1444a0'
|
|
|
-const androidName = 'ASNFTNGFHP-Android'
|
|
|
-const iosName = 'ASNFTNGFHP-iOS'
|
|
|
-
|
|
|
-inquirer
|
|
|
- .prompt([
|
|
|
- {
|
|
|
- name: 'type',
|
|
|
- type: 'list',
|
|
|
- message: 'Deployment Type',
|
|
|
- choices: ['Development', 'Release'],
|
|
|
- default: 'Development'
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'platform',
|
|
|
- type: 'checkbox',
|
|
|
- message: 'Platform',
|
|
|
- choices: ['Android', 'iOS'],
|
|
|
- default: ['Android']
|
|
|
- },
|
|
|
- { name: 'build', type: 'list', message: 'Build Package', choices: ['YES', 'NO'], default: 'YES' }
|
|
|
- ])
|
|
|
- .then(async answers => {
|
|
|
- console.log(answers)
|
|
|
- let mode = 'app'
|
|
|
- if (answers.type === 'Development') {
|
|
|
- process.env.NODE_ENV = 'dev'
|
|
|
- mode = 'test'
|
|
|
- }
|
|
|
- const capacitorConfig = await loadConfig()
|
|
|
- const codePush = new CodePush(token)
|
|
|
- const projectConfig = {
|
|
|
- ios: {
|
|
|
- path: 'ios/App'
|
|
|
- },
|
|
|
- android: {
|
|
|
- path: 'android'
|
|
|
- }
|
|
|
- }
|
|
|
- const project = new MobileProject(process.cwd(), projectConfig)
|
|
|
- await project.load()
|
|
|
- // if (answers.platform.includes('Android')) await project.android.incrementVersionCode()
|
|
|
- // if (answers.platform.includes('iOS')) await project.ios.incrementBuild('App')
|
|
|
- project.commit()
|
|
|
-
|
|
|
- let meta = String(fs.readFileSync(path.resolve(process.cwd(), 'public', 'meta.js')))
|
|
|
- if (answers.build === 'YES') {
|
|
|
- meta = meta.replace(
|
|
|
- /(window.www_version = )\d+/,
|
|
|
- `$1${parseInt(/window.www_version = (\d+)/.exec(meta)[1]) + 1}`
|
|
|
- )
|
|
|
- fs.writeFileSync(path.resolve(process.cwd(), 'public', 'meta.js'), meta)
|
|
|
- await build({
|
|
|
- configFile: 'vite.config.js',
|
|
|
- mode
|
|
|
- })
|
|
|
- }
|
|
|
- if (answers.platform.includes('Android')) {
|
|
|
- var bar1 = new ProgressBar('Upload Android Bundle [:bar] :percent', { total: 100 })
|
|
|
- await sync(capacitorConfig, 'android', null, false)
|
|
|
- await codePush
|
|
|
- .release(androidName, answers.type, 'android/app/src/main/assets/public/', '~1.0.0', {}, percent => {
|
|
|
- bar1.tick(percent)
|
|
|
- })
|
|
|
- .then(res => {
|
|
|
- console.log('Upload Android Bundle Success', res)
|
|
|
- })
|
|
|
- }
|
|
|
- if (answers.platform.includes('iOS')) {
|
|
|
- var bar2 = new ProgressBar('Upload iOS Bundle [:bar] :percent', { total: 100 })
|
|
|
- await sync(capacitorConfig, 'ios', null, false)
|
|
|
- await codePush
|
|
|
- .release(androidName, answers.type, 'ios/App/App/public/', '~1.0.0', {}, percent => {
|
|
|
- bar2.tick(percent)
|
|
|
- })
|
|
|
- .then(res => {
|
|
|
- console.log('Upload iOS Bundle Success', res)
|
|
|
- })
|
|
|
- }
|
|
|
- fs.readdirSync(process.cwd()).forEach(file => {
|
|
|
- if (/^\w+\.zip$/.test(file)) {
|
|
|
- fs.unlinkSync(path.resolve(process.cwd(), file))
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- console.log(error)
|
|
|
- if (error.isTtyError) {
|
|
|
- // Prompt couldn't be rendered in the current environment
|
|
|
- } else {
|
|
|
- // Something else went wrong
|
|
|
- }
|
|
|
- })
|