Skip to content

Commit 5e5161c

Browse files
sebawitasis0k0
authored andcommitted
feat: add migration schematic from {N} to web+{N} shared project (#3)
1 parent 269ebfd commit 5e5161c

24 files changed

+1063
-4
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ src/**/*.js.map
66
.idea/
77
jsconfig.json
88
.vscode/
9+
.history
910

1011
# Misc
1112
node_modules/

Diff for: package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"build": "tsc -p tsconfig.json",
77
"watch": "tsc -w -p tsconfig.json",
88
"test": "npm run build && jasmine **/*_spec.js",
9-
"prepare": "npm run build"
9+
"prepare": "npm run build",
10+
"debug": "node --debug-brk ./node_modules/@angular/cli/bin/ng g command"
1011
},
1112
"schematics": "./src/collection.json",
1213
"dependencies": {
1314
"typescript": "~2.6.2",
14-
"@angular-devkit/core": "^0.2.0",
15-
"@angular-devkit/schematics": "^0.2.0",
16-
"@schematics/angular": "^0.2.0",
15+
"@angular-devkit/core": "~0.4.6",
16+
"@angular-devkit/schematics": "~0.4.6",
17+
"@schematics/angular": "~0.4.6",
1718
"rxjs": "^5.5.6"
1819
},
1920
"devDependencies": {

Diff for: src/collection.json

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
"schema": "./ng-cli-config/schema.json"
4141
},
4242

43+
"migrate-ns": {
44+
"factory": "./migrate-ns",
45+
"description": "Migrates {N} to a code sharing project structure",
46+
"schema": "./migrate-ns/schema.json"
47+
},
48+
4349
"class": {
4450
"aliases": [ "cl" ],
4551
"extends": "@schematics/angular:class"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--The content below is only a placeholder and can be replaced.-->
2+
<div style="text-align:center">
3+
<h1>
4+
Welcome to {{ title }}!
5+
</h1>
6+
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
7+
</div>
8+
<h2>Here are some links to help you start: </h2>
9+
<ul>
10+
<li>
11+
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12+
</li>
13+
<li>
14+
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15+
</li>
16+
<li>
17+
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
18+
</li>
19+
</ul>
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: '<%= indexAppRootTag %>',
5+
templateUrl: './app.component.html'
6+
})
7+
export class <%= entryComponentName %> {
8+
title = 'app';
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { NgModule } from '@angular/core';
3+
4+
5+
import { <%= entryComponentName %> } from '<%= entryComponentImportPath %>';
6+
7+
8+
@NgModule({
9+
declarations: [
10+
<%= entryComponentName %>
11+
],
12+
imports: [
13+
BrowserModule
14+
],
15+
providers: [],
16+
bootstrap: [<%= entryComponentName %>]
17+
})
18+
export class <%= entryModuleName %> { }
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { enableProdMode } from '@angular/core';
2+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3+
4+
import { <%= entryModuleName %> } from '<%= entryModuleImportPath %>';
5+
import { environment } from './environments/environment';
6+
7+
if (environment.production) {
8+
enableProdMode();
9+
}
10+
11+
platformBrowserDynamic().bootstrapModule(<%= entryModuleName %>)
12+
.catch(err => console.log(err));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true
3+
};
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+
};

Diff for: src/migrate-ns/_files/__appRoot__/favicon.ico

5.3 KB
Binary file not shown.

Diff for: src/migrate-ns/_files/__appRoot__/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>NgSample</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+
<<%= indexAppRootTag %>></<%= indexAppRootTag %>>
13+
</body>
14+
</html>

Diff for: src/migrate-ns/_files/__appRoot__/polyfills.ts

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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/weak-map';
35+
// import 'core-js/es6/set';
36+
37+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
38+
// import 'classlist.js'; // Run `npm install --save classlist.js`.
39+
40+
/** IE10 and IE11 requires the following for the Reflect API. */
41+
// import 'core-js/es6/reflect';
42+
43+
44+
/** Evergreen browsers require these. **/
45+
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46+
import 'core-js/es7/reflect';
47+
48+
49+
/**
50+
* Required to support Web Animations `@angular/platform-browser/animations`.
51+
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
52+
**/
53+
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54+
55+
56+
57+
/***************************************************************************************************
58+
* Zone JS is required by default for Angular itself.
59+
*/
60+
import 'zone.js/dist/zone'; // Included with Angular CLI.
61+
62+
63+
64+
/***************************************************************************************************
65+
* APPLICATION IMPORTS
66+
*/

Diff for: src/migrate-ns/_files/__appRoot__/styles.css

+1
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 */

Diff for: src/migrate-ns/_files/__appRoot__/tsconfig.app.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/app",
5+
"baseUrl": "./",
6+
"module": "es2015",
7+
"types": []
8+
},
9+
"exclude": [
10+
"test.ts",
11+
"**/*.spec.ts"
12+
]
13+
}

