Skip to content

Commit

Permalink
Merge branch 'zotero:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sharonhoward authored Aug 31, 2024
2 parents 1966d9b + 6c9d01f commit ed64526
Show file tree
Hide file tree
Showing 595 changed files with 147,511 additions and 38,493 deletions.
11 changes: 11 additions & 0 deletions .ci/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"env": {
"node": true,
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"notice/notice": "off"
}
}
1 change: 0 additions & 1 deletion .ci/.gitignore

This file was deleted.

22 changes: 22 additions & 0 deletions .ci/AGPL
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
***** BEGIN LICENSE BLOCK *****

Copyright © ${ period } ${ holder }

This file is part of Zotero.

Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.

***** END LICENSE BLOCK *****
*/
49 changes: 0 additions & 49 deletions .ci/README.md

This file was deleted.

6 changes: 3 additions & 3 deletions .ci/checkDeletedTxt.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$SCRIPT_DIR/helper.sh"
. "$SCRIPT_DIR/helper.sh"
cd "$SCRIPT_DIR"

MASTER="master"
Expand All @@ -12,7 +12,7 @@ if [[ "$BRANCH" = "$MASTER" ]];then
exit 0
fi

if ! git branch |grep -q "$MASTER"; then
if ! git branch -a | grep -q "$MASTER"; then
echo "${color_warn}skip${color_reset} - Can only check deleted.txt when '$MASTER' branch is also available for comparison"
exit 0
fi
Expand All @@ -25,7 +25,7 @@ main() {
deletions+=($(git diff-index --diff-filter=D --name-only --find-renames $MASTER|grep -v '\.ci'|grep 'js$'))
if (( ${#deletions[@]} > 0 ));then
for f in "${deletions[@]}";do
local id=$(git show $MASTER:"$f"|grepTranslatorId)
local id=$(git show $MASTER:"$f" | get_translator_id)
if ! grep -qF "$id" '../deleted.txt';then
echo "${color_notok}not ok${color_reset} - $id ($f) should be added to deleted.txt"
(( failed += 1))
Expand Down
193 changes: 0 additions & 193 deletions .ci/checkTranslator.sh

This file was deleted.

9 changes: 9 additions & 0 deletions .ci/eslint-plugin-zotero-translator/bin/teslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

'use strict';

const path = require('path');

process.argv = process.argv.map(arg => arg === '--output-json' ? [ '--format', 'json', '--output-file' ] : arg).flat();

require('../../../node_modules/.bin/eslint')
15 changes: 15 additions & 0 deletions .ci/eslint-plugin-zotero-translator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @fileoverview Checks Zotero translators for errors and recommended style
* @author Emiliano Heyns
*/

'use strict';

const requireDir = require('require-dir');

module.exports = {
rules: requireDir('./lib/rules'),
processors: {
translator: require('./processor'),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict';

const { parsed, header } = require('../../processor').support;

module.exports = {
meta: {
type: 'problem',
docs: {
description: 'enforce valid lastUpdated in header',
category: 'Possible Errors',
},
fixable: 'code',
},

create: function (context) {
return {
Program: function (node) {
const filename = context.getFilename();
const translator = parsed(filename);
if (!translator || !translator.header.fields) return; // regular js source, or header is invalid

const lastUpdated = header(node).properties.find(p => p.key.value === 'lastUpdated');

if (!lastUpdated) {
context.report({
loc: { start: { line: 1, column: 1 } },
message: 'Header needs lastUpdated field',
});
return;
}

const format = date => date.toISOString().replace('T', ' ').replace(/\..*/, '');
const now = format(new Date());
const fix = fixer => fixer.replaceText(lastUpdated.value, `"${now}"`);

if (typeof lastUpdated.value.value !== 'string' || !lastUpdated.value.value.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/)) {
context.report({
node: lastUpdated.value,
message: `lastUpdated field must be a string in YYYY-MM-DD HH:MM:SS format`,
fix,
});
return;
}

if (translator.lastUpdated && translator.lastUpdated > lastUpdated.value.value) {
context.report({
node: lastUpdated.value,
message: `lastUpdated field must be updated to be > ${translator.lastUpdated} to push to clients`,
fix,
});
}
}
};
},
};
Loading

0 comments on commit ed64526

Please sign in to comment.