diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 00000000..41b6441b --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,35 @@ +name: Build npm package +on: push +jobs: + build: + if: contains(github.event.head_commit.message, '🔖') + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + # Setup .npmrc file to use GitHub Packages + - uses: actions/setup-node@v3 + with: + node-version: '10.x' + registry-url: 'https://npm.pkg.github.com' + # Defaults to the user or organization that owns the workflow file + scope: '@screeps' + - name: Install + run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish (github) + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-node@v3 + with: + node-version: '10.x' + registry-url: 'https://registry.npmjs.org' + scope: '@screeps' + - name: Publish (npmjs) + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }} diff --git a/.npmignore b/.npmignore index 24531a47..127c146e 100644 --- a/.npmignore +++ b/.npmignore @@ -2,6 +2,7 @@ node_modules .idea .run +.github build/config.gypi src/local-config.js dist/core diff --git a/package-lock.json b/package-lock.json index 4272c0f5..24cd7335 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@screeps/engine", - "version": "4.2.16", + "version": "4.2.17-rc1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -36,9 +36,9 @@ } }, "@screeps/pathfinding": { - "version": "0.4.16", - "resolved": "https://registry.npmjs.org/@screeps/pathfinding/-/pathfinding-0.4.16.tgz", - "integrity": "sha1-0dCKmij21UrDzx8qV6X+ppAuVpc=", + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/@screeps/pathfinding/-/pathfinding-0.4.17.tgz", + "integrity": "sha512-W8z4jkKe+PHtWWNZ3Q4Jy/BtK90hqe/THt1bXlFNlgCZrZxMh5ckAsKfa4v1jSHX1QE35BkQYH0yxYt5Q+o6rw==", "requires": { "heap": "0.2.5" } @@ -2226,7 +2226,7 @@ "heap": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/heap/-/heap-0.2.5.tgz", - "integrity": "sha1-cTtlWQ68xA/L7q9V6FFpQJKzmvE=" + "integrity": "sha512-G7HLD+WKcrOyJP5VQwYZNC3Z6FcQ7YYjEFiFoIj8PfEr73mu421o8B1N5DKUcc8K37EsJ2XXWA8DtrDz/2dReg==" }, "home-or-tmp": { "version": "2.0.0", @@ -2768,7 +2768,8 @@ "natives": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz", - "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==" + "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==", + "dev": true }, "nice-try": { "version": "1.0.5", diff --git a/package.json b/package.json index 48093667..16749126 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@screeps/engine", - "version": "4.2.16", + "version": "4.2.17-rc1", "bin": { "screeps-engine-main": "dist/main.js", "screeps-engine-runner": "dist/runner.js", @@ -8,10 +8,11 @@ }, "main": "dist/index.js", "scripts": { - "test": "cross-env DRIVER_MODULE=@screeps/driver jasmine" + "test": "cross-env DRIVER_MODULE=@screeps/driver jasmine", + "prepublish": "gulp" }, "dependencies": { - "@screeps/pathfinding": "^0.4.16", + "@screeps/pathfinding": "^0.4.17", "bulk-require": "^0.2.1", "cross-env": "^5.2.0", "lodash": "3.10.1", @@ -41,5 +42,8 @@ "transform-es2015-destructuring", "transform-strict-mode" ] + }, + "browser": { + "@screeps/core": "@screeps/simcore" } } diff --git a/src/game/game.js b/src/game/game.js index f9506004..579a2b49 100644 --- a/src/game/game.js +++ b/src/game/game.js @@ -6,7 +6,8 @@ C = driver.constants, map = require('./map'), market = require('./market'), - customPrototypes = require('./custom-prototypes'); + customPrototypes = require('./custom-prototypes'), + system = { Function: { bind: Function.bind } }; var findCacheFn = { [C.FIND_CREEPS]: (i) => !i.spawning, @@ -505,7 +506,7 @@ !_.isObject(runCodeCache[userId].globals.require.cache.main) || !_.isFunction( runCodeCache[userId].globals.require.cache.main.loop)) { - runCodeCache[userId].globals.require = requireFn.bind(runCodeCache[userId]); + runCodeCache[userId].globals.require = system.Function.bind.call(requireFn, runCodeCache[userId]); runCodeCache[userId].globals.require.cache = {lodash: runCodeCache[userId].globals._}; runCodeCache[userId].globals.require.timestamp = runCodeCache[userId].runtimeData.userCodeTimestamp; } diff --git a/src/utils.js b/src/utils.js index 7c25b460..35c03a83 100644 --- a/src/utils.js +++ b/src/utils.js @@ -15,7 +15,7 @@ catch(e) {} exports.getDriver = function getDriver() { driver = typeof process != 'undefined' && process.env.DRIVER_MODULE ? require(process.env.DRIVER_MODULE) : - require('./core/index'); + require('@screeps/core'); loadDriver(); return driver; };