Diff for: src/migrate-ns/_files/tsconfig.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"outDir": "./dist/out-tsc",
5+
"sourceMap": true,
6+
"declaration": false,
7+
"moduleResolution": "node",
8+
"emitDecoratorMetadata": true,
9+
"experimentalDecorators": true,
10+
"target": "es5",
11+
"typeRoots": [
12+
"node_modules/@types"
13+
],
14+
"lib": [
15+
"es2017",
16+
"dom"
17+
]
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"project": {
4+
"name": "<%= name %>"
5+
},
6+
"apps": [
7+
{
8+
"root": "<%= sourceDir %>",
9+
"outDir": "dist",
10+
"assets": [
11+
"assets",
12+
"favicon.ico"
13+
],
14+
"index": "index.html",
15+
"main": "main.ts",
16+
"polyfills": "polyfills.ts",
17+
"test": "test.ts",
18+
"tsconfig": "tsconfig.app.json",
19+
"testTsconfig": "tsconfig.spec.json",
20+
"prefix": "app",
21+
"styles": [
22+
"styles.css"
23+
],
24+
"scripts": [],
25+
"environmentSource": "environments/environment.ts",
26+
"environments": {
27+
"dev": "environments/environment.ts",
28+
"prod": "environments/environment.prod.ts"
29+
}
30+
}
31+
],
32+
"e2e": {
33+
"protractor": {
34+
"config": "./protractor.conf.js"
35+
}
36+
},
37+
"lint": [
38+
{
39+
"project": "<%= sourceDir %>/tsconfig.app.json",
40+
"exclude": "**/node_modules/**"
41+
},
42+
{
43+
"project": "<%= sourceDir %>/tsconfig.spec.json",
44+
"exclude": "**/node_modules/**"
45+
},
46+
{
47+
"project": "e2e/tsconfig.e2e.json",
48+
"exclude": "**/node_modules/**"
49+
}
50+
],
51+
"test": {
52+
"karma": {
53+
"config": "./karma.conf.js"
54+
}
55+
},
56+
"defaults": {
57+
"styleExt": "css",
58+
"component": {}
59+
}
60+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/dist-server
6+
/tmp
7+
/out-tsc
8+
9+
# dependencies
10+
/node_modules
11+
12+
# IDEs and editors
13+
/.idea
14+
.project
15+
.classpath
16+
.c9/
17+
*.launch
18+
.settings/
19+
*.sublime-workspace
20+
21+
# IDE - VSCode
22+
.vscode/*
23+
!.vscode/settings.json
24+
!.vscode/tasks.json
25+
!.vscode/launch.json
26+
!.vscode/extensions.json
27+
28+
# misc
29+
/.sass-cache
30+
/connect.lock
31+
/coverage
32+
/libpeerconnection.log
33+
npm-debug.log
34+
testem.log
35+
/typings
36+
37+
# e2e
38+
/e2e/*.js
39+
/e2e/*.map
40+
41+
# System Files
42+
.DS_Store
43+
Thumbs.db

Diff for: src/migrate-ns/_ngproject/__directory__/package.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "<%= name %>",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"scripts": {
6+
"ng": "ng",
7+
"start": "ng serve",
8+
"build": "ng build --prod",
9+
"test": "ng test",
10+
"lint": "ng lint",
11+
"e2e": "ng e2e",
12+
"prep": "npm i -D nativescript-dev-webpack"
13+
},
14+
"private": true,
15+
"dependencies": {
16+
"@angular/animations": "^5.2.0",
17+
"@angular/common": "^5.2.0",
18+
"@angular/compiler": "^5.2.0",
19+
"@angular/core": "^5.2.0",
20+
"@angular/forms": "^5.2.0",
21+
"@angular/http": "^5.2.0",
22+
"@angular/platform-browser": "^5.2.0",
23+
"@angular/platform-browser-dynamic": "^5.2.0",
24+
"@angular/router": "^5.2.0",
25+
"core-js": "^2.4.1",
26+
"rxjs": "^5.5.6",
27+
"zone.js": "^0.8.19"
28+
},
29+
"devDependencies": {
30+
"@angular/cli": "1.6.7",
31+
"@angular/compiler-cli": "^5.2.0",
32+
"@angular/language-service": "^5.2.0",
33+
"@types/jasmine": "~2.8.3",
34+
"@types/jasminewd2": "~2.0.2",
35+
"@types/node": "~6.0.60",
36+
"codelyzer": "^4.0.1",
37+
"jasmine-core": "~2.8.0",
38+
"jasmine-spec-reporter": "~4.2.1",
39+
"karma": "~2.0.0",
40+
"karma-chrome-launcher": "~2.2.0",
41+
"karma-coverage-istanbul-reporter": "^1.2.1",
42+
"karma-jasmine": "~1.1.0",
43+
"karma-jasmine-html-reporter": "^0.2.2",
44+
"protractor": "~5.1.2",
45+
"ts-node": "~4.1.0",
46+
"tslint": "~5.9.1",
47+
"typescript": "~2.5.3"
48+
}
49+
}

0 commit comments

Comments
 (0)