Skip to content

Commit

Permalink
feat(Gadget-quickSave): Introduce quickSave
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnAngela committed Mar 16, 2023
1 parent cbae2b1 commit 965ba93
Show file tree
Hide file tree
Showing 14 changed files with 567 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/postCommit.yml
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: linguist-generated
run: node scripts/postCommit/linguist-generated.js
- name: Show git status
run: node scripts/postCommit/push.js
run: node scripts/postCommit/preparePush.js
- name: Run linter test # Name MUST NOT be changed.
uses: ./.github/linter test
with:
Expand Down
21 changes: 19 additions & 2 deletions .vscode/json-schemas/gadget-definition.json
@@ -1,5 +1,5 @@
{
"$id": "https://github.com/MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes/blob/master/.vscode/json-schemas/gadget-definition.json",
"$id": "gadget-definition.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "小工具定义",
Expand Down Expand Up @@ -165,7 +165,24 @@
]
},
"rights": {
"$ref": "user-rights-definition.json#/definitions/userRights"
"type": "array",
"default": [],
"title": "rights 指定用户所需要的权限,如无需权限可保留空数组,但不能删去",
"uniqueItems": true,
"minItems": 0,
"items": {
"anyOf": [
{
"$ref": "user-rights-definition.json#/definitions/userRights"
},
{
"$ref": "user-rights-definition.json#/definitions/fabricatedUserRights"
}
]
},
"examples": [
[]
]
},
"peers": {
"type": "array",
Expand Down
258 changes: 128 additions & 130 deletions .vscode/json-schemas/user-rights-definition.json
@@ -1,140 +1,138 @@
{
"$id": "https://github.com/MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes/blob/master/.vscode/json-schemas/gadget-definition.json",
"$id": "user-rights-definition.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "可用权限",
"additionalProperties": false,
"definitions": {
"fabricatedUserRights": {
"type": "string",
"title": "每个权限一个元素(虚拟权限)",
"enum": [
"hidden",
"disabled"
]
},
"userRights": {
"type": "array",
"default": [],
"title": "rights 指定用户所需要的权限,如无需权限可保留空数组,但不能删去",
"uniqueItems": true,
"minItems": 0,
"items": {
"type": "string",
"title": "每个权限一个元素",
"enum": [
"abusefilter-hidden-log",
"abusefilter-hide-log",
"abusefilter-log",
"abusefilter-log-detail",
"abusefilter-log-private",
"abusefilter-modify",
"abusefilter-modify-restricted",
"abusefilter-private",
"abusefilter-private-log",
"abusefilter-revert",
"abusefilter-view",
"abusefilter-view-private",
"ajaxpoll-view-results",
"ajaxpoll-view-results-before-vote",
"ajaxpoll-vote",
"apihighlimits",
"applychangetags",
"autoconfirmed",
"autopatrol",
"avataradmin",
"avatarupload",
"bigdelete",
"block",
"blockemail",
"bot",
"browsearchive",
"changetags",
"checkuser",
"checkuser-log",
"comment",
"commentadmin-restricted",
"createaccount",
"createpage",
"createtalk",
"delete",
"deletebatch",
"deletechangetags",
"deletedhistory",
"deletedtext",
"deletelogentry",
"deleterevision",
"edit",
"editcontentmodel",
"editinterface",
"editmyoptions",
"editmyprivateinfo",
"editmyusercss",
"editmyuserjs",
"editmyuserjson",
"editmywatchlist",
"editprotected",
"editsemiprotected",
"editusercss",
"edituserjs",
"edituserjson",
"editwidgets",
"extendedconfirmed",
"globalblock",
"globalblock-exempt",
"globalblock-whitelist",
"hideuser",
"import",
"importupload",
"interwiki",
"ipblock-exempt",
"lookupuser",
"managechangetags",
"markbotedits",
"masseditregex",
"mergehistory",
"minoredit",
"move",
"move-categorypages",
"move-rootuserpages",
"move-subpages",
"movefile",
"nominornewtalk",
"noratelimit",
"nuke",
"override-antispoof",
"patrol",
"patrolleredit",
"patrolmarks",
"protect",
"purge",
"read",
"renameuser",
"replacetext",
"reupload",
"reupload-own",
"reupload-shared",
"rollback",
"see-through-badwords",
"sendemail",
"skipcaptcha",
"spamblacklistlog",
"staffpower",
"suppressionlog",
"suppressredirect",
"suppressrevision",
"tboverride",
"techedit",
"titleblacklistlog",
"transcode-reset",
"transcode-status",
"unblockself",
"undelete",
"unwatchedpages",
"upload",
"upload_by_url",
"usermerge",
"userrights",
"viewmyprivateinfo",
"viewmywatchlist",
"viewsuppressed",
"writeapi"
]
},
"examples": [
[]
"type": "string",
"title": "每个权限一个元素",
"enum": [
"abusefilter-hidden-log",
"abusefilter-hide-log",
"abusefilter-log",
"abusefilter-log-detail",
"abusefilter-log-private",
"abusefilter-modify",
"abusefilter-modify-restricted",
"abusefilter-private",
"abusefilter-private-log",
"abusefilter-revert",
"abusefilter-view",
"abusefilter-view-private",
"ajaxpoll-view-results",
"ajaxpoll-view-results-before-vote",
"ajaxpoll-vote",
"apihighlimits",
"applychangetags",
"autoconfirmed",
"autopatrol",
"avataradmin",
"avatarupload",
"bigdelete",
"block",
"blockemail",
"bot",
"browsearchive",
"changetags",
"checkuser",
"checkuser-log",
"comment",
"commentadmin-restricted",
"createaccount",
"createpage",
"createtalk",
"delete",
"deletebatch",
"deletechangetags",
"deletedhistory",
"deletedtext",
"deletelogentry",
"deleterevision",
"edit",
"editcontentmodel",
"editinterface",
"editmyoptions",
"editmyprivateinfo",
"editmyusercss",
"editmyuserjs",
"editmyuserjson",
"editmywatchlist",
"editprotected",
"editsemiprotected",
"editusercss",
"edituserjs",
"edituserjson",
"editwidgets",
"extendedconfirmed",
"globalblock",
"globalblock-exempt",
"globalblock-whitelist",
"hideuser",
"import",
"importupload",
"interwiki",
"ipblock-exempt",
"lookupuser",
"managechangetags",
"markbotedits",
"masseditregex",
"mergehistory",
"minoredit",
"move",
"move-categorypages",
"move-rootuserpages",
"move-subpages",
"movefile",
"nominornewtalk",
"noratelimit",
"nuke",
"override-antispoof",
"patrol",
"patrolleredit",
"patrolmarks",
"protect",
"purge",
"read",
"renameuser",
"replacetext",
"reupload",
"reupload-own",
"reupload-shared",
"rollback",
"see-through-badwords",
"sendemail",
"skipcaptcha",
"spamblacklistlog",
"staffpower",
"suppressionlog",
"suppressredirect",
"suppressrevision",
"tboverride",
"techedit",
"titleblacklistlog",
"transcode-reset",
"transcode-status",
"unblockself",
"undelete",
"unwatchedpages",
"upload",
"upload_by_url",
"usermerge",
"userrights",
"viewmyprivateinfo",
"viewmywatchlist",
"viewsuppressed",
"writeapi"
]
}
}
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -95,6 +95,7 @@
"Gadget-queryContributions",
"Gadget-queryWhatlinkshere",
"Gadget-quickMoveThread",
"Gadget-quickSave",
"Gadget-ReferenceTooltips",
"Gadget-registerToDelete",
"Gadget-report",
Expand Down
3 changes: 3 additions & 0 deletions scripts/generatePolyfill/unrecognizableFeatures.json
Expand Up @@ -11,6 +11,7 @@
"AnalyserNode.prototype.constructor",
"Animation.prototype.cancel",
"Animation.prototype.constructor",
"Animation.prototype.finish",
"Animation.prototype.id",
"Animation.prototype.reverse",
"AnimationEffect.prototype.constructor",
Expand Down Expand Up @@ -2348,6 +2349,7 @@
"WebGL2RenderingContext.prototype.constructor",
"WebGL2RenderingContext.prototype.disable",
"WebGL2RenderingContext.prototype.enable",
"WebGL2RenderingContext.prototype.finish",
"WebGL2RenderingContext.prototype.hint",
"WebGL2RenderingContext.prototype.isBuffer",
"WebGLActiveInfo.prototype.constructor",
Expand All @@ -2364,6 +2366,7 @@
"WebGLRenderingContext.prototype.constructor",
"WebGLRenderingContext.prototype.disable",
"WebGLRenderingContext.prototype.enable",
"WebGLRenderingContext.prototype.finish",
"WebGLRenderingContext.prototype.hint",
"WebGLRenderingContext.prototype.isBuffer",
"WebGLSampler.prototype.constructor",
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateUserRightsSchema/index.js
Expand Up @@ -28,7 +28,7 @@ const schema = await jsonModule.readFile(".vscode/json-schemas/user-rights-defin
startGroup("old schema:");
console.info(schema);
endGroup();
schema.definitions.userRights.items.enum = userRights;
schema.definitions.userRights.enum = userRights;
startGroup("new schema:");
console.info(schema);
endGroup();
Expand Down
4 changes: 3 additions & 1 deletion scripts/modules/modulePath.js
@@ -1,5 +1,7 @@
import path from "path";
import { fileURLToPath } from "url";

/**
* @param {ImportMeta} meta
*/
export default (meta) => path.relative(process.cwd(), new URL(meta.url).pathname);
export default (meta) => path.relative(process.cwd(), fileURLToPath(meta.url));
9 changes: 7 additions & 2 deletions scripts/postCommit/preparePush.js
Expand Up @@ -14,8 +14,13 @@ const GITHUB_EVENT = await jsonModule.readFile(process.env.GITHUB_EVENT_PATH);
const isPushRequest = ["push"].includes(process.env.GITHUB_EVENT_NAME);
console.info("isPushRequest:", isPushRequest);
const { before, after } = GITHUB_EVENT;
console.info("commits:", { before, after });
const changedFiles = before && after ? (await git.raw(["diff-tree", "-c", "-r", "--no-commit-id", "--name-only", before, after])).trim() : "";
const isBeforeExists = before && after && (await git.branch(["--contains", before]).catch(() => ({ current: "" }))).current.length > 0;
console.info("commits:", { before, after, isBeforeExists });
const commits = [after];
if (isBeforeExists) {
commits.unshift(before);
}
const changedFiles = before && after ? (await git.raw(["diff-tree", "-c", "-r", "--no-commit-id", "--name-only", ...commits])).trim() : "";
startGroup("changedFiles:");
console.info(changedFiles);
endGroup();
Expand Down
5 changes: 5 additions & 0 deletions scripts/test/test.js
@@ -1,7 +1,12 @@
import { startGroup, endGroup } from "@actions/core";
import jsonModule from "../modules/jsonModule.js";
import path from "path";
import { fileURLToPath } from "url";

console.info("import.meta.url:", import.meta.url);
console.info("new URL(import.meta.url).pathname):", `${new URL(import.meta.url).pathname}`);
console.info("path.relative(process.cwd(), new URL(import.meta.url).pathname):", path.relative(process.cwd(), new URL(import.meta.url).pathname));
console.info("fileURLToPath(import.meta.url):", fileURLToPath(import.meta.url));
startGroup("process.env");
console.info(process.env);
endGroup();
Expand Down
1 change: 1 addition & 0 deletions src/gadgets/Gadgets-definition-list.yaml
Expand Up @@ -86,6 +86,7 @@
- autoconfirmedUserPing
- widgetPreload
- wikiBlame
- quickSave

- name: interface
gadgets:
Expand Down

0 comments on commit 965ba93

Please sign in to comment.