Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ async function config() {

// Get branch
const branch = ref?.split('/')?.pop()?.split('-')[0] || '(current branch could not be determined)';
// eslint-disable-next-line no-console

console.log(`Running on branch: ${branch}`);

// Set changelog file
const changelogFile = `./changelogs/CHANGELOG_${branch}.md`;
// eslint-disable-next-line no-console

console.log(`Changelog file output to: ${changelogFile}`);

// Load template file contents
Expand Down
4 changes: 2 additions & 2 deletions ci/CiVersionCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class CiVersionCheck {
* Runs the check.
*/
async check() {
/* eslint-disable no-console */

try {
console.log(`\nChecking ${this.packageName} versions in CI environments...`);

Expand Down Expand Up @@ -285,7 +285,7 @@ class CiVersionCheck {
const msg = `Failed to check ${this.packageName} versions with error: ${e}`;
core.setFailed(msg);
}
/* eslint-enable no-console */

}
}

Expand Down
2 changes: 1 addition & 1 deletion ci/definitionsCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const util = require('util');
fs.readFile('./src/Options/docs.js', 'utf8'),
]);
if (currentDefinitions !== newDefinitions || currentDocs !== newDocs) {
// eslint-disable-next-line no-console

console.error(
'\x1b[31m%s\x1b[0m',
'Definitions files cannot be updated manually. Please update src/Options/index.js then run `npm run definitions` to generate definitions.'
Expand Down
6 changes: 3 additions & 3 deletions ci/nodeEngineCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class NodeEngineCheck {
nodeVersion: version
});
} catch(e) {
// eslint-disable-next-line no-console

console.log(`Ignoring file because it is not valid JSON: ${file}`);
core.warning(`Ignoring file because it is not valid JSON: ${file}`);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ async function check() {
// Get highest version
const highestVersion = higherVersions.map(v => v.nodeMinVersion).pop();

/* eslint-disable no-console */

// If there are higher versions
if (higherVersions.length > 0) {
console.log(`\nThere are ${higherVersions.length} dependencies that require a higher node engine version than the parent package (${parentVersion.nodeVersion}):`);
Expand All @@ -191,7 +191,7 @@ async function check() {
}

console.log(`✅ All dependencies satisfy the node version requirement of the parent package (${parentVersion.nodeVersion}).`);
/* eslint-enable no-console */

}

check();
59 changes: 55 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const js = require("@eslint/js");
const babelParser = require("@babel/eslint-parser");
const globals = require("globals");

module.exports = [
{
ignores: ["**/lib/**", "**/coverage/**", "**/out/**", "**/types/**"],
Expand All @@ -9,14 +10,64 @@ module.exports = [
{
languageOptions: {
parser: babelParser,
parserOptions: {
requireConfigFile: false,
},
ecmaVersion: 6,
sourceType: "module",
globals: {
Parse: "readonly",
...globals.node,
},
parserOptions: {
requireConfigFile: false,
__dirname: true,
beforeEach: true,
Buffer: true,
console: true,
describe: true,
fail: true,
expect: true,
global: true,
it: true,
jasmine: true,
process: true,
spyOn: true,
it_exclude_dbs: true,
reconfigureServer: true,
createTestUser: true,
databaseAdapter: true,
Container: true,
expectAsync: true,
TestObject: true,
beforeAll: true,
afterAll: true,
afterEach: true,
mockFetch: true,
pending: true,
equal: true,
notEqual: true,
create: true,
Item: true,
strictEqual: true,
arrayContains: true,
jequal: true,
range: true,
defaultConfiguration: true,
jfail: true,
ok: true,
xit: true,
fit: true,
on_db: true,
it_id: true,
it_only_db: true,
fit_id: true,
fit_only_db: true,
databaseURI: true,
fdescribe: true,
xdescribe: true,
describe_only: true,
describe_only_db: true,
fdescribe_only_db: true,
it_only_mongodb_version: true,
spyOnProperty: true,
},
},
rules: {
Expand All @@ -34,7 +85,7 @@ module.exports = [
curly: ["error", "all"],
"block-spacing": ["error", "always"],
"no-unused-vars": "off",
"no-console": "warn"
"no-console": 0,
},
},
];
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
"ci:definitionsCheck": "node ./ci/definitionsCheck.js",
"definitions": "node ./resources/buildConfigDefinitions.js && prettier --write 'src/Options/*.js'",
"docs": "jsdoc -c ./jsdoc-conf.json",
"lint": "eslint --cache ./ --flag unstable_config_lookup_from_file",
"lint-fix": "eslint --fix --cache ./ --flag unstable_config_lookup_from_file",
"lint": "eslint --cache ./",
"lint-fix": "eslint --fix --cache ./",
"build": "babel src/ -d lib/ --copy-files --extensions '.ts,.js'",
"build:types": "tsc",
"watch": "babel --watch src/ -d lib/ --copy-files",
Expand Down
42 changes: 21 additions & 21 deletions spec/Adapters/Auth/gcenter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ describe('GameCenterAuth Adapter', function () {
const gcProd4 = fs.readFileSync(path.resolve(__dirname, '../../support/cert/gc-prod-4.cer'));
const digicertPem = fs.readFileSync(path.resolve(__dirname, '../../support/cert/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem')).toString();

mockFetch([
{
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
method: 'GET',
response: {
ok: true,
headers: new Map(),
arrayBuffer: () => Promise.resolve(
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
),
mockFetch([
{
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
method: 'GET',
response: {
ok: true,
headers: new Map(),
arrayBuffer: () => Promise.resolve(
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
),
},
},
},
{
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
method: 'GET',
response: {
ok: true,
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
text: () => Promise.resolve(digicertPem),
},
}
]);
{
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
method: 'GET',
response: {
ok: true,
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
text: () => Promise.resolve(digicertPem),
},
}
]);
});

describe('Test config failing due to missing params or wrong types', function () {
Expand Down
107 changes: 55 additions & 52 deletions spec/AudienceRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,59 +317,62 @@ describe('AudiencesRouter', () => {
);
});

it_id('af1111b5-3251-4b40-8f06-fb0fc624fa91')(it_exclude_dbs(['postgres']))('should support legacy parse.com audience fields', done => {
const database = Config.get(Parse.applicationId).database.adapter.database;
const now = new Date();
Parse._request(
'POST',
'push_audiences',
{ name: 'My Audience', query: JSON.stringify({ deviceType: 'ios' }) },
{ useMasterKey: true }
).then(audience => {
database
.collection('test__Audience')
.updateOne(
{ _id: audience.objectId },
{
$set: {
times_used: 1,
_last_used: now,
},
}
)
.then(result => {
expect(result).toBeTruthy();
it_id('af1111b5-3251-4b40-8f06-fb0fc624fa91')(it_exclude_dbs(['postgres']))(
'should support legacy parse.com audience fields',
done => {
const database = Config.get(Parse.applicationId).database.adapter.database;
const now = new Date();
Parse._request(
'POST',
'push_audiences',
{ name: 'My Audience', query: JSON.stringify({ deviceType: 'ios' }) },
{ useMasterKey: true }
).then(audience => {
database
.collection('test__Audience')
.updateOne(
{ _id: audience.objectId },
{
$set: {
times_used: 1,
_last_used: now,
},
}
)
.then(result => {
expect(result).toBeTruthy();

database
.collection('test__Audience')
.find({ _id: audience.objectId })
.toArray()
.then(rows => {
expect(rows[0]['times_used']).toEqual(1);
expect(rows[0]['_last_used']).toEqual(now);
Parse._request(
'GET',
'push_audiences/' + audience.objectId,
{},
{ useMasterKey: true }
)
.then(audience => {
expect(audience.name).toEqual('My Audience');
expect(audience.query.deviceType).toEqual('ios');
expect(audience.timesUsed).toEqual(1);
expect(audience.lastUsed).toEqual(now.toISOString());
done();
})
.catch(error => {
done.fail(error);
});
})
.catch(error => {
done.fail(error);
});
});
});
});
database
.collection('test__Audience')
.find({ _id: audience.objectId })
.toArray()
.then(rows => {
expect(rows[0]['times_used']).toEqual(1);
expect(rows[0]['_last_used']).toEqual(now);
Parse._request(
'GET',
'push_audiences/' + audience.objectId,
{},
{ useMasterKey: true }
)
.then(audience => {
expect(audience.name).toEqual('My Audience');
expect(audience.query.deviceType).toEqual('ios');
expect(audience.timesUsed).toEqual(1);
expect(audience.lastUsed).toEqual(now.toISOString());
done();
})
.catch(error => {
done.fail(error);
});
})
.catch(error => {
done.fail(error);
});
});
});
}
);

it('should be able to search on audiences', done => {
Parse._request(
Expand Down
10 changes: 2 additions & 8 deletions spec/Auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,10 @@ describe('extendSessionOnUse', () => {
const { shouldUpdateSessionExpiry } = require('../lib/Auth');
let update = new Date(Date.now() - 86410 * 1000);

const res = shouldUpdateSessionExpiry(
{ sessionLength: 86460 },
{ updatedAt: update }
);
const res = shouldUpdateSessionExpiry({ sessionLength: 86460 }, { updatedAt: update });

update = new Date(Date.now() - 43210 * 1000);
const res2 = shouldUpdateSessionExpiry(
{ sessionLength: 86460 },
{ updatedAt: update }
);
const res2 = shouldUpdateSessionExpiry({ sessionLength: 86460 }, { updatedAt: update });

expect(res).toBe(true);
expect(res2).toBe(false);
Expand Down
Loading
Loading