Skip to content

Commit

Permalink
🏗♻️ Reorganize all files in build-system/ (#24890)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha committed Oct 3, 2019
1 parent adbe236 commit db49f43
Show file tree
Hide file tree
Showing 90 changed files with 173 additions and 197 deletions.
4 changes: 2 additions & 2 deletions ads/_a4a-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export function getA4ARegistry() {
// TODO: Add new ad network implementation "is enabled" functions here.
// Note: if you add a function here that requires a new "import", above,
// you'll probably also need to add a whitelist exception to
// build-system/dep-check-config.js in the "filesMatching: 'ads/**/*.js'
// rule.
// build-system/test-configs/dep-check-config.js in the
// "filesMatching: 'ads/**/*.js'" rule.
});
}

Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'use strict';

const minimist = require('minimist');
const {isTravisBuild} = require('./build-system/travis');
const {isTravisBuild} = require('./build-system/common/travis');
const argv = minimist(process.argv.slice(2));

const isDist = argv._.includes('dist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const {
staticTemplateTags,
staticTemplateFactoryFns,
} = require('../../static-template-metadata');
} = require('../static-template-metadata');
const {minify} = require('html-minifier');

const INSERTED_TEMPLATES = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const {
assertAliases,
singletonFunctions,
transformableMethods,
} = require('../../log-module-metadata.js');
} = require('../log-module-metadata.js');

