feat: add workspace schematic
This commit is contained in:
parent
da8395c36f
commit
0d0ac9ea4f
18
e2e/workspace.test.ts
Normal file
18
e2e/workspace.test.ts
Normal file
@ -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`
|
||||
);
|
||||
});
|
||||
});
|
||||
40
src/schematics/workspace/files/BUILD.bazel__tmpl__
Normal file
40
src/schematics/workspace/files/BUILD.bazel__tmpl__
Normal file
@ -0,0 +1,40 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
exports_files(["tsconfig.json"])
|
||||
|
||||
load("@build_bazel_rules_angular//:defs.bzl", "ng_external_libraries")
|
||||
|
||||
filegroup(name = "node_modules", srcs = glob([
|
||||
# should not be whitelisted
|
||||
"node_modules/@angular/**",
|
||||
"node_modules/typescript/**",
|
||||
"node_modules/zone.js/**",
|
||||
"node_modules/rxjs/**/*.d.ts",
|
||||
"node_modules/rxjs/**/*.js",
|
||||
"node_modules/@types/**/*.d.ts",
|
||||
"node_modules/tsickle/**",
|
||||
"node_modules/hammerjs/**/*.d.ts",
|
||||
"node_modules/protobufjs/**",
|
||||
"node_modules/bytebuffer/**",
|
||||
"node_modules/reflect-metadata/**",
|
||||
"node_modules/minimist/**/*.js",
|
||||
"node_modules/webpack/**"
|
||||
], exclude=["node_modules/@angular/cli/**"]))
|
||||
|
||||
ng_external_libraries(name = "ng_libs", srcs = glob([
|
||||
"node_modules/@angular/**"
|
||||
], exclude = [
|
||||
"node_modules/@angular/cli/**",
|
||||
"node_modules/@angular/platform-browser/animations*",
|
||||
"node_modules/@angular/platform-browser/animations/**",
|
||||
|
||||
# Alex E?
|
||||
"node_modules/@angular/router*",
|
||||
"node_modules/@angular/router/**",
|
||||
]))
|
||||
|
||||
filegroup(
|
||||
name= "init",
|
||||
srcs = [
|
||||
":ng_libs"
|
||||
]
|
||||
)
|
||||
28
src/schematics/workspace/files/README.md__tmpl__
Executable file
28
src/schematics/workspace/files/README.md__tmpl__
Executable file
@ -0,0 +1,28 @@
|
||||
# <%= className %>
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version <%= version %>.
|
||||
|
||||
## Development server
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
||||
Before running the tests make sure you are serving the app via `ng serve`.
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
||||
36
src/schematics/workspace/files/WORKSPACE__tmpl__
Normal file
36
src/schematics/workspace/files/WORKSPACE__tmpl__
Normal file
@ -0,0 +1,36 @@
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
|
||||
git_repository(
|
||||
name = "build_bazel_rules_typescript",
|
||||
remote = "https://github.com/vsavkin/rules_typescript",
|
||||
commit = "9a6c806",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "build_bazel_rules_angular",
|
||||
remote = "https://github.com/alexeagle/rules_angular",
|
||||
commit = "ce85fe6",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "io_bazel_rules_sass",
|
||||
remote = "https://github.com/bazelbuild/rules_sass.git",
|
||||
tag = "0.0.2",
|
||||
)
|
||||
|
||||
git_repository(
|
||||
name = "build_bazel_rules_nodejs",
|
||||
remote = "https://github.com/alexeagle/rules_nodejs.git",
|
||||
commit = "4924d7b",
|
||||
)
|
||||
|
||||
local_repository(
|
||||
name = "build_bazel_rules_nrwl",
|
||||
path = "node_modules/@nrwl/nx/bazel",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories")
|
||||
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
|
||||
|
||||
node_repositories(package_json = "//:package.json")
|
||||
sass_repositories()
|
||||
@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"project": {
|
||||
"name": "<%= fileName %>"
|
||||
},
|
||||
"apps": [
|
||||
],
|
||||
"test": {
|
||||
"karma": {
|
||||
"config": "node_modules/@nrwl/nx/bazel/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"schematics": {
|
||||
"collection": "@nrwl/nx"
|
||||
},
|
||||
"component": {
|
||||
"spec": true,
|
||||
"inlineStyle": false,
|
||||
"inlineTemplate": false
|
||||
},
|
||||
"directive": {
|
||||
"spec": true
|
||||
},
|
||||
"class": {
|
||||
"spec": true
|
||||
},
|
||||
"guard": {
|
||||
"spec": true
|
||||
},
|
||||
"module": {
|
||||
"spec": true
|
||||
},
|
||||
"pipe": {
|
||||
"spec": true
|
||||
},
|
||||
"service": {
|
||||
"spec": true
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/schematics/workspace/files/__dot__bazelrc__tmpl__
Normal file
5
src/schematics/workspace/files/__dot__bazelrc__tmpl__
Normal file
@ -0,0 +1,5 @@
|
||||
build --strategy=AngularTemplateCompile=standalone
|
||||
build --strategy=TypeScriptCompile=worker
|
||||
build --spawn_strategy=standalone
|
||||
build --watchfs
|
||||
build --symlink_prefix=/
|
||||
13
src/schematics/workspace/files/__dot__editorconfig__tmpl__
Normal file
13
src/schematics/workspace/files/__dot__editorconfig__tmpl__
Normal file
@ -0,0 +1,13 @@
|
||||
# Editor configuration, see http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
42
src/schematics/workspace/files/__dot__gitignore__tmpl__
Executable file
42
src/schematics/workspace/files/__dot__gitignore__tmpl__
Executable file
@ -0,0 +1,42 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# e2e
|
||||
/e2e/*.js
|
||||
/e2e/*.map
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
53
src/schematics/workspace/files/package.json__tmpl__
Normal file
53
src/schematics/workspace/files/package.json__tmpl__
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "<%= fileName %>",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "4.3.0",
|
||||
"@angular/common": "4.3.0",
|
||||
"@angular/compiler": "4.3.0",
|
||||
"@angular/core": "4.3.0",
|
||||
"@angular/forms": "4.3.0",
|
||||
"@angular/http": "4.3.0",
|
||||
"@angular/platform-browser": "4.3.0",
|
||||
"@angular/platform-browser-dynamic": "4.3.0",
|
||||
"@angular/router": "4.3.0",
|
||||
"core-js": "^2.4.1",
|
||||
"rxjs": "^5.4.2",
|
||||
"zone.js": "^0.8.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/cli": "https://github.com/nrwl/bazel-cli-build",
|
||||
"@nrwl/nx": "https://github.com/nrwl/nx-build",
|
||||
"@angular/compiler-cli": "4.3.0",
|
||||
"@angular/language-service": "4.3.0",
|
||||
"@types/jasmine": "~2.5.53",
|
||||
"@types/jasminewd2": "~2.0.2",
|
||||
"@types/node": "~6.0.60",
|
||||
"codelyzer": "~3.1.1",
|
||||
"jasmine-core": "~2.6.2",
|
||||
"jasmine-spec-reporter": "~4.1.0",
|
||||
"karma": "~1.7.0",
|
||||
"karma-chrome-launcher": "~2.1.1",
|
||||
"karma-cli": "~1.0.1",
|
||||
"karma-coverage-istanbul-reporter": "^1.2.1",
|
||||
"karma-jasmine": "~1.1.0",
|
||||
"karma-jasmine-html-reporter": "^0.2.2",
|
||||
"protractor": "~5.1.2",
|
||||
"ts-node": "~3.2.0",
|
||||
"tslint": "~5.3.2",
|
||||
"typescript": "2.3.4",
|
||||
"protobufjs": "5.0.0",
|
||||
"karma-spec-reporter": "0.0.31",
|
||||
"karma-webpack": "2.0.4"
|
||||
}
|
||||
}
|
||||
28
src/schematics/workspace/files/protractor.conf.js__tmpl__
Normal file
28
src/schematics/workspace/files/protractor.conf.js__tmpl__
Normal file
@ -0,0 +1,28 @@
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter } = require('jasmine-spec-reporter');
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'./e2e/**/*.e2e-spec.ts'
|
||||
],
|
||||
capabilities: {
|
||||
'browserName': 'chrome'
|
||||
},
|
||||
directConnect: true,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {}
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: 'e2e/tsconfig.e2e.json'
|
||||
});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||
}
|
||||
};
|
||||
8
src/schematics/workspace/files/tsconfig.json__tmpl__
Normal file
8
src/schematics/workspace/files/tsconfig.json__tmpl__
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"experimentalDecorators": true,
|
||||
"baseUrl": "."
|
||||
}
|
||||
}
|
||||
18
src/schematics/workspace/index.ts
Normal file
18
src/schematics/workspace/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {apply, chain, mergeWith, move, Rule, schematic, template, url,} from '@angular-devkit/schematics';
|
||||
import {Schema} from './schema';
|
||||
import {names} from '../name-utils';
|
||||
|
||||
export default function (options: Schema): Rule {
|
||||
return chain([
|
||||
mergeWith(
|
||||
apply(url('./files'), [
|
||||
template({
|
||||
...options,
|
||||
...names(options.name),
|
||||
'dot': '.',
|
||||
'tmpl': ''
|
||||
}),
|
||||
move(options.name !)
|
||||
]))
|
||||
]);
|
||||
}
|
||||
4
src/schematics/workspace/schema.d.ts
vendored
Normal file
4
src/schematics/workspace/schema.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export interface Schema {
|
||||
name: string;
|
||||
version?: string;
|
||||
}
|
||||
18
src/schematics/workspace/schema.json
Normal file
18
src/schematics/workspace/schema.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/schema",
|
||||
"id": "SchematicsAngularBazelWorkspace",
|
||||
"title": "Angular Bazel Workspace Options Schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"version"
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user