-
Notifications
You must be signed in to change notification settings - Fork 2.7k
add bazel schematics #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7a7da27
update scripts to package and release the package
vsavkin 95c6855
move schematics into a peer dependency
vsavkin 3b31d90
update README
vsavkin 40626bb
cleanup: remove unused file
vsavkin 86d861a
refactor: update addNgRxToModule schematic to use utilities provided …
vsavkin 5ee42f5
cleanup: clean up ast utils
vsavkin acd1e75
feat: add workspace schematic
vsavkin 9d0b61b
feat: add app schematic
vsavkin b3b3691
feat: register the new schematics in collection.json
vsavkin 66d1441
feat: add bazel build utils
vsavkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { | ||
| addNgRx, checkFilesExists, cleanup, newApp, readFile, runCLI, runCommand, runSchematic, | ||
| updateFile | ||
| } from './utils'; | ||
|
|
||
| describe('application', () => { | ||
| beforeEach(cleanup); | ||
|
|
||
| it('creates a new application in a workspace', () => { | ||
| runSchematic('@nrwl/nx:application --name=proj'); | ||
| runSchematic('@nrwl/nx:app --name=myapp', {projectName: 'proj'}); | ||
|
|
||
| checkFilesExists( | ||
| `proj/tsconfig.json`, | ||
| `proj/WORKSPACE`, | ||
| `proj/BUILD.bazel`, | ||
| `proj/apps/myapp/BUILD.bazel`, | ||
| `proj/apps/myapp/src/index.html`, | ||
| `proj/apps/myapp/src/app/app.module.ts`, | ||
| `proj/apps/myapp/src/app/app.component.ts` | ||
| ); | ||
|
|
||
| expect(readFile('proj/apps/myapp/src/app/app.module.ts')).toContain('bootstrap: [AppComponent]'); | ||
|
|
||
| const cliConfig = JSON.parse(readFile('proj/.angular-cli.json')); | ||
| expect(cliConfig.apps.length).toEqual(1); | ||
| }); | ||
|
|
||
| it('creates multiple applications in a workspace', () => { | ||
| runSchematic('@nrwl/nx:application --name=proj2'); | ||
| runSchematic('@nrwl/nx:app --name=first', {projectName: 'proj2'}); | ||
| runSchematic('@nrwl/nx:app --name=second', {projectName: 'proj2'}); | ||
|
|
||
| const cliConfig = JSON.parse(readFile('proj2/.angular-cli.json')); | ||
| expect(cliConfig.apps[0].name).toEqual('first'); | ||
| expect(cliConfig.apps[0].root).toEqual('apps/first/src'); | ||
| expect(cliConfig.apps[1].name).toEqual('second'); | ||
| expect(cliConfig.apps[1].root).toEqual('apps/second/src'); | ||
| }); | ||
| }); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { | ||
| addNgRx, checkFilesExists, cleanup, newApp, readFile, runCLI, runCommand, runSchematic, | ||
| updateFile | ||
| } from './utils'; | ||
|
|
||
| describe('workspace', () => { | ||
| beforeEach(cleanup); | ||
|
|
||
| it('creates a new workspace for developing angular applications', () => { | ||
| runSchematic('@nrwl/nx:application --name=proj --version=0.1'); | ||
|
|
||
| checkFilesExists( | ||
| `proj/tsconfig.json`, | ||
| `proj/WORKSPACE`, | ||
| `proj/BUILD.bazel` | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ./scripts/build.sh | ||
| cp package.json build/src/package.json | ||
| cp README.md build/src/README.md | ||
| cp LICENSE build/src/LICENSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| load("@build_bazel_rules_typescript//:defs.bzl", "nodejs_binary") | ||
| exports_files(["webpack.config.js", "test.js"]) | ||
|
|
||
| nodejs_binary( | ||
| name = "webpack", | ||
| entry_point = "webpack/bin/webpack", | ||
| visibility = ["//visibility:public"], | ||
| ) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /** | ||
| * Warning: the testing rule will change. | ||
| * | ||
| * Instead of running karma outside of bazel against the bin_dir directory, we will run it as part of the bazel process. | ||
| */ | ||
| module.exports = function(config) { | ||
| const webpackConfig = { | ||
| resolveLoader: { | ||
| alias: { | ||
| "template-loader": '@nrwl/nx/bazel/template-loader' | ||
| } | ||
| }, | ||
| module: { | ||
| rules: [ | ||
| { | ||
| test: /\.component\.js$/, | ||
| use: [ | ||
| {loader: 'template-loader' } | ||
| ] | ||
| }, | ||
| { | ||
| test: /\.html$/, | ||
| use: [ | ||
| {loader: 'raw-loader' } | ||
| ] | ||
| }, | ||
| { | ||
| test: /\.css$/, | ||
| use: [ | ||
| {loader: 'raw-loader' } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| }; | ||
|
|
||
| config.set({ | ||
| // base path that will be used to resolve all patterns (eg. files, exclude) | ||
| basePath: `${config.opts.bin_dir}/${config.opts.app}`, | ||
|
|
||
| // frameworks to use | ||
| // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
| frameworks: ['jasmine'], | ||
|
|
||
| // list of files / patterns to load in the browser | ||
| files: [ | ||
| { pattern: 'test.js', watched: false} | ||
| ], | ||
|
|
||
| // list of files to exclude | ||
| exclude: [], | ||
|
|
||
| // preprocess matching files before serving them to the browser | ||
| // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
| preprocessors: { | ||
| 'test.js': ['webpack'] | ||
| }, | ||
|
|
||
| // test results reporter to use | ||
| // possible values: 'dots', 'progress' | ||
| // available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
| reporters: config.opts.reporters ? config.opts.reporters : (config.opts.progress ? ['progress'] : ['dots']), | ||
|
|
||
| webpack: webpackConfig, | ||
|
|
||
| webpackMiddleware: { | ||
| stats: 'errors-only' | ||
| }, | ||
|
|
||
| plugins: [ | ||
| require('karma-jasmine'), | ||
| require('karma-chrome-launcher'), | ||
| require('karma-jasmine-html-reporter'), | ||
| require('karma-coverage-istanbul-reporter'), | ||
| require('karma-webpack') | ||
| ], | ||
|
|
||
| coverageIstanbulReporter: { | ||
| reports: [ 'html', 'lcovonly' ], | ||
| fixWebpackSourcePaths: true | ||
| }, | ||
|
|
||
| client: { | ||
| clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
| }, | ||
|
|
||
| // web server port | ||
| port: config.opts.port ? config.opts.port : 9876, | ||
|
|
||
| // enable / disable colors in the output (reporters and logs) | ||
| colors: config.opts.colors, | ||
|
|
||
| // level of logging | ||
| // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
| logLevel: config.opts.log ? config.opts.log: config.LOG_INFO, | ||
|
|
||
| // enable / disable watching file and executing tests whenever any file changes | ||
| autoWatch: true, | ||
|
|
||
| // start these browsers | ||
| // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
| // browsers: ['PhantomJS'], | ||
| browsers: ['Chrome'], | ||
|
|
||
| // Concurrency level | ||
| // how many browser should be started simultaneous | ||
| concurrency: Infinity | ||
| }); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*([,}]))/gm; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file only used with karma, right? seems like there should be a karma subdirectory |
||
| var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g; | ||
| var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g; | ||
|
|
||
| function replaceStringsWithRequires(string) { | ||
| return string.replace(stringRegex, function (match, quote, url) { | ||
| if (url.charAt(0) !== ".") { | ||
| url = "./" + url; | ||
| } | ||
| return "require('" + url + "')"; | ||
| }); | ||
| } | ||
|
|
||
| module.exports = function(source, sourcemap) { | ||
| // Not cacheable during unit tests; | ||
| this.cacheable && this.cacheable(); | ||
|
|
||
| var newSource = source.replace(templateUrlRegex, function (match, url) { | ||
| return "template:" + replaceStringsWithRequires(url); | ||
| }).replace(stylesRegex, function (match, urls) { | ||
| return "styles:" + replaceStringsWithRequires(urls); | ||
| }); | ||
|
|
||
| // Support for tests | ||
| if (this.callback) { | ||
| this.callback(null, newSource, sourcemap) | ||
| } else { | ||
| return newSource; | ||
| } | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a warning comment about how the testing rule will change? (ppl might come browse this repo to find out what we are planning)