You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
// bundle-submit.js
|
|
// Copyright (C) 2022 Rob Colbert @[email protected]
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
import 'dotenv/config';
|
|
|
|
import path, { dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
const __dirname = dirname(fileURLToPath(import.meta.url)); // jshint ignore:line
|
|
|
|
import { createRequire } from "module";
|
|
const require = createRequire(import.meta.url); // jshint ignore:line
|
|
|
|
import fetch, { FormData, fileFrom } from 'node-fetch';
|
|
|
|
/*
|
|
* This script loads the developer's credentials, verifies that a bundle exists,
|
|
* and sends that bundle to the configured hosting environment.
|
|
*/
|
|
|
|
(async ( ) => {
|
|
|
|
try {
|
|
const pkg = require(path.join(__dirname, 'package.json'));
|
|
const formData = new FormData();
|
|
|
|
formData.set('package', pkg);
|
|
|
|
const bundleFileName = path.join(__dirname, 'bundle', process.argv[2]);
|
|
const bundleFile = fileFrom(bundleFileName, 'application/gzip');
|
|
formData.set('bundle-file', bundleFile, 'nice-bundle.tar.gz');
|
|
|
|
const response = await fetch(`https://${process.env.ARCADE_HOST}/submissions`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-Game-Id': process.env.ARCADE_GAME_ID,
|
|
'X-Developer-Id': process.env.ARCADE_DEVELOPER_ID,
|
|
'X-Developer-Key': process.env.ARCADE_DEVELOPER_KEY,
|
|
},
|
|
body: formData,
|
|
});
|
|
const message = await response.text();
|
|
console.log(message);
|
|
} catch (error) {
|
|
console.log('ERROR:', error.message, error);
|
|
} finally {
|
|
console.log('Nice Arcade bundle submission process complete.');
|
|
}
|
|
})();
|