From d251f22ebda9342dc610808b3a569d03e75ed77c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 22 Nov 2019 16:45:46 -0800 Subject: [PATCH] build: remove obsolete build related tools and helper scripts (#34058) none of these files are needed any more as they were replaced by Bazel. PR Close #34058 --- gulpfile.js | 1 - tools/build/benchpress.js | 11 -- tools/build/licensewrap.js | 20 --- tools/build/logging.js | 46 ------ tools/build/snippets/url_params_to_form.js | 28 ---- tools/build/watch.js | 124 -------------- tools/build/watch.spec.js | 179 --------------------- tools/cjs-jasmine/index-tools.ts | 55 ------- tools/cjs-jasmine/index.ts | 101 ------------ tools/cjs-jasmine/test-cjs-main.ts | 13 -- tools/gulp-tasks/serve.js | 26 --- 11 files changed, 604 deletions(-) delete mode 100644 tools/build/benchpress.js delete mode 100644 tools/build/licensewrap.js delete mode 100644 tools/build/logging.js delete mode 100644 tools/build/snippets/url_params_to_form.js delete mode 100644 tools/build/watch.js delete mode 100644 tools/build/watch.spec.js delete mode 100644 tools/cjs-jasmine/index-tools.ts delete mode 100644 tools/cjs-jasmine/index.ts delete mode 100644 tools/cjs-jasmine/test-cjs-main.ts delete mode 100644 tools/gulp-tasks/serve.js diff --git a/gulpfile.js b/gulpfile.js index fe6d689c78..754b59aa1b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -51,7 +51,6 @@ gulp.task('validate-commit-messages', loadTask('validate-commit-message')); gulp.task('source-map-test', loadTask('source-map-test')); gulp.task('tools:build', loadTask('tools-build')); gulp.task('check-cycle', loadTask('check-cycle')); -gulp.task('serve', loadTask('serve', 'default')); gulp.task('changelog', loadTask('changelog')); gulp.task('changelog:zonejs', loadTask('changelog-zonejs')); gulp.task('check-env', () => {/* this is a noop because the env test ran already above */}); diff --git a/tools/build/benchpress.js b/tools/build/benchpress.js deleted file mode 100644 index a4de6a40c5..0000000000 --- a/tools/build/benchpress.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -module.exports = function(gulp, plugins, config) { - return function(done) { del(config.path, done); }; -}; diff --git a/tools/build/licensewrap.js b/tools/build/licensewrap.js deleted file mode 100644 index 694635cbf2..0000000000 --- a/tools/build/licensewrap.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -var fs = require('fs'); -module.exports = function(licenseFile, outputFile) { - var licenseText = fs.readFileSync(licenseFile); - var license = '/**\n @license\n' + licenseText + '\n */\n'; - if (outputFile) { - outputFile = licenseFile + '.wrapped'; - fs.writeFileSync(outputFile, license, 'utf8'); - return outputFile; - } else { - return license; - } -}; diff --git a/tools/build/logging.js b/tools/build/logging.js deleted file mode 100644 index fb6e8f2f5c..0000000000 --- a/tools/build/logging.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -var kLogsArgument = /^--logs\s*=\s*(.+?)$/; -var kTrimLeft = /^\s+/; -var kTrimRight = /\s+$/; -var kCamelCase = /[-_\s]+(.)?/g; -var logs = findArgvLogs(); - -function findArgvLogs() { - for (var i = 0; i < process.argv.length; ++i) { - var match = process.argv[i].match(kLogsArgument); - if (match) { - return logsToObject(match[1]); - } - } - return null; -} - -function logsToObject(logstr) { - return logstr.split(',').reduce(function(obj, key) { - key = camelize(key); - if (key.length > 0) obj[key] = true; - return obj; - }, Object.create(null)); - return logs; -} - -function camelize(str) { - return str.replace(kTrimLeft, '').replace(kTrimRight, '').replace(kCamelCase, function(match, c) { - return c ? c.toUpperCase() : ''; - }); -} - -function shouldLog(str) { - if (!logs || logs.quiet) return false; - if (logs.all) return true; - return !!logs[camelize(str)]; -} - -module.exports = shouldLog; diff --git a/tools/build/snippets/url_params_to_form.js b/tools/build/snippets/url_params_to_form.js deleted file mode 100644 index a9dd0c29ac..0000000000 --- a/tools/build/snippets/url_params_to_form.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -// helper script that will read out the url parameters -// and store them in appropriate form fields on the page -(function() { - var regex = /(\w+)=(\w+)/g; - var search = decodeURIComponent(location.search); - while (match = regex.exec(search)) { - var name = match[1]; - var value = match[2]; - var els = document.querySelectorAll('input[name="' + name + '"]'); - var el; - for (var i = 0; i < els.length; i++) { - el = els[i]; - if (el.type === 'radio' || el.type === 'checkbox') { - el.checked = el.value === value; - } else { - el.value = value; - } - } - } -})(); \ No newline at end of file diff --git a/tools/build/watch.js b/tools/build/watch.js deleted file mode 100644 index 39413efa5e..0000000000 --- a/tools/build/watch.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -var chokidar = require('chokidar'); -var runSequence = require('run-sequence'); -var path = require('path'); - -function watch(globs, opts, tasks) { - if (typeof opts !== 'object' || Array.isArray(opts)) { - tasks = opts; - opts = {}; - } - - var triggerCount = 0; - var useRunSequence = typeof tasks !== 'function'; - var runTasks; - - if (useRunSequence) { - if (!Array.isArray(tasks)) tasks = [tasks]; - tasks = tasks.slice(); - tasks.push(tasksDone); - runTasks = function runTaskSequence() { runSequence.apply(null, tasks); }; - } else { - var sync = tasks.length === 0; - runTasks = function runCallback() { - try { - tasks(tasksDone); - if (sync) tasksDone(); - } catch (e) { - return tasksDone(e); - } - }; - } - - var events = opts.events = opts.events || ['add', 'change', 'unlink']; - - // Don't let chokidar call us while initializing because on large trees it might take too long for - // all the add events to be emitted which causes the initial callback to be triggered more than - // once. Instead, we call handleEvent directly. - var ignoreInitial = opts.ignoreInitial; - opts.ignoreInitial = true; - - var delay = opts.delay; - if (delay === undefined) delay = 100; - - var watcher = - chokidar.watch(globs, opts).on('all', handleEvent).on('error', function(err) { throw err; }); - - var log = function watchLogger(triggerCount) { - // Don't report change for initial event - if (!ignoreInitial && !--triggerCount) return; - - process.stdout.write([ - '', - '==================================================', - ' WATCH TRIGGERED BY FILE CHANGE #' + triggerCount, - ' On: ' + prettyTime(), - '==================================================\n', - ].join('\n')); - - function prettyTime() { - var now = new Date(); - return now.toLocaleDateString() + ' at ' + now.toLocaleTimeString(); - } - }; - - if (opts.log !== undefined && !opts.log) { - log = function noopLog(triggerCount) {}; - } - - var close = watcher.close.bind(watcher); - watcher.close = function() { - if (timeoutId !== null) clearTimeout(timeoutId); - close(); - }; - - var eventsRecorded = 0; // Number of events recorded - var timeoutId = null; // If non-null, event capture window is open - - if (!ignoreInitial) { - // synthetic event to kick off the first task run - timeoutId = setTimeout(invokeCallback, delay); - } - - return watcher; - - function handleEvent(event, filepath) { - // Ignore unwatched events - if (events.indexOf(event) < 0) return; - - // Increment number of events captured in this window - ++eventsRecorded; - - if (timeoutId === null) { - timeoutId = setTimeout(invokeCallback, delay); - } - } - - function invokeCallback() { - eventsRecorded = 0; - log(++triggerCount); - runTasks(); - } - - function tasksDone(err) { - if (eventsRecorded) { - // eventsRecorded has increased during the run, run again on the next turn - timeoutId = setTimeout(invokeCallback, 0); - } else { - timeoutId = null; - } - if (!useRunSequence && err) { - // tslint:disable-next-line:no-console - console.log('Watch task error:', err.toString()); - } - } -} - -module.exports = watch; diff --git a/tools/build/watch.spec.js b/tools/build/watch.spec.js deleted file mode 100644 index c64ea80091..0000000000 --- a/tools/build/watch.spec.js +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -var rewire = require('rewire'); - -describe('watch()', function() { - var timeout; - var watch; - var watcher; - var unmock; - - beforeEach(function() { - timeout = mockTimeout(); - var watchModule = rewire('./watch'); - unmock = watchModule.__set__(timeout.mocks); - watch = watchModule.__get__('watch'); - }); - - afterEach(function() { - // Shouldn't really be necessary, but... - if (watcher) { - watcher.close(); - watcher = null; - } - unmock(); - expect(timeout.pending).toBe(0); - timeout = null; - }); - - - it('should fire callback once for events which occur within `delay` window', function() { - var cb = jasmine.createSpy('callback'); - watcher = watch('./$$fake_path/**/*', {delay: 10, log: false}, cb); - - watcher._emit('add', './$$fake_path/test.txt'); - timeout.flush(9); - expect(cb).not.toHaveBeenCalled(); - - watcher._emit('change', './$$fake_path/test.txt'); - watcher._emit('add', './$$fake_path/test2.txt'); - watcher._emit('change', './$$fake_path/test2.txt'); - watcher._emit('add', './$$fake_path/test3.txt'); - watcher._emit('change', './$$fake_path/test3.txt'); - expect(cb).not.toHaveBeenCalled(); - - timeout.flush(1); - expect(cb.calls.count()).toBe(1); - }); - - - it('should trigger callback if events are collected during task running', function() { - var calls = 0; - function cb(done) { - if (++calls !== 1) return done(); - - watcher._emit('change', './$$fake_path/test1.txt'); - watcher._emit('change', './$$fake_path/test2.txt'); - - // Before the done callback, there are no pending timer events - expect(timeout.pending).toBe(0); - done(); - - // Afterwards, there is one - expect(timeout.pending).toBe(1); - } - - var watcher = watch('./$$fake_path/**/*', {delay: 10, log: false}, cb); - - watcher._emit('change', './$$fake_path/test1.txt'); - expect(timeout.pending).toBe(1); - expect(calls).toBe(0); - - timeout.flush(10); - expect(calls).toBe(2); - }); - - - it('should continue to trigger callbacks if task throws', function() { - var calls = 0; - spyOn(console, 'log'); - function cb(done) { - calls += 1; - if (calls === 1) throw new Error('oops!'); - done(); - } - - var watcher = watch('./$$fake_path/**/*', {delay: 10, log: false}, cb); - - watcher._emit('change', './$$fake_path/test1.txt'); - timeout.flush(); - expect(calls).toBe(1); - expect(console.log).toHaveBeenCalledWith('Watch task error:', 'Error: oops!'); - - watcher._emit('change', './$$fake_path/test2.txt'); - timeout.flush(); - expect(calls).toBe(2); - }); - - - it('should cancel pending callback if FSWatcher is closed', function() { - var cb = jasmine.createSpy('callback'); - var watcher = watch('./$$fake_path/**/*', {delay: 10, log: false}, cb); - - watcher._emit('change', './$$fake_path/test1.txt'); - expect(timeout.pending).toBe(1); - expect(cb).not.toHaveBeenCalled(); - - watcher.close(); - expect(timeout.pending).toBe(0); - }); - - - it('should cancel followup pending callback if FSWatcher is closed during task', function() { - var calls = 0; - function cb(done) { - if (++calls !== 1) return done(); - - watcher._emit('change', './$$fake_path/test2.txt'); - done(); - expect(timeout.pending).toBe(1); - watcher.close(); - expect(timeout.pending).toBe(0); - } - - var watcher = watch('./$$fake_path/**/*', {delay: 10, log: false}, cb); - watcher._emit('change', './$$fake_path/test1.txt'); - - timeout.flush(10); - - expect(calls).toBe(1); - }); -}); - - -// setTimeout/clearTimeout mocking, mostly stolen from angular-mocks.js -function mockTimeout() { - var events = []; - var id = 0; - var now = 0; - - return { - mocks: {setTimeout: mockSetTimeout, clearTimeout: mockClearTimeout}, - flush: flush, get pending() { return events.length; } - }; - - function mockSetTimeout(fn, delay) { - delay = delay || 0; - events.push({time: now + delay, fn: fn, id: id}); - events.sort(function(a, b) { return a.time - b.time; }); - return id++; - } - - function mockClearTimeout(id) { - for (var i = 0; i < events.length; ++i) { - if (events[i].id === id) { - events.splice(i, 1); - break; - } - } - } - - function flush(delay) { - if (delay !== undefined) - now += delay; - else if (events.length) - now = events[events.length - 1].time; - else - throw new Error('No timer events registered'); - - while (events.length && events[0].time <= now) { - events.shift().fn(); - } - } -} diff --git a/tools/cjs-jasmine/index-tools.ts b/tools/cjs-jasmine/index-tools.ts deleted file mode 100644 index 6fbbd70ccd..0000000000 --- a/tools/cjs-jasmine/index-tools.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -'use strict'; - -const glob = require('glob'); -import 'zone.js/lib/node/rollup-main'; -const JasmineRunner = require('jasmine'); -const path = require('path'); -import 'zone.js/lib/zone-spec/long-stack-trace'; -import 'zone.js/lib/zone-spec/task-tracing'; -import 'zone.js/lib/zone-spec/proxy'; -import 'zone.js/lib/zone-spec/sync-test'; -import 'zone.js/lib/zone-spec/async-test'; -import 'zone.js/lib/zone-spec/fake-async-test'; -const {generateSeed} = require('../../../tools/jasmine-seed-generator'); - -// Let TypeScript know this is a module -export {}; - -const jrunner = new JasmineRunner({projectBaseDir: path.resolve(__dirname, '../../')}); -(global as any)['jasmine'] = jrunner.jasmine; -import 'zone.js/lib/jasmine/jasmine'; - -// Turn on full stack traces in errors to help debugging -(Error)['stackTraceLimit'] = Infinity; - -// Config the test runner -jrunner.jasmine.DEFAULT_TIMEOUT_INTERVAL = 100; -jrunner.loadConfig({ - random: true, - spec_dir: '', -}); -jrunner.seed(generateSeed('cjs-jasmine/index-tools')); -jrunner.configureDefaultReporter({showColors: process.argv.indexOf('--no-color') === -1}); -jrunner.onComplete((passed: boolean) => process.exit(passed ? 0 : 1)); - -// Support passing multiple globs -const rootDir = process.cwd(); -const globsIndex = process.argv.indexOf('--'); -const globs = (globsIndex === -1) ? [process.argv[2]] : process.argv.slice(globsIndex + 1); -const specFiles = globs.map(globstr => glob.sync(globstr, {cwd: rootDir}) as string[]) - .reduce((allPaths, paths) => allPaths.concat(paths), []); - -// Load helpers and spec files -const rootDirRequire = (relativePath: string) => require(path.join(rootDir, relativePath)); -specFiles.forEach(rootDirRequire); - -// Run the tests -jrunner.execute(); diff --git a/tools/cjs-jasmine/index.ts b/tools/cjs-jasmine/index.ts deleted file mode 100644 index 9ba6d5c63d..0000000000 --- a/tools/cjs-jasmine/index.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -'use strict'; - -const glob = require('glob'); -require('zone.js/lib/node/rollup-main.js'); -const JasmineRunner = require('jasmine'); -const path = require('path'); -require('source-map-support').install(); -require('zone.js/lib/zone-spec/long-stack-trace.js'); -require('zone.js/lib/zone-spec/task-tracking.js'); -require('zone.js/lib/zone-spec/proxy.js'); -require('zone.js/lib/zone-spec/sync-test.js'); -require('zone.js/lib/zone-spec/async-test.js'); -require('zone.js/lib/zone-spec/fake-async-test.js'); -require('reflect-metadata/Reflect'); -const {generateSeed} = require('../../../tools/jasmine-seed-generator'); - -// Let TypeScript know this is a module -export {}; - -const jrunner = new JasmineRunner({projectBaseDir: path.resolve(__dirname, '../../')}); -(global as any)['jasmine'] = jrunner.jasmine; -require('zone.js/lib/jasmine/jasmine.js'); - -(global as any).isBrowser = false; -(global as any).isNode = true; - -// Turn on full stack traces in errors to help debugging -(Error)['stackTraceLimit'] = Infinity; - -// Config the test runner -jrunner.jasmine.DEFAULT_TIMEOUT_INTERVAL = 100; -jrunner.loadConfig({ - random: true, - spec_dir: '', -}); -jrunner.seed(generateSeed('cjs-jasmine/index')); -jrunner.configureDefaultReporter({showColors: process.argv.indexOf('--no-color') === -1}); -jrunner.onComplete((passed: boolean) => process.exit(passed ? 0 : 1)); - -// Support passing multiple globs -const distAll = process.cwd() + '/dist/all'; -const globsIndex = process.argv.indexOf('--'); -const globs = (globsIndex === -1) ? [process.argv[2]] : process.argv.slice(globsIndex + 1); -const specFiles = - globs - .map(globstr => glob.sync(globstr, { - cwd: distAll, - ignore: [ - // the following code and tests are not compatible with CJS/node environment - '@angular/_testing_init/**', - '@angular/compiler/test/aot/**', - '@angular/compiler/test/render3/**', - '@angular/compiler-cli/test/compliance/**', - '@angular/core/test/bundling/**', - '@angular/core/test/fake_async_spec.*', - '@angular/core/test/render3/**', - '@angular/core/test/zone/**', - '@angular/elements/**', - '@angular/examples/**', - '@angular/forms/test/**', - '@angular/integration_test/symbol_inspector/**', - '@angular/platform-browser/**', - '@angular/platform-browser-dynamic/**', - '@angular/router/test/integration/bootstrap_spec.*', - '@angular/router/test/route_config/route_config_spec.*', - '@angular/upgrade/**', - '@angular/**/e2e_test/**', - 'angular1_router/**', - 'payload_tests/**', - ], - }) as string[]) - // Run relevant subset of browser tests for features reused on the server side. - // Make sure the security spec works on the server side! - .concat(glob.sync('@angular/platform-browser/test/security/**/*_spec.js', {cwd: distAll})) - .concat(['/@angular/platform-browser/test/browser/meta_spec.js']) - .concat(['/@angular/platform-browser/test/browser/title_spec.js']) - .concat(['/@angular/platform-browser/test/browser/transfer_state_spec.js']) - .reduce((allPaths, paths) => allPaths.concat(paths), []); - -// Load helpers and spec files -const distAllRequire = (relativePath: string) => { - const mod = require(path.join(distAll, relativePath)); - if (mod.main) { - mod.main(); - } - return mod; -}; -require('./test-cjs-main'); -distAllRequire('@angular/platform-server/src/domino_adapter').DominoAdapter.makeCurrent(); -specFiles.forEach(distAllRequire); - -// Run the tests -jrunner.execute(); diff --git a/tools/cjs-jasmine/test-cjs-main.ts b/tools/cjs-jasmine/test-cjs-main.ts deleted file mode 100644 index 7720713d8f..0000000000 --- a/tools/cjs-jasmine/test-cjs-main.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -const testingPlatformServer = require('../../all/@angular/platform-server/testing/src/server.js'); -const coreTesting = require('../../all/@angular/core/testing'); - -coreTesting.TestBed.initTestEnvironment( - testingPlatformServer.ServerTestingModule, testingPlatformServer.platformServerTesting()); diff --git a/tools/gulp-tasks/serve.js b/tools/gulp-tasks/serve.js deleted file mode 100644 index d3f476cbd2..0000000000 --- a/tools/gulp-tasks/serve.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 - */ - -module.exports = { - - // Serve the built files - default: (gulp) => () => { - const connect = require('gulp-connect'); - const cors = require('cors'); - const path = require('path'); - - connect.server({ - root: path.resolve(__dirname, '../../dist'), - port: 8000, - livereload: false, - open: false, - middleware: (connect, opt) => [cors()], - }); - }, - -};