Skip to content

Commit 2365bb8

Browse files
josephperrottAndrewKushnir
authored andcommitted
build: migrate from gulp to ng-dev for running formatting (angular#36726)
Migrates away from gulp to ng-dev for running our formatter. Additionally, provides a deprecation warning for any attempted usage of the previous `gulp format:*` tasks. PR Close angular#36726
1 parent 7b5a0ba commit 2365bb8

File tree

7 files changed

+48
-474
lines changed

7 files changed

+48
-474
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ jobs:
278278
- run: 'yarn bazel:lint ||
279279
(echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)'
280280

281-
- run: yarn -s lint --branch $CI_GIT_BASE_REVISION
281+
- run: yarn -s tslint
282+
- run: yarn -s ng-dev format changed $CI_GIT_BASE_REVISION --check
282283
- run: yarn -s ts-circular-deps:check
283284
- run: yarn -s ng-dev pullapprove verify
284285
- run: yarn -s ng-dev commit-message validate-range --range $CI_COMMIT_RANGE

.dev-infra.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"!packages/common/src/i18n/currencies.ts",
5555
"!packages/common/src/i18n/locale_en.ts",
5656
"modules/benchmarks/**/*.{js,ts}",
57-
"modules/e2e_util/**/*.{js,ts}",
5857
"modules/playground/**/*.{js,ts}",
5958
"tools/**/*.{js,ts}",
6059
"!tools/gulp-tasks/cldr/extract.js",

gulpfile.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,36 @@ function loadTask(fileName, taskName) {
2626
return task(gulp);
2727
}
2828

29-
//#######################################################
30-
// A format and enforce task for different sets of files.
31-
//#######################################################
3229

33-
// All source files.
34-
gulp.task('format:all', loadTask('format', 'format'));
35-
gulp.task('format:all:enforce', loadTask('format', 'enforce'));
36-
37-
// Untracked source code files.
38-
gulp.task('format:untracked', loadTask('format', 'format-untracked'));
39-
gulp.task('format:untracked:enforce', loadTask('format', 'enforce-untracked'));
40-
41-
// Changed, tracked source code files.
42-
gulp.task('format:diff', loadTask('format', 'format-diff'));
43-
gulp.task('format:diff:enforce', loadTask('format', 'enforce-diff'));
44-
45-
// Changed, both tracked and untracked, source code files.
46-
gulp.task('format:changed', ['format:untracked', 'format:diff']);
47-
gulp.task('format:changed:enforce', ['format:untracked:enforce', 'format:diff:enforce']);
48-
49-
// Alias for `format:changed` that formerly formatted all files.
50-
gulp.task('format', ['format:changed']);
51-
52-
gulp.task('lint', ['format:changed:enforce']);
5330
gulp.task('source-map-test', loadTask('source-map-test'));
5431
gulp.task('changelog', loadTask('changelog'));
5532
gulp.task('changelog:zonejs', loadTask('changelog-zonejs'));
5633
gulp.task('check-env', () => {/* this is a noop because the env test ran already above */});
5734
gulp.task('cldr:extract', loadTask('cldr', 'extract'));
5835
gulp.task('cldr:gen-closure-locale', loadTask('cldr', 'closure'));
36+
37+
38+
// TODO(josephperrott): Remove old task entries and deprecation notice after deprecation period.
39+
/** Notify regarding `gulp format:*` deprecation. */
40+
function gulpFormatDeprecationNotice() {
41+
console.info(`######################################################################`)
42+
console.info(`gulp format is deprecated in favor of running the formatter via ng-dev`);
43+
console.info();
44+
console.info(`You can find more usage information by running:`);
45+
console.info(` yarn ng-dev format --help`);
46+
console.info();
47+
console.info(`For more on the rationale and effects of this deprecation visit:`);
48+
console.info(` https://github.com/angular/angular/pull/36726#issue-406278018`);
49+
console.info(`######################################################################`)
50+
process.exit(1);
51+
}
52+
gulp.task('format:all', gulpFormatDeprecationNotice);
53+
gulp.task('format:all:enforce', gulpFormatDeprecationNotice);
54+
gulp.task('format:untracked', gulpFormatDeprecationNotice);
55+
gulp.task('format:untracked:enforce', gulpFormatDeprecationNotice);
56+
gulp.task('format:diff', gulpFormatDeprecationNotice);
57+
gulp.task('format:diff:enforce', gulpFormatDeprecationNotice);
58+
gulp.task('format:changed', gulpFormatDeprecationNotice);
59+
gulp.task('format:changed:enforce', gulpFormatDeprecationNotice);
60+
gulp.task('format', gulpFormatDeprecationNotice);
61+
gulp.task('lint', gulpFormatDeprecationNotice);

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"//circleci-win-comment": "See the test-win circleci job for why these are needed. If they are not needed anymore, remove them.",
3030
"circleci-win-ve": "bazelisk test --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-browser:chromium-local //packages/compiler-cli/... //tools/ts-api-guardian/...",
3131
"circleci-win-ivy": "bazelisk test --config=ivy --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local //packages/compiler-cli/... //tools/ts-api-guardian/...",
32-
"lint": "yarn -s tslint && yarn gulp lint",
32+
"lint": "yarn -s tslint && yarn -s ng-dev format changed --check",
3333
"tslint": "tsc -p tools/tsconfig.json && tslint -c tslint.json \"+(packages|modules|scripts|tools)/**/*.+(js|ts)\"",
3434
"public-api:check": "node goldens/public-api/manage.js test",
3535
"public-api:update": "node goldens/public-api/manage.js accept",
@@ -167,11 +167,7 @@
167167
"firefox-profile": "1.0.3",
168168
"glob": "7.1.2",
169169
"gulp": "3.9.1",
170-
"gulp-clang-format": "^1.0.27",
171170
"gulp-conventional-changelog": "^2.0.3",
172-
"gulp-filter": "^5.1.0",
173-
"gulp-git": "^2.7.0",
174-
"gulp-tslint": "8.1.2",
175171
"husky": "^4.2.3",
176172
"inquirer": "^7.1.0",
177173
"jpm": "1.3.1",

tools/gulp-tasks/README.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,6 @@ module.exports = (gulp) => (done) => {
1515
};
1616
```
1717

18-
E.g. The `format.js` file contains two tasks:
19-
20-
```js
21-
module.exports = {
22-
// Check source code for formatting errors (clang-format)
23-
enforce: (gulp) => () => {
24-
...
25-
},
26-
27-
// Format the source code with clang-format (see .clang-format)
28-
format: (gulp) => () => {
29-
...
30-
}
31-
};
32-
33-
```
34-
3518
## Loading Tasks
3619

3720
The tasks are loaded in the gulp file, by requiring them. There is a helper called `loadTask(fileName, taskName)`
@@ -42,15 +25,3 @@ E.g. Loading the task that will run the build, from a task file that contains on
4225
```js
4326
gulp.task('build.sh', loadTask('build'));
4427
```
45-
46-
E.g. Loading the task that will enforce formatting, from a task file that contains more than one task:
47-
48-
```js
49-
gulp.task('format:enforce', loadTask('format', 'enforce'));
50-
```
51-
52-
E.g. Loading a task that has dependencies:
53-
54-
```js
55-
gulp.task('lint', ['format:enforce'], loadTask('lint'));
56-
```

tools/gulp-tasks/format.js

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)