Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome web store automation #13

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions chrome-web-store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
var fs = require("fs");
var ncp = require("ncp").ncp;
var process = require("process");
var zipFolder = require('zip-folder');

var packageJson = require("./package.json");

var chromeWebStoreManifest = {
// ----------------- Required -----------------
// "app" Used by packaged apps to specify the app's background scripts. Also used by hosted apps to specify the URLs that the app uses.
"app": {
// "background" Used by packaged apps to specify the app's background scripts. Also used by hosted apps to specify the URLs that the app uses.
"background": {
// Optional
"scripts": ["background.js"]
}
},
// For Splat purposes this should always be the integer 2 without quotes. More info: https://developer.chrome.com/apps/manifest/manifest_version
"manifest_version": 2,
"name": packageJson.name,
// "version" One to four dot-separated integers identifying the version of this game. Must be between 0 and 65535, inclusive, and non-zero integers can't start with 0. More info: https://developer.chrome.com/apps/manifest/version
"version": packageJson.version,

// ----------------- Recommended -----------------
//"default_locale": "en",
"description": packageJson.description,
// "icons" paths to png icons 128, 48, and 16 recommended at minimum. More info: https://developer.chrome.com/apps/manifest/icons
"icons": packageJson.icons,

// ----------------- Optional -----------------
"author": packageJson.author,

// More information on optional features can be found here: https://developer.chrome.com/apps/manifest
// "automation": "",
// "bluetooth": {
// "uuids": ["1105", "1006"]
// },
// "commands": {""},
// "current_locale": "",
// "event_rules": [{""}],
// "externally_connectable": {
// "matches": ["*://*.example.com/*"]
// },
// "file_handlers": {""},
// "file_system_provider_capabilities": {
// "configurable": true,
// "multiple_mounts": true,
// "source": "network"
// },
// "import": [{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],
// "key": "publicKey",
// "kiosk": {
// "required_platform_version": ""
// },
// "kiosk_enabled": true,
// "kiosk_only": true,
// "kiosk_secondary_apps": "",
// "minimum_chrome_version": "versionString",
// "nacl_modules": [""],
// "oauth2": "",
// "offline_enabled" Let's users know that game works without internet connection with a lightning bolt icon in the store. Mark false if you have ads or any online features! More info: https://developer.chrome.com/apps/manifest/offline_enabled
"offline_enabled": packageJson.offlineEnabled
// "optional_permissions": ["tabs"],
// "permissions": ["tabs"],
// "platforms": "",
// "requirements": {""},
// "sandbox": [""],
// "short_name": "Short Name",
// "signature": "",
// "sockets": {
// "tcp": {
// "connect": "*"
// },
// "udp": {
// "send": "*"
// }
// },
// "storage": {
// "managed_schema": "schema.json"
// },
// "system_indicator": "",
// "update_url": "http://path/to/updateInfo.xml",
// "url_handlers": {""},
// "usb_printers": {
// "filters": [""]
// },
// "version_name": "aString",
// "webview": {""}
};

var backgroundJsCode = "chrome.app.runtime.onLaunched.addListener(function() {"
+" chrome.app.window.create('index.html', {"
+" 'bounds': " + JSON.stringify(packageJson.gameBounds, null, 2)
+" });"
+"});";

ncp("build/html", "build/chrome-web-store", function(err) {
if (err) {
console.error(err);
process.exit(1);
}

fs.writeFile("build/chrome-web-store/background.js", backgroundJsCode, function(err) {
if (err) {
console.error(err);
process.exit(2);
}

fs.writeFile("build/chrome-web-store/manifest.json", JSON.stringify(chromeWebStoreManifest, null, 2), function(err) {
if (err) {
console.error(err);
process.exit(3);
}

zipFolder('build/chrome-web-store', 'build/chrome-web-store-build.zip', function(err) {
if(err) {
console.log('Error in zipping Chrome web store Build', err);
} else {
console.log('Chrome Web Store Build ready. build/chrome-web-store-build.zip');
}
});

});

});

});
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@
"name": "splat-ecs-starter-project",
"version": "0.0.0",
"description": "A Sample game",
"gameBounds": {
"width": 1920,
"height": 1080
},
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"offlineEnabled": true,
"private": true,
"main": "src/game.js",
"scripts": {
"build": "webpack",
"clean": "rimraf build",
"electron": "webpack && node electron.js",
"chrome-web-store": "webpack && node chrome-web-store.js",
"lint": "eslint .",
"start": "webpack-dev-server --hot --inline --content-base build/html --host 0.0.0.0 --port 4000",
"watch": "webpack --watch"
Expand Down Expand Up @@ -38,6 +49,7 @@
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"splat-ecs": "^7.1.0"
"splat-ecs": "^7.1.0",
"zip-folder": "^1.0.0"
}
}
Binary file added src/icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var soundRegExp = new RegExp(soundPath + ".*\.(mp3|ogg|wav)$", "i");
var imagePath = pathForRegexp("src/images");
var imageRegExp = new RegExp(imagePath + ".*\.(jpe?g|png|gif|svg)$", "i");

var iconPath = pathForRegexp("src/icons");
var iconRegExp = new RegExp(iconPath + ".*\.(jpe?g|png|gif|svg)$", "i");

var fontPath = pathForRegexp("src/fonts");
var fontRegExp = new RegExp(fontPath + ".*\.(eot|svg|ttf|woff2?)$", "i");

Expand Down Expand Up @@ -48,6 +51,13 @@ module.exports = {
//"image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false"
]
},
{
test: iconRegExp,
loaders: [
"file?hash=sha512&digest=hex&name=[path][name].[ext]&context=src"
//"image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false"
]
},
{
test: fontRegExp,
loader: "file?hash=sha512&digest=hex&name=[path][name].[ext]&context=src"
Expand Down