bump scripts
This commit is contained in:
Родитель
5d6c394463
Коммит
9503c2fe65
|
@ -1,75 +1,48 @@
|
|||
/* eslint-disable no-console */
|
||||
import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import { parseArgs } from "util";
|
||||
import { runCommand, executeCommand } from "./utils.js";
|
||||
|
||||
interface Arguments {
|
||||
folderName: string;
|
||||
command?: "pylint" | "mypy" | "pyright" | "eslint";
|
||||
skipWarning?: boolean;
|
||||
skipEslint?: boolean;
|
||||
}
|
||||
|
||||
const validCommands = ["pylint", "mypy", "pyright", "eslint"];
|
||||
|
||||
// PARSE INPUT ARGUMENTS
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option("folderName", {
|
||||
type: "string",
|
||||
choices: ["generator", "autorest"],
|
||||
description: "Specify the flavor",
|
||||
default: "generator",
|
||||
})
|
||||
.option("command", {
|
||||
alias: "c",
|
||||
type: "string",
|
||||
choices: validCommands,
|
||||
description: "Specify the command to run",
|
||||
})
|
||||
.option("skipWarning", {
|
||||
alias: "s",
|
||||
type: "boolean",
|
||||
description: "Skip to check warnings",
|
||||
})
|
||||
.option("skipEslint", {
|
||||
alias: "e",
|
||||
type: "boolean",
|
||||
description: "Skip to check eslint",
|
||||
}).argv as Arguments;
|
||||
|
||||
const argv = parseArgs({args: process.argv.slice(2), options: {
|
||||
folderName: { type: 'string' },
|
||||
command: { type: 'string' },
|
||||
skipWarning: { type: 'boolean' },
|
||||
skipEslint: { type: 'boolean' },
|
||||
},});
|
||||
|
||||
export function pylint() {
|
||||
runCommand(`pylint ${argv.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
|
||||
runCommand(`pylint ${argv.values.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
|
||||
}
|
||||
|
||||
export function mypy() {
|
||||
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
|
||||
runCommand(`mypy ${argv.values.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
|
||||
}
|
||||
|
||||
export function pyright() {
|
||||
runCommand(`pyright ${argv.folderName}/ -p ./scripts/eng/pyrightconfig.json`, "pyright");
|
||||
runCommand(`pyright ${argv.values.folderName}/ -p ./scripts/eng/pyrightconfig.json`, "pyright");
|
||||
}
|
||||
|
||||
export function eslint() {
|
||||
// const checkWarning = argv.skipWarning ? "" : "--max-warnings=0";
|
||||
const checkWarning = "";
|
||||
executeCommand(`npx eslint . --ext .ts ${checkWarning} `, "eslint");
|
||||
}
|
||||
|
||||
if (argv.command === "pylint") {
|
||||
if (argv.values.command === "pylint") {
|
||||
pylint();
|
||||
} else if (argv.command === "mypy") {
|
||||
} else if (argv.values.command === "mypy") {
|
||||
mypy();
|
||||
} else if (argv.command === "pyright") {
|
||||
} else if (argv.values.command === "pyright") {
|
||||
pyright();
|
||||
} else if (argv.command === "eslint") {
|
||||
if (!argv.skipEslint) {
|
||||
} else if (argv.values.command === "eslint") {
|
||||
if (!argv.values.skipEslint) {
|
||||
eslint();
|
||||
}
|
||||
} else {
|
||||
pylint();
|
||||
mypy();
|
||||
pyright();
|
||||
if (!argv.skipEslint) {
|
||||
if (!argv.values.skipEslint) {
|
||||
eslint();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/* eslint-disable no-console */
|
||||
import { exec as execCallback } from "child_process";
|
||||
import { promisify } from "util";
|
||||
import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import { parseArgs } from "util";
|
||||
import { dirname, join, relative, resolve } from "path";
|
||||
import { promises, rmSync } from "fs";
|
||||
import { fileURLToPath } from "url";
|
||||
|
@ -136,13 +135,13 @@ async function executeCommand(tspCommand: TspCommand): Promise<void> {
|
|||
}
|
||||
|
||||
interface RegenerateFlagsInput {
|
||||
flavor?: "azure" | "unbranded";
|
||||
flavor?: string;
|
||||
debug?: boolean;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
interface RegenerateFlags {
|
||||
flavor: "azure" | "unbranded";
|
||||
flavor: string;
|
||||
debug: boolean;
|
||||
name?: string;
|
||||
}
|
||||
|
@ -270,23 +269,14 @@ async function regenerate(flags: RegenerateFlagsInput): Promise<void> {
|
|||
}
|
||||
|
||||
// PARSE INPUT ARGUMENTS
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option("flavor", {
|
||||
type: "string",
|
||||
choices: ["azure", "unbranded"],
|
||||
description: "Specify the flavor",
|
||||
})
|
||||
.option("debug", {
|
||||
alias: "d",
|
||||
type: "boolean",
|
||||
description: "Debug mode",
|
||||
})
|
||||
.option("name", {
|
||||
alias: "n",
|
||||
type: "string",
|
||||
description: "Specify filename if you only want to generate a subset",
|
||||
}).argv;
|
||||
|
||||
regenerate(argv as RegenerateFlags)
|
||||
const argv = parseArgs({args: process.argv.slice(2), options: {
|
||||
flavor: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
debug: { type: 'boolean' },
|
||||
},});
|
||||
|
||||
|
||||
regenerate(argv.values)
|
||||
.then(() => console.log("Regeneration successful"))
|
||||
.catch((error) => console.error(`Regeneration failed: ${error.message}`));
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
import { execSync } from "child_process";
|
||||
import { readFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import { parseArgs } from "util";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
interface Arguments {
|
||||
|
@ -15,34 +14,16 @@ interface Arguments {
|
|||
|
||||
const validCommands = ["ci", "lint", "mypy", "pyright", "apiview"];
|
||||
|
||||
// Parse command-line arguments using yargs
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option("validFolders", {
|
||||
alias: "vf",
|
||||
describe: "Specify the valid folders",
|
||||
type: "array",
|
||||
default: ["azure", "unbranded"],
|
||||
})
|
||||
.option("flavor", {
|
||||
alias: "f",
|
||||
describe: "Specify the flavor to use",
|
||||
type: "string",
|
||||
})
|
||||
.option("command", {
|
||||
alias: "c",
|
||||
describe: "Specify the command to run",
|
||||
choices: validCommands,
|
||||
type: "string",
|
||||
})
|
||||
.option("name", {
|
||||
alias: "n",
|
||||
describe: "Specify the name of the test",
|
||||
type: "string",
|
||||
}).argv as Arguments;
|
||||
const argv = parseArgs({args: process.argv.slice(2), options: {
|
||||
validFolders: { type: 'string', required: true, multiple: true },
|
||||
flavor: { type: 'string' },
|
||||
command: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
},});
|
||||
|
||||
const foldersToProcess = argv.flavor ? [argv.flavor] : argv.validFolders;
|
||||
const foldersToProcess = argv.values.flavor ? [argv.values.flavor] : argv.values.validFolders!;
|
||||
|
||||
const commandToRun = argv.command || "all";
|
||||
const commandToRun = argv.values.command || "all";
|
||||
|
||||
function getCommand(command: string, flavor: string, name?: string): string {
|
||||
if (!validCommands.includes(command)) throw new Error(`Unknown command '${command}'.`);
|
||||
|
@ -73,11 +54,11 @@ foldersToProcess.forEach((flavor) => {
|
|||
if (commandToRun === "all") {
|
||||
for (const key of validCommands) {
|
||||
console.log(`Running ${key} for flavor ${flavor}...`);
|
||||
myExecSync(key, flavor, argv.name);
|
||||
myExecSync(key, flavor, argv.values.name);
|
||||
}
|
||||
} else if (getCommand(commandToRun, flavor, argv.name)) {
|
||||
} else if (getCommand(commandToRun, flavor, argv.values.name)) {
|
||||
console.log(`Running ${commandToRun} for flavor ${flavor}...`);
|
||||
myExecSync(commandToRun, flavor, argv.name);
|
||||
myExecSync(commandToRun, flavor, argv.values.name);
|
||||
} else {
|
||||
console.error(`Error: Unknown command '${commandToRun}'.`);
|
||||
process.exit(1);
|
||||
|
|
|
@ -25,7 +25,7 @@ export function executeCommand(command: string, prettyName: string) {
|
|||
|
||||
// Function to run a command and log the output
|
||||
export function runCommand(command: string, prettyName: string) {
|
||||
let pythonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "venv/");
|
||||
let pythonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "venv/");
|
||||
if (existsSync(join(pythonPath, "bin"))) {
|
||||
pythonPath = join(pythonPath, "bin", "python");
|
||||
} else if (existsSync(join(pythonPath, "Scripts"))) {
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
"@azure-tools/cadl-ranch-specs": "0.37.1",
|
||||
"@types/js-yaml": "~4.0.5",
|
||||
"@types/node": "^18.16.3",
|
||||
"@types/yargs": "17.0.32",
|
||||
"@types/semver": "7.5.8",
|
||||
"@typespec/eslint-config-typespec": "~0.55.0",
|
||||
"@typespec/openapi": "~0.59.0",
|
||||
|
@ -89,7 +88,6 @@
|
|||
"@typespec/rest": "~0.59.0",
|
||||
"@typespec/versioning": "~0.59.0",
|
||||
"@azure-tools/typespec-azure-rulesets": "0.45.0",
|
||||
"yargs": "~17.2.1",
|
||||
"chalk": "5.3.0",
|
||||
"vitest": "^1.4.0"
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче