Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 817ef8e

Browse files
committed
feat(@angular/schematics-cli): Implement the first version of the Schematics CLI
1 parent 9db8bf7 commit 817ef8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2030
-1
lines changed

bin/schematics

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
require('../lib/bootstrap-local');
4+
const packages = require('../lib/packages').packages;
5+
6+
require(packages['@angular/schematics-cli'].bin['schematics']);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.0.0",
44
"description": "Software Development Kit for Angular",
55
"bin": {
6-
"sdk-admin": "./bin/sdk-admin"
6+
"sdk-admin": "./bin/sdk-admin",
7+
"schematics": "./bin/schematics"
78
},
89
"keywords": [],
910
"scripts": {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require('../src/cli');

packages/schematics_cli/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@angular/schematics-cli",
3+
"version": "0.0.0",
4+
"description": "CLI tool for Angular",
5+
"main": "src/cli.js",
6+
"bin": {
7+
"schematics": "./bin/schematics.js"
8+
},
9+
"keywords": [
10+
"angular",
11+
"sdk",
12+
"blueprints",
13+
"code generation",
14+
"schematics",
15+
"cli",
16+
"Angular SDK"
17+
],
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/angular/sdk.git"
21+
},
22+
"engines": {
23+
"node": ">= 6.9.0",
24+
"npm": ">= 3.0.0"
25+
},
26+
"author": "Angular Authors",
27+
"license": "MIT",
28+
"bugs": {
29+
"url": "https://github.com/angular/sdk/issues"
30+
},
31+
"schematics": "./schematics/collection.json",
32+
"homepage": "https://github.com/angular/sdk",
33+
"dependencies": {
34+
"@angular/schematics": "0.0.0"
35+
}
36+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# <%= utils.classify(name) %>
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version <%= version %>.
4+
5+
## Development server
6+
7+
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.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
12+
13+
## Build
14+
15+
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.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24+
Before running the tests make sure you are serving the app via `ng serve`.
25+
26+
## Further help
27+
28+
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).
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
const routes: Routes = [
5+
{
6+
path: '',
7+
children: []
8+
}
9+
];
10+
11+
@NgModule({
12+
imports: [RouterModule.forRoot(routes)],
13+
exports: [RouterModule]
14+
})
15+
export class AppRoutingModule { }

packages/schematics_cli/schematics/angular-app/files/__path__/app/app.component.__styleext__

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<h1>
2+
{{title}}
3+
</h1><% if (routing) { %>
4+
<router-outlet></router-outlet><% } %>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { TestBed, async } from '@angular/core/testing';<% if (routing) { %>
2+
import { RouterTestingModule } from '@angular/router/testing';<% } %>
3+
4+
import { AppComponent } from './app.component';
5+
6+
describe('AppComponent', () => {
7+
beforeEach(async(() => {
8+
TestBed.configureTestingModule({<% if (routing) { %>
9+
imports: [
10+
RouterTestingModule
11+
],<% } %>
12+
declarations: [
13+
AppComponent
14+
],
15+
}).compileComponents();
16+
}));
17+
18+
it('should create the app', async(() => {
19+
const fixture = TestBed.createComponent(AppComponent);
20+
const app = fixture.debugElement.componentInstance;
21+
expect(app).toBeTruthy();
22+
}));
23+
24+
it(`should have as title '<%= prefix %> works!'`, async(() => {
25+
const fixture = TestBed.createComponent(AppComponent);
26+
const app = fixture.debugElement.componentInstance;
27+
expect(app.title).toEqual('<%= prefix %> works!');
28+
}));
29+
30+
it('should render title in a h1 tag', async(() => {
31+
const fixture = TestBed.createComponent(AppComponent);
32+
fixture.detectChanges();
33+
const compiled = fixture.debugElement.nativeElement;
34+
expect(compiled.querySelector('h1').textContent).toContain('<%= prefix %> works!');
35+
}));
36+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: '<%= prefix %>-root',<% if (inlineTemplate) { %>
5+
template: `
6+
<h1>
7+
{{title}}
8+
</h1><% if (routing) { %>
9+
<router-outlet></router-outlet><% } %>
10+
`,<% } else { %>
11+
templateUrl: './app.component.html',<% } %><% if (inlineStyle) { %>
12+
styles: []<% } else { %>
13+
styleUrls: ['./app.component.<%= styleext %>']<% } %>
14+
})
15+
export class AppComponent {
16+
title = '<%= prefix %> works!';
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { NgModule } from '@angular/core';
3+
import { FormsModule } from '@angular/forms';
4+
import { HttpModule } from '@angular/http';
5+
<% if (routing) { %>
6+
import { AppRoutingModule } from './app-routing.module';<% } %>
7+
import { AppComponent } from './app.component';
8+
9+
@NgModule({
10+
declarations: [
11+
AppComponent
12+
],
13+
imports: [
14+
BrowserModule,
15+
FormsModule,
16+
HttpModule<% if (routing) { %>,
17+
AppRoutingModule<% } %>
18+
],
19+
providers: [],
20+
bootstrap: [AppComponent]
21+
})
22+
export class AppModule { }

packages/schematics_cli/schematics/angular-app/files/__path__/assets/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true
3+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// The file contents for the current environment will overwrite these during build.
2+
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
3+
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
4+
// The list of which env maps to which file can be found in `.angular-cli.json`.
5+
6+
export const environment = {
7+
production: false
8+
};
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title><%= utils.classify(name) %></title>
6+
<base href="/">
7+
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
<link rel="icon" type="image/x-icon" href="favicon.ico">
10+
</head>
11+
<body>
12+
<<%= prefix %>-root>Loading...</<%= prefix %>-root>
13+
</body>
14+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { enableProdMode } from '@angular/core';
2+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3+
4+
import { AppModule } from './app/app.module';
5+
import { environment } from './environments/environment';
6+
7+
if (environment.production) {
8+
enableProdMode();
9+
}
10+
11+
platformBrowserDynamic().bootstrapModule(AppModule);
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* This file includes polyfills needed by Angular and is loaded before the app.
3+
* You can add your own extra polyfills to this file.
4+
*
5+
* This file is divided into 2 sections:
6+
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7+
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8+
* file.
9+
*
10+
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11+
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12+
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13+
*
14+
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15+
*/
16+
17+
/***************************************************************************************************
18+
* BROWSER POLYFILLS
19+
*/
20+
21+
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
22+
// import 'core-js/es6/symbol';
23+
// import 'core-js/es6/object';
24+
// import 'core-js/es6/function';
25+
// import 'core-js/es6/parse-int';
26+
// import 'core-js/es6/parse-float';
27+
// import 'core-js/es6/number';
28+
// import 'core-js/es6/math';
29+
// import 'core-js/es6/string';
30+
// import 'core-js/es6/date';
31+
// import 'core-js/es6/array';
32+
// import 'core-js/es6/regexp';
33+
// import 'core-js/es6/map';
34+
// import 'core-js/es6/set';
35+
36+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
37+
// import 'classlist.js'; // Run `npm install --save classlist.js`.
38+
39+
/** IE10 and IE11 requires the following to support `@angular/animation`. */
40+
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
41+
42+
43+
/** Evergreen browsers require these. **/
44+
import 'core-js/es6/reflect';
45+
import 'core-js/es7/reflect';
46+
47+
48+
/** ALL Firefox browsers require the following to support `@angular/animation`. **/
49+
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
50+
51+
52+
53+
/***************************************************************************************************
54+
* Zone JS is required by Angular itself.
55+
*/
56+
import 'zone.js/dist/zone'; // Included with Angular CLI.
57+
58+
59+
60+
/***************************************************************************************************
61+
* APPLICATION IMPORTS
62+
*/
63+
64+
/**
65+
* Date, currency, decimal and percent pipes.
66+
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
67+
*/
68+
// import 'intl'; // Run `npm install --save intl`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* You can add global styles to this file, and also import other style files */
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
2+
3+
import 'zone.js/dist/long-stack-trace-zone';
4+
import 'zone.js/dist/proxy.js';
5+
import 'zone.js/dist/sync-test';
6+
import 'zone.js/dist/jasmine-patch';
7+
import 'zone.js/dist/async-test';
8+
import 'zone.js/dist/fake-async-test';
9+
import { getTestBed } from '@angular/core/testing';
10+
import {
11+
BrowserDynamicTestingModule,
12+
platformBrowserDynamicTesting
13+
} from '@angular/platform-browser-dynamic/testing';
14+
15+
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16+
declare var __karma__: any;
17+
declare var require: any;
18+
19+
// Prevent Karma from running prematurely.
20+
__karma__.loaded = function () {};
21+
22+
// First, initialize the Angular testing environment.
23+
getTestBed().initTestEnvironment(
24+
BrowserDynamicTestingModule,
25+
platformBrowserDynamicTesting()
26+
);
27+
// Then we find all the tests.
28+
const context = require.context('./', true, /\.spec\.ts$/);
29+
// And load the modules.
30+
context.keys().map(context);
31+
// Finally, start Karma to run the tests.
32+
__karma__.start();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "<%= path.split('/').map(x => '..').join('/') %>/tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "<%= path.split('/').map(x => '..').join('/') %>/out-tsc/app",
5+
"module": "es2015",
6+
"baseUrl": "",
7+
"types": []
8+
},
9+
"exclude": [
10+
"test.ts",
11+
"**/*.spec.ts"
12+
]
13+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "<%= path.split('/').map(x => '..').join('/') %>/tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "<%= path.split('/').map(x => '..').join('/') %>/out-tsc/spec",
5+
"module": "commonjs",
6+
"target": "es5",
7+
"baseUrl": "",
8+
"types": [
9+
"jasmine",
10+
"node"
11+
]
12+
},
13+
"files": [
14+
"test.ts"
15+
],
16+
"include": [
17+
"**/*.spec.ts",
18+
"**/*.d.ts"
19+
]
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* SystemJS module definition */
2+
declare var module: NodeModule;
3+
interface NodeModule {
4+
id: string;
5+
}

0 commit comments

Comments
 (0)