style(dev-infra): enforce format on newly included files (#36940)

Historically files to be formatted were added to a listing (via matchers)
to be included in formatting.  Instead, this change begins efforts to
instead include all files in format enforcement, relying instead on an
opt out methodology.

PR Close #36940
This commit is contained in:
Joey Perrott 2020-05-05 13:12:39 -07:00 committed by Misko Hevery
parent 34e4098e85
commit d3b5e5696f
11 changed files with 88 additions and 83 deletions

View File

@ -60,14 +60,15 @@ if (require.resolve === module) {
// Helpers
function _main(args) {
triggerWebhook(...args).
then(({statusCode, responseText}) => (200 <= statusCode && statusCode < 400) ?
console.log(`Status: ${statusCode}\n${responseText}`) :
Promise.reject(new Error(`Request failed (status: ${statusCode}): ${responseText}`))).
catch(err => {
console.error(err);
process.exit(1);
});
triggerWebhook(...args)
.then(
({statusCode, responseText}) => (200 <= statusCode && statusCode < 400) ?
console.log(`Status: ${statusCode}\n${responseText}`) :
Promise.reject(new Error(`Request failed (status: ${statusCode}): ${responseText}`)))
.catch(err => {
console.error(err);
process.exit(1);
});
}
function postJson(url, data) {
@ -77,15 +78,12 @@ function postJson(url, data) {
const statusCode = res.statusCode || -1;
let responseText = '';
res.
on('error', reject).
on('data', d => responseText += d).
on('end', () => resolve({statusCode, responseText}));
res.on('error', reject)
.on('data', d => responseText += d)
.on('end', () => resolve({statusCode, responseText}));
};
request(url, opts, onResponse).
on('error', reject).
end(JSON.stringify(data));
request(url, opts, onResponse).on('error', reject).end(JSON.stringify(data));
});
}

View File

