mirror of
https://github.com/chenasraf/DefinitelyTyped-tools.git
synced 2026-05-17 17:48:07 +00:00
Fix errors, run both npm and github
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,4 +3,5 @@ node_modules
|
||||
*.log
|
||||
dist
|
||||
*.tsbuildinfo
|
||||
*.lerna_backup
|
||||
*.lerna_backup
|
||||
packages/utils/cache
|
||||
@@ -7,7 +7,8 @@
|
||||
"lint": "eslint . --ext .ts",
|
||||
"format": "prettier --write 'packages/**/*.ts'",
|
||||
"test": "jest",
|
||||
"build": "tsc -b tsconfig.all.json"
|
||||
"build": "tsc -b tsconfig.all.json",
|
||||
"retag": "node packages/retag/lib/retag.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.3",
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
installAllTypeScriptVersions
|
||||
} from "@definitelytyped/utils";
|
||||
|
||||
import { allDependencies, getAffectedPackages } from "@definitelytyped/definitions-parser/src/get-affected-packages";
|
||||
import { allDependencies, getAffectedPackages } from "@definitelytyped/definitions-parser";
|
||||
import { numberOfOsProcesses } from "../util/util";
|
||||
|
||||
const perfDir = joinPaths(os.homedir(), ".dts", "perf");
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
const yargs = require("yargs");
|
||||
const process = require('process')
|
||||
const process = require("process");
|
||||
|
||||
const {
|
||||
withNpmCache, NpmPublishClient, UncachedNpmInfoClient,
|
||||
consoleLogger, logUncaughtErrors, loggerWithErrors, Registry,
|
||||
nAtATime, } = require("@definitelytyped/utils");
|
||||
withNpmCache,
|
||||
NpmPublishClient,
|
||||
UncachedNpmInfoClient,
|
||||
consoleLogger,
|
||||
logUncaughtErrors,
|
||||
loggerWithErrors,
|
||||
Registry,
|
||||
nAtATime
|
||||
} = require("@definitelytyped/utils");
|
||||
const { AllPackages, parseDefinitions, getDefinitelyTyped } = require("@definitelytyped/definitions-parser");
|
||||
const {
|
||||
AllPackages, parseDefinitions, getDefinitelyTyped,
|
||||
} = require("@definitelytyped/definitions-parser");
|
||||
const {
|
||||
parseNProcesses,
|
||||
updateLatestTag, updateTypeScriptVersionTags, getLatestTypingVersion
|
||||
parseNProcesses,
|
||||
updateLatestTag,
|
||||
updateTypeScriptVersionTags,
|
||||
getLatestTypingVersion
|
||||
} = require("@definitelytyped/publisher");
|
||||
|
||||
logUncaughtErrors(tag(!!yargs.argv.dry, /** @type {string=} */(yargs.argv.name)));
|
||||
logUncaughtErrors(main);
|
||||
|
||||
async function main() {
|
||||
await tag(!!yargs.argv.dry, false, /** @type {string=} */ (yargs.argv.name));
|
||||
await tag(!!yargs.argv.dry, true, /** @type {string=} */ (yargs.argv.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the tags on every package.
|
||||
@@ -23,36 +34,38 @@ logUncaughtErrors(tag(!!yargs.argv.dry, /** @type {string=} */(yargs.argv.name))
|
||||
* This shouldn't normally need to run, since we run `tagSingle` whenever we publish a package.
|
||||
* But this should be run if the way we calculate tags changes (e.g. when a new release is allowed to be tagged "latest").
|
||||
* @param {boolean} dry
|
||||
* @param {boolean} github
|
||||
* @param {string} [name]
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async function tag(dry, name) {
|
||||
const log = loggerWithErrors()[0];
|
||||
const options = { definitelyTypedPath: "../DefinitelyTyped", progress: true, parseInParallel: true };
|
||||
await parseDefinitions(
|
||||
await getDefinitelyTyped(options, log),
|
||||
// TODO: Going to have to move DT-tools to ~ probably
|
||||
{ nProcesses: parseNProcesses(), definitelyTypedPath: "../DefinitelyTyped" },
|
||||
log);
|
||||
async function tag(dry, github, name) {
|
||||
const log = loggerWithErrors()[0];
|
||||
const options = { definitelyTypedPath: "../DefinitelyTyped", progress: true, parseInParallel: true };
|
||||
await parseDefinitions(
|
||||
await getDefinitelyTyped(options, log),
|
||||
{ nProcesses: parseNProcesses(), definitelyTypedPath: "../DefinitelyTyped" },
|
||||
log
|
||||
);
|
||||
|
||||
const registryName = !!true ? Registry.NPM : Registry.Github;
|
||||
const token = /** @type {string} */(registryName === Registry.Github ? process.env.GH_API_TOKEN : process.env.NPM_TOKEN);
|
||||
const registryName = github ? Registry.Github : Registry.NPM;
|
||||
const token =
|
||||
/** @type {string} */ (registryName === Registry.Github ? process.env.GH_API_TOKEN : process.env.NPM_TOKEN);
|
||||
|
||||
const publishClient = await NpmPublishClient.create(token, {}, Registry.Github);
|
||||
await withNpmCache(new UncachedNpmInfoClient(), async infoClient => {
|
||||
if (name) {
|
||||
const pkg = await AllPackages.readSingle(name);
|
||||
const version = await getLatestTypingVersion(pkg, infoClient);
|
||||
await updateTypeScriptVersionTags(pkg, version, publishClient, consoleLogger.info, dry);
|
||||
await updateLatestTag(pkg.fullNpmName, version, publishClient, consoleLogger.info, dry);
|
||||
} else {
|
||||
await nAtATime(10, await AllPackages.readLatestTypings(), async pkg => {
|
||||
// Only update tags for the latest version of the package.
|
||||
const version = await getLatestTypingVersion(pkg, infoClient);
|
||||
await updateTypeScriptVersionTags(pkg, version, publishClient, consoleLogger.info, dry);
|
||||
await updateLatestTag(pkg.fullNpmName, version, publishClient, consoleLogger.info, dry);
|
||||
});
|
||||
}
|
||||
});
|
||||
// Don't tag notNeeded packages
|
||||
const publishClient = await NpmPublishClient.create(token, {}, registryName);
|
||||
await withNpmCache(new UncachedNpmInfoClient(), async infoClient => {
|
||||
if (name) {
|
||||
const pkg = await AllPackages.readSingle(name);
|
||||
const version = await getLatestTypingVersion(pkg, infoClient);
|
||||
await updateTypeScriptVersionTags(pkg, version, publishClient, consoleLogger.info, dry);
|
||||
await updateLatestTag(pkg.fullNpmName, version, publishClient, consoleLogger.info, dry);
|
||||
} else {
|
||||
await nAtATime(10, await AllPackages.readLatestTypings(), async pkg => {
|
||||
// Only update tags for the latest version of the package.
|
||||
const version = await getLatestTypingVersion(pkg, infoClient);
|
||||
await updateTypeScriptVersionTags(pkg, version, publishClient, consoleLogger.info, dry);
|
||||
await updateLatestTag(pkg.fullNpmName, version, publishClient, consoleLogger.info, dry);
|
||||
});
|
||||
}
|
||||
});
|
||||
// Don't tag notNeeded packages
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user