Implement automatic steam uploading
This commit is contained in:
parent
0af3d8e6cb
commit
a17c35c87f
|
@ -10,6 +10,9 @@ nodejs version >=7.
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
# Install gulp globally to prevent reinstallation every time
|
||||||
|
npm install -g gulp
|
||||||
|
|
||||||
# Run mission build
|
# Run mission build
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
@ -27,6 +30,7 @@ gulp <task_name>
|
||||||
| build | assembles missionfolder and sets config values |
|
| build | assembles missionfolder and sets config values |
|
||||||
| pbo | packs missionfolders into PBOs |
|
| pbo | packs missionfolders into PBOs |
|
||||||
| zip | creates release ZIPs |
|
| zip | creates release ZIPs |
|
||||||
|
| workshop | uploads built PBOs to Steam workshop |
|
||||||
| __default__ | runs _build_, _pbo_ and _zip_ |
|
| __default__ | runs _build_, _pbo_ and _zip_ |
|
||||||
|
|
||||||
Build files will be outputted to `build/` dir.
|
Build files will be outputted to `build/` dir.
|
||||||
|
@ -81,4 +85,4 @@ const paths: FolderStructureInfo = {
|
||||||
// Output directory
|
// Output directory
|
||||||
workDir: resolve("./build")
|
workDir: resolve("./build")
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"map": "Altis",
|
"map": "Altis",
|
||||||
"configFile": "KPLIB_config.sqf",
|
"configFile": "KPLIB_config.sqf",
|
||||||
"variables": {
|
"variables": {
|
||||||
}
|
},
|
||||||
|
"workshopId": "1578389037"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,7 +7,7 @@ import * as del from "del";
|
||||||
|
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
|
|
||||||
import { MissionPaths } from "./src";
|
import { MissionPaths, uploadLegacy } from "./src";
|
||||||
import { Preset, FolderStructureInfo } from "./src";
|
import { Preset, FolderStructureInfo } from "./src";
|
||||||
|
|
||||||
const ROOT_DIR = resolve('..', '..');
|
const ROOT_DIR = resolve('..', '..');
|
||||||
|
@ -30,6 +30,7 @@ const paths: FolderStructureInfo = {
|
||||||
let taskNames: string[] = [];
|
let taskNames: string[] = [];
|
||||||
let taskNamesPbo: string[] = [];
|
let taskNamesPbo: string[] = [];
|
||||||
let taskNamesZip: string[] = [];
|
let taskNamesZip: string[] = [];
|
||||||
|
let taskNamesWorkshop: string[] = [];
|
||||||
|
|
||||||
for (let preset of presets) {
|
for (let preset of presets) {
|
||||||
const mission = new MissionPaths(preset, paths);
|
const mission = new MissionPaths(preset, paths);
|
||||||
|
@ -115,6 +116,17 @@ for (let preset of presets) {
|
||||||
.pipe(gulp.dest(mission.getWorkDir()))
|
.pipe(gulp.dest(mission.getWorkDir()))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!!preset.workshopId) {
|
||||||
|
|
||||||
|
taskNamesWorkshop.push('workshop_' + taskName);
|
||||||
|
|
||||||
|
gulp.task('workshop_' + taskName, async () => {
|
||||||
|
const pboPath = resolve(mission.getWorkDir(), 'pbo', mission.getFullName() + '.pbo');
|
||||||
|
console.log(pboPath);
|
||||||
|
|
||||||
|
await uploadLegacy(preset.workshopId, pboPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +142,8 @@ gulp.task('pbo', gulp.series(taskNamesPbo));
|
||||||
|
|
||||||
gulp.task('zip', gulp.series(taskNamesZip));
|
gulp.task('zip', gulp.series(taskNamesZip));
|
||||||
|
|
||||||
|
gulp.task('workshop', gulp.series(taskNamesWorkshop));
|
||||||
|
|
||||||
gulp.task('default',
|
gulp.task('default',
|
||||||
gulp.series(
|
gulp.series(
|
||||||
gulp.task('build'),
|
gulp.task('build'),
|
||||||
|
|
|
@ -1,33 +1,38 @@
|
||||||
export interface Preset {
|
export interface Preset {
|
||||||
/**
|
/**
|
||||||
* Path to folder with mission.sqm relative to "missionsFolder".
|
* Path to folder with mission.sqm relative to "missionsFolder".
|
||||||
* If mission.sqm is in root of "missionsFolder" should be empty string.
|
* If mission.sqm is in root of "missionsFolder" should be empty string.
|
||||||
*
|
*
|
||||||
* @see FolderStructureInfo.missionsFolder
|
* @see FolderStructureInfo.missionsFolder
|
||||||
*/
|
*/
|
||||||
readonly sourceFolder: string;
|
readonly sourceFolder: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to file with mission configuration.
|
* Path to file with mission configuration.
|
||||||
* Replacement of variables will be applied here.
|
* Replacement of variables will be applied here.
|
||||||
*/
|
*/
|
||||||
readonly configFile: string;
|
readonly configFile: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of mission (part before mapname)
|
* Name of mission (part before mapname)
|
||||||
*/
|
*/
|
||||||
readonly missionName: string;
|
readonly missionName: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map name
|
* Map name
|
||||||
*/
|
*/
|
||||||
readonly map: string;
|
readonly map: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key=>val of values to replace in config file
|
* key=>val of values to replace in config file
|
||||||
* @see {VariablesReplacements}
|
* @see {VariablesReplacements}
|
||||||
*/
|
*/
|
||||||
readonly variables: VariablesReplacements;
|
readonly variables: VariablesReplacements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Steam Workshop Id
|
||||||
|
*/
|
||||||
|
readonly workshopId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VariablesReplacements {
|
export interface VariablesReplacements {
|
||||||
|
@ -36,21 +41,21 @@ export interface VariablesReplacements {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FolderStructureInfo {
|
export interface FolderStructureInfo {
|
||||||
/**
|
/**
|
||||||
* Folder of folders with mission.sqm.
|
* Folder of folders with mission.sqm.
|
||||||
* Value of "sourceFolder" from Preset will be appended to this path.
|
* Value of "sourceFolder" from Preset will be appended to this path.
|
||||||
*
|
*
|
||||||
* @see {Preset}
|
* @see {Preset}
|
||||||
*/
|
*/
|
||||||
readonly missionsFolder: string;
|
readonly missionsFolder: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to folder with mission framework files.
|
* Path to folder with mission framework files.
|
||||||
*/
|
*/
|
||||||
readonly frameworkFolder: string;
|
readonly frameworkFolder: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory containing built missions
|
* Directory containing built missions
|
||||||
*/
|
*/
|
||||||
readonly workDir: string;
|
readonly workDir: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { spawn, SpawnOptions } from 'child_process';
|
||||||
|
|
||||||
|
const BINARY = 'kpsteam';
|
||||||
|
const ARMA_APPID = '107410';
|
||||||
|
|
||||||
|
function promisifySpawn(command: string, args?: string[], options?: SpawnOptions) {
|
||||||
|
return new Promise<number>((resolve, reject) => {
|
||||||
|
const process = spawn(command, args, options);
|
||||||
|
|
||||||
|
process.stdout.on( 'data', data => console.log(`${data}`));
|
||||||
|
process.stderr.on( 'data', data => console.error(`${data}`));
|
||||||
|
|
||||||
|
process.on('close', code => {
|
||||||
|
console.log( `child process exited with code ${code}` );
|
||||||
|
if (code !== 0) {
|
||||||
|
return reject(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(code);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function uploadLegacy(itemId: string, path: string): Promise<number> {
|
||||||
|
return promisifySpawn(BINARY, [
|
||||||
|
`upload`,
|
||||||
|
`--app=${ARMA_APPID}`,
|
||||||
|
`--item=${itemId}`,
|
||||||
|
`--path=${path}`,
|
||||||
|
`--legacy`,
|
||||||
|
]);
|
||||||
|
}
|
|
@ -2,3 +2,5 @@
|
||||||
export * from "./MissionPaths";
|
export * from "./MissionPaths";
|
||||||
|
|
||||||
export * from "./Config";
|
export * from "./Config";
|
||||||
|
|
||||||
|
export * from "./KpSteam";
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
|
"moduleResolution": "node",
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noImplicitAny": true
|
"noImplicitAny": true
|
||||||
|
@ -12,4 +13,4 @@
|
||||||
"include": [
|
"include": [
|
||||||
"./src/"
|
"./src/"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue