-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support generic platform keys with YML
- Loading branch information
1 parent
18968a9
commit e25dea8
Showing
12 changed files
with
254 additions
and
99 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface PlatformYamlConfig { | ||
path: string, | ||
zip: boolean | ||
} | ||
|
||
export interface YamlConfig { | ||
account: string, | ||
project: string, | ||
release: string, | ||
platforms: Record<string, PlatformYamlConfig> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { ReleaseConfig, SupportedPlatform } from "@valist/sdk"; | ||
import { YamlConfig } from "./types"; | ||
import fs from 'fs'; | ||
import YAML from 'yaml'; | ||
import { FlagOutput } from "@oclif/core/lib/interfaces"; | ||
|
||
/* eslint-disable-next-line */ | ||
export function parseYml(args: {[name: string]: any;}, flags: FlagOutput): {config: ReleaseConfig, yamlConfig: YamlConfig | undefined} | undefined{ | ||
let config: ReleaseConfig; | ||
let yamlConfig: YamlConfig | undefined = undefined; | ||
const flagPath = flags['ymlPath'] | ||
const ymlPath = flagPath ? flagPath : 'hyperplay.yml' | ||
// cli args and flags | ||
if (args.account && args.project && args.release && !flags['useYml']) { | ||
config = new ReleaseConfig(args.account, args.project, args.release); | ||
const platformFlags: SupportedPlatform[] = ["web", "darwin_amd64", "darwin_arm64", "linux_amd64", "linux_arm64", "windows_amd64", "windows_arm64", "android_arm64"] | ||
for (const platform of platformFlags){ | ||
if (flags[platform]) | ||
config.platforms[platform] = flags[platform] | ||
} | ||
|
||
// using hyperplay.yml | ||
} else if(fs.existsSync(ymlPath)){ | ||
const data = fs.readFileSync(ymlPath, 'utf8'); | ||
yamlConfig = YAML.parse(data); | ||
|
||
const configPlatforms: Record<string, string> = {} | ||
for (const [key, value] of Object.entries(yamlConfig!.platforms)){ | ||
configPlatforms[key] = value.path | ||
} | ||
if (yamlConfig === undefined){ | ||
return undefined | ||
} | ||
config = {...yamlConfig, platforms: configPlatforms} | ||
|
||
// override yaml if cli args are passed for acct, project, or release | ||
if (args.account) { | ||
config.account = args.account | ||
} | ||
if (args.project) { | ||
config.project = args.project | ||
} | ||
if (args.release) { | ||
config.release = args.release | ||
} | ||
} | ||
else { | ||
return undefined | ||
} | ||
return {config, yamlConfig} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This is just used for testing | ||
account: valist | ||
project: cli | ||
release: v0.0.2 | ||
|
||
platforms: | ||
darwin_amd64: | ||
path: ./mock_data/mac_x64 | ||
zip: true | ||
darwin_arm64: | ||
path: ./mock_data/mac_arm64 | ||
zip: true | ||
windows_amd64: | ||
path: ./mock_data/windows_amd64 | ||
zip: true | ||
web: | ||
path: ./mock_data/web | ||
zip: true | ||
|
Oops, something went wrong.