@ -24,18 +24,11 @@ var hosts = [];
PORTS.forEach(function(port) {
fakeServers.push(http.createServer(function() {}).listen(port));
hosts.push({
name: HOSTNAME,
port: port,
sslFlag: 0
});
hosts.push({name: HOSTNAME, port: port, sslFlag: 0});
});
var tunnel = new BrowserStackTunnel({
key: ACCESS_KEY,
localIdentifier: TUNNEL_IDENTIFIER,
hosts: hosts
});
var tunnel =
new BrowserStackTunnel({key: ACCESS_KEY, localIdentifier: TUNNEL_IDENTIFIER, hosts: hosts});
console.info('Starting tunnel on ports', PORTS.join(', '));
tunnel.start(function(error) {

View File

@ -33,6 +33,4 @@ function buildDevInfraPackage() {
console.info('');
}
module.exports = {
buildDevInfraPackage
};
module.exports = {buildDevInfraPackage};

View File

@ -47,7 +47,12 @@ const bazelBin = exec(`${bazelCmd} info bazel-bin`, true);
const scriptPath = relative(baseDir, require.main.filename);
module.exports = {
baseDir, bazelBin, bazelCmd, buildTargetPackages, exec, scriptPath,
baseDir,
bazelBin,
bazelCmd,
buildTargetPackages,
exec,
scriptPath,
};
/**
@ -68,12 +73,13 @@ function buildTargetPackages(destPath, enableIvy, description) {
// List of targets to build, e.g. core, common, compiler, etc. Note that we want to also remove
// all carriage return (`\r`) characters form the query output, because otherwise the carriage
// return is part of the bazel target name and bazel will complain.
const getTargetsCmd =
`${bazelCmd} query --output=label "attr('tags', '\\[.*release-with-framework.*\\]', //packages/...) intersect kind('ng_package|pkg_npm', //packages/...)"`;
const getTargetsCmd = `${
bazelCmd} query --output=label "attr('tags', '\\[.*release-with-framework.*\\]', //packages/...) intersect kind('ng_package|pkg_npm', //packages/...)"`;
const targets = exec(getTargetsCmd, true).split(/\r?\n/);
// Use `--config=release` so that snapshot builds get published with embedded version info.
exec(`${bazelCmd} build --config=release --config=${enableIvy ? 'ivy' : 'view-engine'} ${targets.join(' ')}`);
exec(`${bazelCmd} build --config=release --config=${enableIvy ? 'ivy' : 'view-engine'} ${
targets.join(' ')}`);
// Create the output directory.
const absDestPath = resolve(baseDir, destPath);

View File

@ -50,11 +50,14 @@ for (const compressionType in limitSizes) {
const operator = actualSize > expectedSize ? 'exceeded' : 'fell below';
failureMessages.push(
`FAIL: Commit ${commit} ${compressionType} ${filename} ${operator} expected size by 500 bytes or >1% ` +
`(expected: ${expectedSize}, actual: ${actualSize}).`);
`FAIL: Commit ${commit} ${compressionType} ${filename} ${
operator} expected size by 500 bytes or >1% ` +
`(expected: ${expectedSize}, actual: ${actualSize}).`);
} else {
successMessages.push(`SUCCESS: Commit ${commit} ${compressionType} ${filename} did NOT cross size threshold of 500 bytes or >1% ` +
`(expected: ${expectedSize}, actual: ${actualSize}).`);
successMessages.push(
`SUCCESS: Commit ${commit} ${compressionType} ${
filename} did NOT cross size threshold of 500 bytes or >1% ` +
`(expected: ${expectedSize}, actual: ${actualSize}).`);
}
}
}
@ -65,7 +68,8 @@ for (const compressionType in limitSizes) {
successMessages.concat(failureMessages).forEach(message => console.error(message));
if (failed) {
console.info(`If this is a desired change, please update the size limits in file '${limitFile}'.`);
console.info(
`If this is a desired change, please update the size limits in file '${limitFile}'.`);
process.exit(1);
} else {
console.info(`Payload size check passed. All diffs are less than 1% or 500 bytes.`);

2
scripts/github/utils/github_closes.js Executable file → Normal file
View File

@ -28,7 +28,7 @@ if (require.main === module) {
function rewriteMsg(msg, prNo) {
var lines = msg.split(/\n/);
lines[0] += ' (#' + prNo +')';
lines[0] += ' (#' + prNo + ')';
lines.push('PR Close #' + prNo);
return lines.join('\n');
}

View File

@ -34,14 +34,14 @@ function extractPaths(obj, paths) {
paths.forEach(function(exp) {
var objs = obj instanceof Array ? [].concat(obj) : [obj];
exp.split('.').forEach(function(name) {
for(var i = 0; i < objs.length; i++) {
for (var i = 0; i < objs.length; i++) {
var o = objs[i];
if (o instanceof Array) {
// Expand and do over
objs = objs.slice(0, i).concat(o).concat(objs.slice(i+1, objs.length));
objs = objs.slice(0, i).concat(o).concat(objs.slice(i + 1, objs.length));
i--;
} else {
name.split("=").forEach(function(name, index) {
name.split('=').forEach(function(name, index) {
if (index == 0) {
objs[i] = o = o[name];
} else if (name.charAt(0) == '^') {
@ -54,7 +54,7 @@ function extractPaths(obj, paths) {
}
}
});
lines.push(objs.join("|"));
lines.push(objs.join('|'));
});
return lines;
}

View File

@ -8,40 +8,42 @@
* found in the LICENSE file at https://angular.io/license
*/
var assert = require("assert");
var assert = require('assert');
var extractPaths = require('./json_extract').extractPaths;
var SAMPLE_LABELS = [
{
"id": 149476251,
"url": "https://api.github.com/repos/angular/angular/labels/cla:%20yes",
"name": "cla: yes",
"color": "009800",
"default": false
'id': 149476251,
'url': 'https://api.github.com/repos/angular/angular/labels/cla:%20yes',
'name': 'cla: yes',
'color': '009800',
'default': false
},
{
"id": 533874619,
"url": "https://api.github.com/repos/angular/angular/labels/comp:%20aio",
"name": "comp: aio",
"color": "c7def8",
"default": false
'id': 533874619,
'url': 'https://api.github.com/repos/angular/angular/labels/comp:%20aio',
'name': 'comp: aio',
'color': 'c7def8',
'default': false
},
{
"id": 133556520,
"url": "https://api.github.com/repos/angular/angular/labels/PR%20action:%20merge",
"name": "PR action: merge",
"color": "99ff66",
"default": false
'id': 133556520,
'url': 'https://api.github.com/repos/angular/angular/labels/PR%20action:%20merge',
'name': 'PR action: merge',
'color': '99ff66',
'default': false
},
{
"id": 655699838,
"url": "https://api.github.com/repos/angular/angular/labels/PR%20target:%20master%20&%20patch",
"name": "PR target: master & patch",
"color": "5319e7",
"default": false
'id': 655699838,
'url': 'https://api.github.com/repos/angular/angular/labels/PR%20target:%20master%20&%20patch',
'name': 'PR target: master & patch',
'color': '5319e7',
'default': false
}
];
assert.deepEqual(extractPaths({head: {label: 'value1'}}, ['head.label']), ['value1']);
assert.deepEqual(extractPaths(SAMPLE_LABELS, ['name']), ['cla: yes|comp: aio|PR action: merge|PR target: master & patch']);
assert.deepEqual(
extractPaths(SAMPLE_LABELS, ['name']),
['cla: yes|comp: aio|PR action: merge|PR target: master & patch']);
assert.deepEqual(extractPaths(SAMPLE_LABELS, ['name=^PR target:']), ['PR target: master & patch']);

View File

@ -13,17 +13,17 @@
// "chromium_revision": "722234" but this does not map easily to the Chrome version
// so we use this mapping here instead.
module.exports = {
"3.3.0": "83.0.4103.0",
"3.2.0": "83.0.4103.0",
"3.1.0": "83.0.4103.0",
"3.0.0": "81.0.4044.0",
"2.1.1": "80.0.3987.0",
"2.1.0": "80.0.3987.0",
"2.0.0": "79.0.3942.0",
"1.20.0": "78.0.3882.0",
"1.19.0": "77.0.3803.0",
"1.17.0": "76.0.3803.0",
"1.15.0": "75.0.3765.0",
"1.13.0": "74.0.3723.0",
"1.12.2": "73.0.3679.0",
'3.3.0': '83.0.4103.0',
'3.2.0': '83.0.4103.0',
'3.1.0': '83.0.4103.0',
'3.0.0': '81.0.4044.0',
'2.1.1': '80.0.3987.0',
'2.1.0': '80.0.3987.0',
'2.0.0': '79.0.3942.0',
'1.20.0': '78.0.3882.0',
'1.19.0': '77.0.3803.0',
'1.17.0': '76.0.3803.0',
'1.15.0': '75.0.3765.0',
'1.13.0': '74.0.3723.0',
'1.12.2': '73.0.3679.0',
};

9
scripts/webdriver-manager-update.js Executable file → Normal file
View File

@ -16,7 +16,8 @@ const spawnSync = require('child_process').spawnSync;
const version = chromeVersionMap[puppeteerVersion];
if (!version) {
console.error(`[webdriver-manager-update.js] Error: Could not find Chrome version for Puppeteer version '${puppeteerVersion}' in Chrome/Puppeteer version map. Please update /scripts/puppeteer-chrome-versions.js.`);
console.error(`[webdriver-manager-update.js] Error: Could not find Chrome version for Puppeteer version '${
puppeteerVersion}' in Chrome/Puppeteer version map. Please update /scripts/puppeteer-chrome-versions.js.`);
process.exit(1);
}
@ -33,10 +34,12 @@ const args = [
const result = spawnSync('yarn', args, {shell: true, stdio: 'inherit'});
if (result.error) {
console.error(`[webdriver-manager-update.js] Call to 'yarn ${args.join(' ')}' failed with error code ${result.error.code}`);
console.error(`[webdriver-manager-update.js] Call to 'yarn ${
args.join(' ')}' failed with error code ${result.error.code}`);
process.exit(result.status);
}
if (result.status) {
console.error(`[webdriver-manager-update.js] Call to 'yarn ${args.join(' ')}' failed with error code ${result.status}`);
console.error(`[webdriver-manager-update.js] Call to 'yarn ${
args.join(' ')}' failed with error code ${result.status}`);
process.exit(result.status);
}

View File

@ -91,13 +91,13 @@ module.exports = (gulp, done) => {
`${RELATIVE_I18N_GLOBAL_FOLDER}/${locale}.js`,
generateGlobalLocale(
locale, locale === 'en' ? new cldrJs('en') : localeData, baseCurrencies));
});
console.log(`${LOCALES.length} locale files generated.`);
console.log(`All i18n cldr files have been generated, formatting files..."`);
shelljs.exec(
`yarn clang-format -i ${I18N_DATA_FOLDER}/**/*.ts ${I18N_DATA_FOLDER}/*.ts ${I18N_FOLDER}/currencies.ts ${I18N_CORE_FOLDER}/locale_en.ts ${I18N_GLOBAL_FOLDER}/*.js`,
`yarn clang-format -i ${I18N_DATA_FOLDER}/**/*.ts ${I18N_DATA_FOLDER}/*.ts ${
I18N_FOLDER}/currencies.ts ${I18N_CORE_FOLDER}/locale_en.ts ${I18N_GLOBAL_FOLDER}/*.js`,
{silent: true});
done();
};
@ -278,7 +278,8 @@ function generateCurrenciesFile() {
export type CurrenciesSymbols = [string] | [string | undefined, string];
/** @internal */
export const CURRENCIES_EN: {[code: string]: CurrenciesSymbols | [string | undefined, string | undefined, number]} = ${stringify(baseCurrencies, true)};
export const CURRENCIES_EN: {[code: string]: CurrenciesSymbols | [string | undefined, string | undefined, number]} = ${
stringify(baseCurrencies, true)};
`;
}