// Considered default for this transform, configurable only for tests.
// For other files output from this transform see linked module.
Expand Down Expand Up @@ -124,7 +124,7 @@ module.exports = function({types: t}) {

/**
* @param {!Node} node
* @return {../../log-module-metadata.LogMethodMetadataDef}
* @return {../log-module-metadata.LogMethodMetadataDef}
*/
function getTransformableCalleeMeta({callee}) {
if (assertAliases.some(name => t.isIdentifier(callee, {name}))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

const {VERSION} = require('../../internal-version');
const {VERSION} = require('../../compile/internal-version');

module.exports = function(babel) {
const {types: t} = babel;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the license.
#
# This file contains the default pre-push hook for AMPHTML. To enable it, run:
# "./build-system/enable-git-pre-push.sh"
# "./build-system/common/enable-git-pre-push.sh"
#
# Note: The checks in this file must not take more than a few seconds to run.
# Time consuming checks that call gulp build, or run all the tests are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@


SCRIPT=${BASH_SOURCE[0]}
BUILD_SYSTEM_DIR=$(dirname "$SCRIPT")
BUILD_SYSTEM_COMMON_DIR=$(dirname "$SCRIPT")
BUILD_SYSTEM_DIR=$(dirname "$BUILD_SYSTEM_COMMON_DIR")
AMPHTML_DIR=$(dirname "$BUILD_SYSTEM_DIR")
PRE_PUSH_SRC="build-system/default-pre-push"
PRE_PUSH_SRC="build-system/common/default-pre-push"
GIT_HOOKS_DIR=".git/hooks"
PRE_PUSH_DEST="$GIT_HOOKS_DIR/pre-push"
PRE_PUSH_BACKUP="$GIT_HOOKS_DIR/pre-push.backup"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/
const argv = require('minimist')(process.argv.slice(2));
const experimentsConfig = require('./global-configs/experiments-config.json');
const experimentsConstantBackup = require('./global-configs/experiments-const.json');
const experimentsConfig = require('../global-configs/experiments-config.json');
const experimentsConstantBackup = require('../global-configs/experiments-const.json');
const localPlugin = name =>
require.resolve(`./babel-plugins/babel-plugin-${name}`);
require.resolve(`../babel-plugins/babel-plugin-${name}`);

const defaultPlugins = [
// TODO(alanorozco): Remove `replaceCallArguments` once serving infra is up.
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions build-system/compile/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const {
handleTypeCheckError,
} = require('./closure-compile');
const {checkTypesNailgunPort, distNailgunPort} = require('../tasks/nailgun');
const {CLOSURE_SRC_GLOBS, SRC_TEMP_DIR} = require('../sources');
const {isTravisBuild} = require('../travis');
const {CLOSURE_SRC_GLOBS, SRC_TEMP_DIR} = require('./sources');
const {isTravisBuild} = require('../common/travis');
const {shortenLicense, shouldShortenLicense} = require('./shorten-license');
const {singlePassCompile} = require('./single-pass');
const {VERSION: internalRuntimeVersion} = require('../internal-version');
const {VERSION: internalRuntimeVersion} = require('./internal-version');

const isProdBuild = !!argv.type;
const queue = [];
Expand Down Expand Up @@ -133,10 +133,10 @@ function compile(
'build/patched-module/',
];
const baseExterns = [
'build-system/amp.extern.js',
'build-system/dompurify.extern.js',
'build-system/layout-jank.extern.js',
'build-system/performance-observer.extern.js',
'build-system/externs/amp.extern.js',
'build-system/externs/dompurify.extern.js',
'build-system/externs/layout-jank.extern.js',
'build-system/externs/performance-observer.extern.js',
'third_party/web-animations-externs/web_animations.js',
'third_party/moment/moment.extern.js',
'third_party/react-externs/externs.js',
Expand Down Expand Up @@ -264,7 +264,7 @@ function compile(
if (options.externs) {
externs = externs.concat(options.externs);
}
externs.push('build-system/amp.multipass.extern.js');
externs.push('build-system/externs/amp.multipass.extern.js');

/* eslint "google-camelcase/google-camelcase": 0*/
const compilerOptions = {
Expand Down Expand Up @@ -336,7 +336,7 @@ function compile(
'unknownDefines'
);
compilerOptions.conformance_configs =
'build-system/conformance-config.textproto';
'build-system/test-configs/conformance-config.textproto';
} else {
compilerOptions.jscomp_warning.push('accessControls', 'moduleLoad');
compilerOptions.jscomp_off.push('unknownDefines');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'use strict';

const argv = require('minimist')(process.argv.slice(2));
const {gitCommitFormattedTime} = require('./git');
const {gitCommitFormattedTime} = require('../common/git');

function getVersion() {
if (argv.version) {
Expand Down
6 changes: 3 additions & 3 deletions build-system/compile/single-pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const babel = require('@babel/core');
const babelify = require('babelify');
const browserify = require('browserify');
const colors = require('ansi-colors');
const conf = require('../build.conf');
const conf = require('./build.conf');
const del = require('del');
const devnull = require('dev-null');
const fs = require('fs-extra');
Expand Down Expand Up @@ -49,8 +49,8 @@ const {
const {shortenLicense, shouldShortenLicense} = require('./shorten-license');
const {TopologicalSort} = require('topological-sort');
const TYPES_VALUES = Object.keys(TYPES).map(x => TYPES[x]);
const wrappers = require('../compile-wrappers');
const {VERSION: internalRuntimeVersion} = require('../internal-version');
const wrappers = require('./compile-wrappers');
const {VERSION: internalRuntimeVersion} = require('./internal-version');

const argv = minimist(process.argv.slice(2));
let singlePassDest =
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const log = require('fancy-log');
const path = require('path');
const ts = require('typescript');
const tsickle = require('tsickle');
const {endBuildStep} = require('./tasks/helpers');
const {endBuildStep} = require('../tasks/helpers');

/**
* Given a file path `foo/bar.js`, transpiles the TypeScript entry point of
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/html-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
staticTemplateFactories,
staticTemplateTags,
staticTemplateFactoryFns,
} = require('../static-template-metadata');
} = require('../babel-plugins/static-template-metadata');

module.exports = function(context) {
function tagCannotBeCalled(node) {
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/no-log-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
definitionFile,
singletonFunctions,
transformableMethods,
} = require('../log-module-metadata.js');
} = require('../babel-plugins/log-module-metadata.js');

const selector = Object.keys(transformableMethods)
.map(name => `CallExpression[callee.property.name=${name}]`)
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/no-mixed-interpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
definitionFile,
singletonFunctions,
transformableMethods,
} = require('../log-module-metadata.js');
} = require('../babel-plugins/log-module-metadata.js');

/**
* @param {!Node} node
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions build-system/pr-check/build-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* determine which tasks are required to run for pull request builds.
*/
const colors = require('ansi-colors');
const config = require('../config');
const config = require('../test-configs/config');
const minimatch = require('minimatch');
const path = require('path');
const {gitDiffNameOnlyMaster} = require('../git');
const {gitDiffNameOnlyMaster} = require('../common/git');

/**
* A mapping of functions that match a given file to one or more build targets.
Expand All @@ -45,9 +45,9 @@ const targetMatchers = [
targets: ['BABEL_PLUGIN', 'RUNTIME'], // Test the runtime for babel plugin changes.
func: file => {
return (
file == 'build-system/internal-version.js' ||
file == 'build-system/log-module-metadata.js' ||
file == 'build-system/static-template-metadata.js' ||
file == 'build-system/babel-plugins/log-module-metadata.js' ||
file == 'build-system/babel-plugins/static-template-metadata.js' ||
file == 'build-system/compile/internal-version.js' ||
file == 'build-system/compile/log-messages.js' ||
file == 'build-system/tasks/babel-plugin-tests.js' ||
file.startsWith('build-system/babel-plugins/')
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const {
uploadBuildOutput,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');
const {runYarnChecks} = require('./yarn-checks');

const FILENAME = 'build.js';
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');
const {reportAllExpectedTests} = require('../tasks/report-test-status');
const {runYarnChecks} = require('./yarn-checks');

Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/dist-bundle-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const {
uploadDistOutput,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');
const {runYarnChecks} = require('./yarn-checks');
const {signalDistUpload} = require('../tasks/pr-deploy-bot-utils');

Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');

const FILENAME = 'e2e-tests.js';
const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/local-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');

const FILENAME = 'local-tests.js';
const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/remote-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');

const FILENAME = 'remote-tests.js';
const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/single-pass-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');

const FILENAME = 'single-pass-tests.js';
const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
Expand Down
9 changes: 5 additions & 4 deletions build-system/pr-check/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const {
gitDiffStatMaster,
gitTravisMasterBaseline,
shortSha,
} = require('../git');
} = require('../common/git');
const {
isTravisBuild,
travisBuildNumber,
travisPullRequestSha,
} = require('../travis');
const {execOrDie, execWithError, exec} = require('../exec');
} = require('../common/travis');
const {execOrDie, execWithError, exec} = require('../common/exec');
const {replaceUrls, signalDistUpload} = require('../tasks/pr-deploy-bot-utils');

const BUILD_OUTPUT_FILE = isTravisBuild()
Expand Down Expand Up @@ -370,7 +370,8 @@ function decryptTravisKey_() {
// openssl 1.0.2g, which is used by Travis to decrypt.
execOrDie(
`openssl aes-256-cbc -md sha256 -k ${process.env.GCP_TOKEN} -in ` +
`build-system/sa-travis-key.json.enc -out ${OUTPUT_STORAGE_KEY_FILE} -d`
`build-system/common/sa-travis-key.json.enc -out ` +
`${OUTPUT_STORAGE_KEY_FILE} -d`
);
}

Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/validator-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');
const {runYarnChecks} = require('./yarn-checks');

const FILENAME = 'validator-tests.js';
Expand Down
2 changes: 1 addition & 1 deletion build-system/pr-check/visual-diff-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const {
timedExecOrDie: timedExecOrDieBase,
} = require('./utils');
const {determineBuildTargets} = require('./build-targets');
const {isTravisPullRequestBuild} = require('../travis');
const {isTravisPullRequestBuild} = require('../common/travis');

const FILENAME = 'visual-diff-tests.js';
const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
Expand Down
4 changes: 2 additions & 2 deletions build-system/pr-check/yarn-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/

const colors = require('ansi-colors');
const {getStderr} = require('../exec');
const {gitDiffColor} = require('../git');
const {getStderr} = require('../common/exec');
const {gitDiffColor} = require('../common/git');

/**
* Makes sure package.json and yarn.lock are in sync.
Expand Down

0 comments on commit db49f43

Please sign in to comment.