mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-07 17:05:33 +02:00
✨ CI Commands
This commit is contained in:
parent
a71f9797b5
commit
d5a8fe2cc3
6 changed files with 78 additions and 8 deletions
|
@ -55,6 +55,7 @@
|
|||
"prompts": "^2.4.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rustic": "^1.2.1",
|
||||
"semver": "^7.3.7",
|
||||
"sharp": "^0.29.1",
|
||||
"xmlbuilder2": "^3.0.2"
|
||||
},
|
||||
|
@ -67,6 +68,7 @@
|
|||
"@types/node": "^14.14.16",
|
||||
"@types/prompts": "^2.0.14",
|
||||
"@types/rimraf": "^3.0.0",
|
||||
"@types/semver": "^7.3.10",
|
||||
"@types/sharp": "^0.29.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
||||
"@typescript-eslint/parser": "^5.22.0",
|
||||
|
|
15
src/cmds.ts
15
src/cmds.ts
|
@ -35,6 +35,21 @@ export const commands: Cmd[] = [
|
|||
description: 'Get and set the dynamic config from this project',
|
||||
requestController: async () => (await import('./commands/set')).set,
|
||||
},
|
||||
{
|
||||
cmd: 'ci',
|
||||
description: 'Configure the CI',
|
||||
requestController: async () => (await import('./commands/ci')).ci,
|
||||
options: [
|
||||
{
|
||||
arg: '--brand <brand>',
|
||||
description: 'Set the brand that the build is using',
|
||||
},
|
||||
{
|
||||
arg: '--bump <section>',
|
||||
description: 'What version should be bumped',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
cmd: 'discard <file>',
|
||||
description: 'Discard a files changes.',
|
||||
|
|
40
src/commands/ci.ts
Normal file
40
src/commands/ci.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Code to handle common, complex tasks that our CI servers have to do to get
|
||||
// ready to build everything
|
||||
|
||||
import { inc, ReleaseType } from 'semver'
|
||||
import { config } from '..'
|
||||
import { log } from '../log'
|
||||
import { dynamicConfig, saveConfig } from '../utils'
|
||||
|
||||
interface Options {
|
||||
brand?: string
|
||||
bump?: ReleaseType
|
||||
}
|
||||
|
||||
export const ci = (options: Options) => {
|
||||
log.info('Set the build to release')
|
||||
dynamicConfig.set('buildMode', 'release')
|
||||
|
||||
if (options.brand) {
|
||||
log.info(`Setting the brand to be '${options.brand}'`)
|
||||
dynamicConfig.set('brand', options.brand)
|
||||
}
|
||||
|
||||
if (options.bump) {
|
||||
const version = inc(
|
||||
config.brands[dynamicConfig.get('brand')].release.displayVersion,
|
||||
options.bump
|
||||
)
|
||||
|
||||
config.brands[dynamicConfig.get('brand')].release.displayVersion =
|
||||
version ||
|
||||
config.brands[dynamicConfig.get('brand')].release.displayVersion
|
||||
saveConfig()
|
||||
|
||||
log.info(
|
||||
`Bumped the version: ${
|
||||
config.brands[dynamicConfig.get('brand')].release.displayVersion
|
||||
} → ${version}`
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,8 +1,16 @@
|
|||
import { config } from '..'
|
||||
import { log } from '../log'
|
||||
import { dynamicConfig } from '../utils'
|
||||
|
||||
export const set = (key: string, value?: string) => {
|
||||
if (key in dynamicConfig.defaultValues) {
|
||||
if (key == 'version') {
|
||||
console.log(
|
||||
config.brands[dynamicConfig.get('brand')].release.displayVersion
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (!(key in dynamicConfig.defaultValues)) {
|
||||
log.warning(`The key ${key} is not found within the dynamic config options`)
|
||||
return
|
||||
}
|
||||
|
@ -13,9 +21,5 @@ export const set = (key: string, value?: string) => {
|
|||
return
|
||||
}
|
||||
|
||||
log.info(
|
||||
`The key '${key}' has ${dynamicConfig.get(
|
||||
key as dynamicConfig.DefaultValuesKeys
|
||||
)}`
|
||||
)
|
||||
console.log(dynamicConfig.get(key as dynamicConfig.DefaultValuesKeys))
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Responsible for loading, parsing and checking the config file for melon
|
||||
*/
|
||||
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import { existsSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
import { log } from '../log'
|
||||
|
@ -223,4 +223,8 @@ export function getConfig(): Config {
|
|||
return fileParsed
|
||||
}
|
||||
|
||||
export function saveConfig() {
|
||||
writeFileSync(configPath, JSON.stringify(config, null, 2))
|
||||
}
|
||||
|
||||
export const config = getConfig()
|
||||
|
|
|
@ -1120,6 +1120,11 @@
|
|||
"@types/glob" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/semver@^7.3.10":
|
||||
version "7.3.10"
|
||||
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.10.tgz#5f19ee40cbeff87d916eedc8c2bfe2305d957f73"
|
||||
integrity sha512-zsv3fsC7S84NN6nPK06u79oWgrPVd0NvOyqgghV1haPaFcVxIrP4DLomRwGAXk0ui4HZA7mOcSFL98sMVW9viw==
|
||||
|
||||
"@types/sharp@^0.29.2":
|
||||
version "0.29.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/sharp/-/sharp-0.29.5.tgz#9c7032d30d138ad16dde6326beaff2af757b91b3"
|
||||
|
@ -3906,7 +3911,7 @@ saxes@^5.0.1:
|
|||
dependencies:
|
||||
xmlchars "^2.2.0"
|
||||
|
||||
semver@7.x, semver@^7.3.2, semver@^7.3.5:
|
||||
semver@7.x, semver@^7.3.2, semver@^7.3.5, semver@^7.3.7:
|
||||
version "7.3.7"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
|
||||
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue