refactor(dev-infra): create ng-dev executable locally in the repo (#39089)
Rather than running ng-dev via ts-node, going forward ng-dev is generated and run locally via node. Additionally, the generated file is tested on each commit to ensure that the local generated version stays up to date. PR Close #39089
This commit is contained in:
parent
d939b5f598
commit
d331e09b71
|
@ -16,6 +16,8 @@ export const format: FormatConfig = {
|
|||
'!.yarn/**',
|
||||
// Do not format d.ts files as they are generated
|
||||
'!**/*.d.ts',
|
||||
// Do not format generated ng-dev script
|
||||
'!dev-infra/ng-dev.js',
|
||||
]
|
||||
},
|
||||
'buildifier': true
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test", "pkg_npm")
|
||||
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
||||
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
|
||||
|
||||
ts_library(
|
||||
name = "cli",
|
||||
|
@ -23,6 +24,23 @@ ts_library(
|
|||
],
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "cli_rollup",
|
||||
entry_point = ":cli.ts",
|
||||
format = "cjs",
|
||||
silent = True,
|
||||
sourcemap = "false",
|
||||
deps = [
|
||||
":cli",
|
||||
],
|
||||
)
|
||||
|
||||
generated_file_test(
|
||||
name = "local_ng_dev",
|
||||
src = "ng-dev.js",
|
||||
generated = "cli_rollup",
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "package-json",
|
||||
srcs = [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
import {getCaretakerConfig} from '../config';
|
||||
|
||||
import {printCiStatus} from './ci';
|
||||
|
|
|
@ -10,7 +10,7 @@ import fetch from 'node-fetch';
|
|||
import {fetchActiveReleaseTrains} from '../../release/versioning/index';
|
||||
|
||||
import {bold, debug, info} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
|
||||
|
||||
/** The results of checking the status of CI. */
|
||||
|
|
|
@ -13,7 +13,7 @@ import {parse as parseYaml} from 'yaml';
|
|||
|
||||
import {getRepoBaseDir} from '../../utils/config';
|
||||
import {bold, debug, info} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
|
||||
/** Compare the upstream master to the upstream g3 branch, if it exists. */
|
||||
export async function printG3Comparison(git: GitClient) {
|
||||
|
@ -120,6 +120,8 @@ export async function printG3Comparison(git: GitClient) {
|
|||
/** Determine whether the file name passes both include and exclude checks. */
|
||||
function checkMatchAgainstIncludeAndExclude(
|
||||
file: string, includes: string[], excludes: string[]) {
|
||||
return multimatch(file, includes).length >= 1 && multimatch(file, excludes).length === 0;
|
||||
return (
|
||||
multimatch.call(undefined, file, includes).length >= 1 &&
|
||||
multimatch.call(undefined, file, excludes).length === 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {alias, onUnion, params, types} from 'typed-graphqlify';
|
||||
|
||||
import {bold, debug, info} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
import {CaretakerConfig} from '../config';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
|
@ -7,15 +6,16 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import * as yargs from 'yargs';
|
||||
import {tsCircularDependenciesBuilder} from './ts-circular-dependencies/index';
|
||||
import {buildPullapproveParser} from './pullapprove/cli';
|
||||
|
||||
import {buildCaretakerParser} from './caretaker/cli';
|
||||
import {buildCommitMessageParser} from './commit-message/cli';
|
||||
import {buildFormatParser} from './format/cli';
|
||||
import {buildReleaseParser} from './release/cli';
|
||||
import {buildPrParser} from './pr/cli';
|
||||
import {captureLogOutputForCommand} from './utils/console';
|
||||
import {buildCaretakerParser} from './caretaker/cli';
|
||||
import {buildNgbotParser} from './ngbot/cli';
|
||||
import {buildPrParser} from './pr/cli';
|
||||
import {buildPullapproveParser} from './pullapprove/cli';
|
||||
import {buildReleaseParser} from './release/cli';
|
||||
import {tsCircularDependenciesBuilder} from './ts-circular-dependencies/index';
|
||||
import {captureLogOutputForCommand} from './utils/console';
|
||||
|
||||
yargs.scriptName('ng-dev')
|
||||
.middleware(captureLogOutputForCommand)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
pr/merge/strategies/commit-message-filter.js
|
|
@ -21,7 +21,3 @@ export function buildCommitMessageParser(localYargs: yargs.Argv) {
|
|||
.command(ValidateFileModule)
|
||||
.command(ValidateRangeModule);
|
||||
}
|
||||
|
||||
if (require.main == module) {
|
||||
buildCommitMessageParser(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,3 @@ export function buildFormatParser(localYargs: yargs.Argv) {
|
|||
executionCmd(files!);
|
||||
});
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
buildFormatParser(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import {exec} from 'shelljs';
|
|||
|
||||
import {info} from '../utils/console';
|
||||
|
||||
import {Formatter, FormatterAction, getActiveFormatters} from './formatters';
|
||||
import {Formatter, FormatterAction, getActiveFormatters} from './formatters/index';
|
||||
|
||||
const AVAILABLE_THREADS = Math.max(cpus().length - 1, 1);
|
||||
|
||||
|
@ -36,9 +36,9 @@ export function runFormatterInParallel(allFiles: string[], action: FormatterActi
|
|||
const pendingCommands: {formatter: Formatter, file: string}[] = [];
|
||||
|
||||
for (const formatter of formatters) {
|
||||
pendingCommands.push(...multimatch(allFiles, formatter.getFileMatcher(), {
|
||||
dot: true
|
||||
}).map(file => ({formatter, file})));
|
||||
pendingCommands.push(
|
||||
...multimatch.call(undefined, allFiles, formatter.getFileMatcher(), {dot: true})
|
||||
.map(file => ({formatter, file})));
|
||||
}
|
||||
|
||||
// If no commands are generated, resolve the promise as `false` as no files
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env ts-node
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
// Loads the ng-dev cli, automatically executing it.
|
||||
require('./cli.ts');
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,3 @@ export function buildNgbotParser(localYargs: yargs.Argv) {
|
|||
return localYargs.help().strict().demandCommand().command(
|
||||
'verify', 'Verify the NgBot config', {}, () => verify());
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
buildNgbotParser(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,3 @@ export function buildPrParser(localYargs: yargs.Argv) {
|
|||
buildRebaseCommand, handleRebaseCommand)
|
||||
.command(CheckoutCommandModule);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
buildPrParser(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
import {types as graphQLTypes} from 'typed-graphqlify';
|
||||
|
||||
import {info} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {addTokenToGitHttpsUrl} from '../../utils/git/github-urls';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
import {getPr} from '../../utils/github';
|
||||
|
||||
/* GraphQL schema for the response body for a pending PR. */
|
||||
|
|
|
@ -11,7 +11,7 @@ import {types as graphQLTypes} from 'typed-graphqlify';
|
|||
|
||||
import {getConfig, NgDevConfig} from '../../utils/config';
|
||||
import {error, info} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
import {getPendingPrs} from '../../utils/github';
|
||||
import {exec} from '../../utils/shelljs';
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ ts_library(
|
|||
exclude = ["**/*.spec.ts"],
|
||||
),
|
||||
module_name = "@angular/dev-infra-private/pr/merge",
|
||||
# prodmode target must be set to es5 as the Ora class, which is extended is not a proper
|
||||
# prototyped object.
|
||||
prodmode_target = "es5",
|
||||
visibility = ["//dev-infra:__subpackages__"],
|
||||
deps = [
|
||||
"//dev-infra/commit-message",
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
import {getConfig, getRepoBaseDir} from '../../utils/config';
|
||||
import {error, green, info, promptConfirm, red, yellow} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GithubApiRequestError} from '../../utils/git/github';
|
||||
import {GITHUB_TOKEN_GENERATE_URL} from '../../utils/git/github-urls';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
|
||||
import {loadAndValidateConfig, MergeConfigWithRemote} from './config';
|
||||
import {MergeResult, MergeStatus, PullRequestMergeTask} from './task';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import * as Octokit from '@octokit/rest';
|
||||
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
|
||||
import {PullRequestFailure} from './failures';
|
||||
import {matchesPattern} from './string-pattern';
|
||||
|
|
|
@ -10,7 +10,7 @@ import {PullsListCommitsResponse, PullsMergeParams} from '@octokit/rest';
|
|||
import {prompt} from 'inquirer';
|
||||
|
||||
import {parseCommitMessage} from '../../../commit-message/parse';
|
||||
import {GitClient} from '../../../utils/git';
|
||||
import {GitClient} from '../../../utils/git/index';
|
||||
import {GithubApiMergeMethod} from '../config';
|
||||
import {PullRequestFailure} from '../failures';
|
||||
import {PullRequest} from '../pull-request';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {GitClient} from '../../../utils/git';
|
||||
import {GitClient} from '../../../utils/git/index';
|
||||
import {PullRequestFailure} from '../failures';
|
||||
import {PullRequest} from '../pull-request';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {promptConfirm} from '../../utils/console';
|
||||
import {GitClient, GitCommandError} from '../../utils/git';
|
||||
import {GitClient, GitCommandError} from '../../utils/git/index';
|
||||
|
||||
import {MergeConfigWithRemote} from './config';
|
||||
import {PullRequestFailure} from './failures';
|
||||
|
|
|
@ -10,8 +10,8 @@ import {types as graphQLTypes} from 'typed-graphqlify';
|
|||
|
||||
import {getConfig, NgDevConfig} from '../../utils/config';
|
||||
import {error, info, promptConfirm} from '../../utils/console';
|
||||
import {GitClient} from '../../utils/git';
|
||||
import {addTokenToGitHttpsUrl} from '../../utils/git/github-urls';
|
||||
import {GitClient} from '../../utils/git/index';
|
||||
import {getPr} from '../../utils/github';
|
||||
|
||||
/* GraphQL schema for the response body for each pending PR. */
|
||||
|
|
|
@ -13,7 +13,3 @@ export function buildPullapproveParser(localYargs: yargs.Argv) {
|
|||
return localYargs.help().strict().demandCommand().command(
|
||||
'verify', 'Verify the pullapprove config', {}, () => verify());
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
buildPullapproveParser(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,3 @@ export function buildReleaseParser(localYargs: yargs.Argv) {
|
|||
'build-env-stamp', 'Build the environment stamping information', {},
|
||||
() => buildEnvStamp());
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
buildReleaseParser(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ export abstract class ReleaseAction {
|
|||
return new Promise((resolve, reject) => {
|
||||
debug(`Waiting for pull request #${id} to be merged.`);
|
||||
|
||||
const spinner = ora().start(`Waiting for pull request #${id} to be merged.`);
|
||||
const spinner = ora.call(undefined).start(`Waiting for pull request #${id} to be merged.`);
|
||||
const intervalId = setInterval(async () => {
|
||||
const prState = await getPullRequestState(this.git, id);
|
||||
if (prState === 'merged') {
|
||||
|
@ -517,7 +517,7 @@ export abstract class ReleaseAction {
|
|||
/** Publishes the given built package to NPM with the specified NPM dist tag. */
|
||||
private async _publishBuiltPackageToNpm(pkg: BuiltPackage, npmDistTag: string) {
|
||||
debug(`Starting publish of "${pkg.name}".`);
|
||||
const spinner = ora().start(`Publishing "${pkg.name}"`);
|
||||
const spinner = ora.call(undefined).start(`Publishing "${pkg.name}"`);
|
||||
|
||||
try {
|
||||
await runNpmPublish(pkg.outputPath, npmDistTag, this.config.publishRegistry);
|
||||
|
|
|
@ -11,7 +11,7 @@ import {Arguments, Argv, CommandModule} from 'yargs';
|
|||
import {getConfig, getRepoBaseDir} from '../../utils/config';
|
||||
import {error, green, info, red, yellow} from '../../utils/console';
|
||||
import {addGithubTokenOption} from '../../utils/git/github-yargs';
|
||||
import {getReleaseConfig} from '../config';
|
||||
import {getReleaseConfig} from '../config/index';
|
||||
|
||||
import {CompletionState, ReleaseTool} from './index';
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ export async function invokeSetNpmDistCommand(npmDistTag: string, version: semve
|
|||
* packages for the currently checked out branch.
|
||||
*/
|
||||
export async function invokeReleaseBuildCommand(): Promise<BuiltPackage[]> {
|
||||
const spinner = ora().start('Building release output.');
|
||||
const spinner = ora.call(undefined).start('Building release output.');
|
||||
try {
|
||||
// Since we expect JSON to be printed from the `ng-dev release build` command,
|
||||
// we spawn the process in silent mode. We have set up an Ora progress spinner.
|
||||
|
|
|
@ -46,7 +46,7 @@ async function handler(args: Arguments<ReleaseSetDistTagOptions>) {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
const spinner = ora().start();
|
||||
const spinner = ora.call(undefined).start();
|
||||
debug(`Setting "${tagName}" NPM dist tag for release packages to v${version}.`);
|
||||
|
||||
for (const pkgName of npmPackages) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
|
@ -13,12 +12,12 @@ import {isAbsolute, relative, resolve} from 'path';
|
|||
import * as ts from 'typescript';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import {green, info, error, red, yellow} from '../utils/console';
|
||||
import {error, green, info, red, yellow} from '../utils/console';
|
||||
|
||||
import {Analyzer, ReferenceChain} from './analyzer';
|
||||
import {compareGoldens, convertReferenceChainToGolden, Golden} from './golden';
|
||||
import {CircularDependenciesTestConfig, loadTestConfig} from './config';
|
||||
import {convertPathToForwardSlash} from './file_system';
|
||||
import {loadTestConfig, CircularDependenciesTestConfig} from './config';
|
||||
import {compareGoldens, convertReferenceChainToGolden, Golden} from './golden';
|
||||
|
||||
|
||||
export function tsCircularDependenciesBuilder(localYargs: yargs.Argv) {
|
||||
|
@ -134,7 +133,3 @@ function getRelativePath(baseDir: string, path: string) {
|
|||
function convertReferenceChainToString(chain: ReferenceChain<string>) {
|
||||
return chain.join(' → ');
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
tsCircularDependenciesBuilder(yargs).parse();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ ts_library(
|
|||
"git/*.ts",
|
||||
]),
|
||||
module_name = "@angular/dev-infra-private/utils",
|
||||
# prodmode target must be set to es5 as the Octokit class, which is extended is not a proper
|
||||
# prototyped object.
|
||||
prodmode_target = "es5",
|
||||
visibility = ["//dev-infra:__subpackages__"],
|
||||
deps = [
|
||||
"@npm//@octokit/graphql",
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {params, types} from 'typed-graphqlify';
|
||||
|
||||
import {GitClient} from './git';
|
||||
import {GitClient} from './git/index';
|
||||
|
||||
/** Get a PR from github */
|
||||
export async function getPr<PrSchema>(prSchema: PrSchema, prNumber: number, git: GitClient) {
|
||||
|
|
|
@ -34,10 +34,9 @@
|
|||
"public-api:update": "node goldens/public-api/manage.js accept",
|
||||
"symbol-extractor:check": "node tools/symbol-extractor/run_all_symbols_extractor_tests.js test",
|
||||
"symbol-extractor:update": "node tools/symbol-extractor/run_all_symbols_extractor_tests.js accept",
|
||||
"ts-circular-deps": "ts-node --transpile-only -- dev-infra/ts-circular-dependencies/index.ts --config ./packages/circular-deps-test.conf.js",
|
||||
"ts-circular-deps:check": "yarn -s ts-circular-deps check",
|
||||
"ts-circular-deps:approve": "yarn -s ts-circular-deps approve",
|
||||
"ng-dev": "ts-node --transpile-only -- dev-infra/cli.ts"
|
||||
"ts-circular-deps:check": "yarn -s ng-dev ts-circular-deps check --config ./packages/circular-deps-test.conf.js",
|
||||
"ts-circular-deps:approve": "yarn -s ng-dev ts-circular-deps approve --config ./packages/circular-deps-test.conf.js",
|
||||
"ng-dev": "node dev-infra/ng-dev"
|
||||
},
|
||||
"// 1": "dependencies are used locally and by bazel",
|
||||
"dependencies": {
|
||||
|
|
|
@ -98,7 +98,8 @@
|
|||
"./modules/benchmarks_external/**/*",
|
||||
// Ignore zone.js directory
|
||||
// TODO(JiaLiPassion): add zone.js back later
|
||||
"./packages/zone.js/**/*"
|
||||
"./packages/zone.js/**/*",
|
||||
"./dev-infra/ng-dev.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue