mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
dependencies: Remove three JS argument parsing libraries.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
da749d1c94
commit
ff70ab441d
@@ -122,7 +122,6 @@
|
||||
"callsites": "^3.1.0",
|
||||
"cldr-annotations-derived-modern": "^45.0.0",
|
||||
"cldr-annotations-modern": "^45.0.0",
|
||||
"commander": "^12.0.0",
|
||||
"confusing-browser-globals": "^1.0.11",
|
||||
"css.escape": "^1.5.1",
|
||||
"diff": "^7.0.0",
|
||||
@@ -137,7 +136,6 @@
|
||||
"eslint-plugin-no-jquery": "^3.0.2",
|
||||
"eslint-plugin-unicorn": "^56.0.0",
|
||||
"jsdom": "^25.0.0",
|
||||
"minimist": "^1.2.6",
|
||||
"mockdate": "^3.0.2",
|
||||
"nyc": "^17.0.0",
|
||||
"openapi-examples-validator": "^5.0.0",
|
||||
@@ -154,7 +152,6 @@
|
||||
"webpack-dev-server": "^5.0.2",
|
||||
"xvfb": "^0.4.0",
|
||||
"yaml": "^2.0.0-8",
|
||||
"yargs": "^17.1.1",
|
||||
"zulip-js": "^2.0.8"
|
||||
},
|
||||
"pnpm": {
|
||||
|
15
pnpm-lock.yaml
generated
15
pnpm-lock.yaml
generated
@@ -377,9 +377,6 @@ importers:
|
||||
cldr-annotations-modern:
|
||||
specifier: ^45.0.0
|
||||
version: 45.0.0
|
||||
commander:
|
||||
specifier: ^12.0.0
|
||||
version: 12.1.0
|
||||
confusing-browser-globals:
|
||||
specifier: ^1.0.11
|
||||
version: 1.0.11
|
||||
@@ -422,9 +419,6 @@ importers:
|
||||
jsdom:
|
||||
specifier: ^25.0.0
|
||||
version: 25.0.1
|
||||
minimist:
|
||||
specifier: ^1.2.6
|
||||
version: 1.2.8
|
||||
mockdate:
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.5
|
||||
@@ -473,9 +467,6 @@ importers:
|
||||
yaml:
|
||||
specifier: ^2.0.0-8
|
||||
version: 2.6.0
|
||||
yargs:
|
||||
specifier: ^17.1.1
|
||||
version: 17.7.2
|
||||
zulip-js:
|
||||
specifier: ^2.0.8
|
||||
version: 2.1.0(encoding@0.1.13)
|
||||
@@ -3464,10 +3455,6 @@ packages:
|
||||
resolution: {integrity: sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
commander@12.1.0:
|
||||
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
commander@2.20.3:
|
||||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||
|
||||
@@ -12604,8 +12591,6 @@ snapshots:
|
||||
|
||||
commander@12.0.0: {}
|
||||
|
||||
commander@12.1.0: {}
|
||||
|
||||
commander@2.20.3: {}
|
||||
|
||||
commander@6.2.1: {}
|
||||
|
@@ -3,21 +3,24 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("node:fs");
|
||||
const {parseArgs} = require("node:util");
|
||||
|
||||
const Diff = require("diff");
|
||||
const ExampleValidator = require("openapi-examples-validator");
|
||||
const Prettier = require("prettier");
|
||||
const SwaggerParser = require("swagger-parser");
|
||||
const {Composer, CST, LineCounter, Parser, Scalar, YAMLMap, YAMLSeq, visit} = require("yaml");
|
||||
const {hideBin} = require("yargs/helpers");
|
||||
const yargs = require("yargs/yargs");
|
||||
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option("fix", {
|
||||
type: "boolean",
|
||||
description: "Automatically fix some problems",
|
||||
})
|
||||
.parse();
|
||||
const usage = "Usage: check-openapi [--fix] <file>...";
|
||||
const {
|
||||
values: {fix, help},
|
||||
positionals: files,
|
||||
} = parseArgs({options: {fix: {type: "boolean"}, help: {type: "boolean"}}, allowPositionals: true});
|
||||
|
||||
if (help) {
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
async function checkFile(file) {
|
||||
const yaml = await fs.promises.readFile(file, "utf8");
|
||||
@@ -85,7 +88,7 @@ async function checkFile(file) {
|
||||
formatted = formatted.replace(/\n$/, "");
|
||||
}
|
||||
if (formatted !== node.value.value) {
|
||||
if (argv.fix) {
|
||||
if (fix) {
|
||||
reformats.set(node.value.range[0], {
|
||||
value: formatted,
|
||||
context: {afterKey: true},
|
||||
@@ -158,7 +161,7 @@ async function checkFile(file) {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
for (const file of argv._) {
|
||||
for (const file of files) {
|
||||
await checkFile(file);
|
||||
}
|
||||
})().catch((error) => {
|
||||
|
@@ -4,28 +4,28 @@
|
||||
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const {parseArgs} = require("node:util");
|
||||
|
||||
const {program} = require("commander");
|
||||
require("css.escape");
|
||||
const puppeteer = require("puppeteer");
|
||||
|
||||
const options = {};
|
||||
const usage = "Usage: message-screenshot.js <message_id> <image_path> <realm_url>";
|
||||
const {
|
||||
values: {help},
|
||||
positionals: [messageId, imagePath, realmUrl],
|
||||
} = parseArgs({options: {help: {type: "boolean"}}, allowPositionals: true});
|
||||
|
||||
program
|
||||
.arguments("<message_id> <image_path> <realm_url>")
|
||||
.action((messageId, imagePath, realmUrl) => {
|
||||
options.messageId = messageId;
|
||||
options.imagePath = imagePath;
|
||||
options.realmUrl = realmUrl;
|
||||
console.log(`Capturing screenshot for message ${messageId} to ${imagePath}`);
|
||||
})
|
||||
.parse(process.argv);
|
||||
|
||||
if (options.messageId === undefined) {
|
||||
console.error("no messageId specified!");
|
||||
if (help) {
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
if (realmUrl === undefined) {
|
||||
console.error(usage);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Capturing screenshot for message ${messageId} to ${imagePath}`);
|
||||
|
||||
// TODO: Refactor to share code with web/e2e-tests/realm-creation.test.ts
|
||||
async function run() {
|
||||
const browser = await puppeteer.launch({
|
||||
@@ -43,7 +43,7 @@ async function run() {
|
||||
const page = await browser.newPage();
|
||||
// deviceScaleFactor:2 gives better quality screenshots (higher pixel density)
|
||||
await page.setViewport({width: 1280, height: 1024, deviceScaleFactor: 2});
|
||||
await page.goto(`${options.realmUrl}/devlogin`);
|
||||
await page.goto(`${realmUrl}/devlogin`);
|
||||
// wait for Iago devlogin button and click on it.
|
||||
await page.waitForSelector('[value="iago@zulip.com"]');
|
||||
|
||||
@@ -54,17 +54,15 @@ async function run() {
|
||||
]);
|
||||
|
||||
// Navigate to message and capture screenshot
|
||||
await page.goto(`${options.realmUrl}/#narrow/id/${options.messageId}`, {
|
||||
await page.goto(`${realmUrl}/#narrow/id/${messageId}`, {
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
// eslint-disable-next-line no-undef
|
||||
const message_list_id = await page.evaluate(() => zulip_test.current_msg_list.id);
|
||||
const messageSelector = `#message-row-${message_list_id}-${CSS.escape(options.messageId)}`;
|
||||
const messageSelector = `#message-row-${message_list_id}-${CSS.escape(messageId)}`;
|
||||
await page.waitForSelector(messageSelector);
|
||||
// remove unread marker and don't select message
|
||||
const marker = `#message-row-${message_list_id}-${CSS.escape(
|
||||
options.messageId,
|
||||
)} .unread_marker`;
|
||||
const marker = `#message-row-${message_list_id}-${CSS.escape(messageId)} .unread_marker`;
|
||||
await page.evaluate((sel) => $(sel).remove(), marker);
|
||||
const messageBox = await page.$(messageSelector);
|
||||
await page.evaluate((msg) => $(msg).removeClass("selected_message"), messageSelector);
|
||||
@@ -74,7 +72,6 @@ async function run() {
|
||||
clip.x -= 5;
|
||||
clip.width += 10;
|
||||
clip.y += 5;
|
||||
const imagePath = options.imagePath;
|
||||
const imageDir = path.dirname(imagePath);
|
||||
await fs.promises.mkdir(imageDir, {recursive: true});
|
||||
await page.screenshot({path: imagePath, clip});
|
||||
|
@@ -4,30 +4,29 @@
|
||||
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const {parseArgs} = require("node:util");
|
||||
|
||||
const {program} = require("commander");
|
||||
require("css.escape");
|
||||
const puppeteer = require("puppeteer");
|
||||
|
||||
const options = {};
|
||||
const usage =
|
||||
"Usage: thread-screenshot.js <narrow_uri> <narrow> <message_id> <image_path> <realm_url>";
|
||||
const {
|
||||
values: {help},
|
||||
positionals: [narrowUri, narrow, messageId, imagePath, realmUrl],
|
||||
} = parseArgs({options: {help: {type: "boolean"}}, allowPositionals: true});
|
||||
|
||||
program
|
||||
.arguments("<narrow_uri> <narrow> <unread_msg_id> <image_path> <realm_url>")
|
||||
.action((narrow_uri, narrow, unread_msg_id, imagePath, realmUrl) => {
|
||||
options.narrowUri = narrow_uri;
|
||||
options.narrow = narrow;
|
||||
options.messageId = unread_msg_id;
|
||||
options.imagePath = imagePath;
|
||||
options.realmUrl = realmUrl;
|
||||
console.log(`Capturing screenshot for ${narrow} to ${imagePath}`);
|
||||
})
|
||||
.parse(process.argv);
|
||||
|
||||
if (options.imagePath === undefined) {
|
||||
console.error("no image path specified!");
|
||||
if (help) {
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
if (realmUrl === undefined) {
|
||||
console.error(usage);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Capturing screenshot for ${narrow} to ${imagePath}`);
|
||||
|
||||
// TODO: Refactor to share code with web/e2e-tests/realm-creation.test.ts
|
||||
async function run() {
|
||||
const browser = await puppeteer.launch({
|
||||
@@ -45,7 +44,7 @@ async function run() {
|
||||
const page = await browser.newPage();
|
||||
// deviceScaleFactor:2 gives better quality screenshots (higher pixel density)
|
||||
await page.setViewport({width: 530, height: 1024, deviceScaleFactor: 2});
|
||||
await page.goto(`${options.realmUrl}/devlogin`);
|
||||
await page.goto(`${realmUrl}/devlogin`);
|
||||
// wait for Iago devlogin button and click on it.
|
||||
await page.waitForSelector('[value="iago@zulip.com"]');
|
||||
|
||||
@@ -56,7 +55,7 @@ async function run() {
|
||||
]);
|
||||
|
||||
// Navigate to message and capture screenshot
|
||||
await page.goto(`${options.narrowUri}`, {
|
||||
await page.goto(`${narrowUri}`, {
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
// eslint-disable-next-line no-undef
|
||||
@@ -72,7 +71,7 @@ async function run() {
|
||||
$(sel).remove();
|
||||
}, marker);
|
||||
|
||||
const messageSelector = `#message-row-${message_list_id}-${CSS.escape(options.messageId)}`;
|
||||
const messageSelector = `#message-row-${message_list_id}-${CSS.escape(messageId)}`;
|
||||
await page.waitForSelector(messageSelector);
|
||||
|
||||
const messageListBox = await page.$(messageListSelector);
|
||||
@@ -91,7 +90,6 @@ async function run() {
|
||||
clip.width -= 64;
|
||||
clip.y += 10;
|
||||
clip.height -= 8;
|
||||
const imagePath = options.imagePath;
|
||||
const imageDir = path.dirname(imagePath);
|
||||
await fs.promises.mkdir(imageDir, {recursive: true});
|
||||
await page.screenshot({path: imagePath, clip});
|
||||
|
@@ -49,4 +49,4 @@ API_FEATURE_LEVEL = 319 # Last bumped for message-link class
|
||||
# historical commits sharing the same major version, in which case a
|
||||
# minor version bump suffices.
|
||||
|
||||
PROVISION_VERSION = (300, 0) # bumped 2024-11-10 to remove mkdirp
|
||||
PROVISION_VERSION = (301, 0) # bumped 2024-11-10 to remove commander, minimist, yargs
|
||||
|
@@ -127,23 +127,24 @@ module.exports = {diff_strings};
|
||||
// Simple CLI for this module
|
||||
// Only run this code if called as a command-line utility
|
||||
if (require.main === module) {
|
||||
// First two args are just "node" and "mdiff.js"
|
||||
const argv = require("minimist")(process.argv.slice(2));
|
||||
const {parseArgs} = require("node:util");
|
||||
|
||||
if (Object.hasOwn(argv, "help")) {
|
||||
console.log(
|
||||
process.argv[0] +
|
||||
" " +
|
||||
process.argv[1] +
|
||||
" [ --help ]" +
|
||||
" string_0" +
|
||||
" string_1" +
|
||||
"\n" +
|
||||
"Where string_0 and string_1 are the strings to be diffed",
|
||||
);
|
||||
const usage =
|
||||
"Usage: mdiff <string_0> <string_1>\nWhere <string_0> and <string_1> are the strings to be diffed";
|
||||
const {
|
||||
values: {help},
|
||||
positionals: [string_0, string_1],
|
||||
} = parseArgs({options: {help: {type: "boolean"}}, allowPositionals: true});
|
||||
|
||||
if (help) {
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
if (string_1 === undefined) {
|
||||
console.error(usage);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const output = diff_strings(argv._[0], argv._[1]);
|
||||
const output = diff_strings(string_0, string_1);
|
||||
console.log(output);
|
||||
}
|
||||
|
Reference in New Issue
Block a user