Skip to content

Commit

Permalink
Feature/version-14 (#48)
Browse files Browse the repository at this point in the history
* lock files

* angular core and cli update

* angular material update

* Version bump and test correction

* feat: move to nx for 14

Signed-off-by: Jordan Hall <jordan@libertyware.co.uk>

Co-authored-by: Raimund S. Utz <raimund.utz@signal-iduna.de>
Co-authored-by: Jordan Hall <jordan@libertyware.co.uk>
  • Loading branch information
3 people authored Jul 14, 2022
1 parent 7f1d20a commit dd64664
Show file tree
Hide file tree
Showing 10 changed files with 6,414 additions and 2,889 deletions.
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@
"defaultConfiguration": "development"
}
}
}},
"defaultProject": "angular-material-rail-drawer"
}
}
}
69 changes: 69 additions & 0 deletions decorate-angular-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* This file decorates the Angular CLI with the Nx CLI to enable features such as computation caching
* and faster execution of tasks.
*
* It does this by:
*
* - Patching the Angular CLI to warn you in case you accidentally use the undecorated ng command.
* - Symlinking the ng to nx command, so all commands run through the Nx CLI
* - Updating the package.json postinstall script to give you control over this script
*
* The Nx CLI decorates the Angular CLI, so the Nx CLI is fully compatible with it.
* Every command you run should work the same when using the Nx CLI, except faster.
*
* Because of symlinking you can still type `ng build/test/lint` in the terminal. The ng command, in this case,
* will point to nx, which will perform optimizations before invoking ng. So the Angular CLI is always invoked.
* The Nx CLI simply does some optimizations before invoking the Angular CLI.
*
* To opt out of this patch:
* - Replace occurrences of nx with ng in your package.json
* - Remove the script from your postinstall script in your package.json
* - Delete and reinstall your node_modules
*/

const fs = require('fs');
const os = require('os');
const cp = require('child_process');
const isWindows = os.platform() === 'win32';
let output;
try {
output = require('@nrwl/workspace').output;
} catch (e) {
console.warn('Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.');
process.exit(0);
}

/**
* Symlink of ng to nx, so you can keep using `ng build/test/lint` and still
* invoke the Nx CLI and get the benefits of computation caching.
*/
function symlinkNgCLItoNxCLI() {
try {
const ngPath = './node_modules/.bin/ng';
const nxPath = './node_modules/.bin/nx';
if (isWindows) {
/**
* This is the most reliable way to create symlink-like behavior on Windows.
* Such that it works in all shells and works with npx.
*/
['', '.cmd', '.ps1'].forEach(ext => {
if (fs.existsSync(nxPath + ext)) fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
});
} else {
// If unix-based, symlink
cp.execSync(`ln -sf ./nx ${ngPath}`);
}
}
catch(e) {
output.error({ title: 'Unable to create a symlink from the Angular CLI to the Nx CLI:' + e.message });
throw e;
}
}

try {
symlinkNgCLItoNxCLI();
require('nx/src/adapter/decorate-cli').decorateCli();
output.log({ title: 'Angular CLI has been decorated to enable computation caching.' });
} catch(e) {
output.error({ title: 'Decoration of the Angular CLI did not complete successfully' });
}
36 changes: 36 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"affected": {
"defaultBase": "master"
},
"implicitDependencies": {
"package.json": {
"dependencies": "*",
"devDependencies": "*"
},
".eslintrc.json": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"lint",
"test",
"e2e"
]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
]
}
},
"workspaceLayout": {
"appsDir": "projects",
"libsDir": "projects"
}
}
72 changes: 38 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "angular-material-rail-drawer-plugin",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"ng": "nx",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"postinstall": "node ./decorate-angular-cli.js"
},
"author": {
"name": "Jordan Hall",
Expand All @@ -23,40 +24,43 @@
"webpack": "^5.0.0"
},
"dependencies": {
"@angular/animations": "~13.0.2",
"@angular/cdk": "^13.0.2",
"@angular/common": "~13.0.2",
"@angular/compiler": "~13.0.2",
"@angular/core": "~13.0.2",
"@angular/forms": "~13.0.2",
"@angular/localize": "13.0.2",
"@angular/material": "~13.0.2",
"@angular/platform-browser": "~13.0.2",
"@angular/platform-browser-dynamic": "~13.0.2",
"@angular/router": "~13.0.2",
"rxjs": "~6.5.4",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
"@angular/animations": "^14.0.6",
"@angular/cdk": "^14.0.4",
"@angular/common": "^14.0.6",
"@angular/compiler": "^14.0.6",
"@angular/core": "^14.0.6",
"@angular/forms": "^14.0.6",
"@angular/localize": "14.0.5",
"@angular/material": "^14.0.4",
"@angular/platform-browser": "^14.0.6",
"@angular/platform-browser-dynamic": "^14.0.6",
"@angular/router": "^14.0.6",
"@nrwl/angular": "14.4.2",
"rxjs": "^7.4.0",
"tslib": "^2.4.0",
"zone.js": "~0.11.6"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.0.3",
"@angular/cli": "~13.0.3",
"@angular/compiler-cli": "~13.0.2",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.9",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^13.0.6",
"@angular-devkit/build-angular": "^14.0.6",
"@angular/cli": "^14.0.6",
"@angular/compiler-cli": "^14.0.6",
"@nrwl/workspace": "14.4.2",
"@types/jasmine": "~4.0.3",
"@types/jasminewd2": "~2.0.10",
"@types/node": "^18.0.3",
"codelyzer": "^6.0.2",
"jasmine-core": "~4.2.0",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.1",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"ng-packagr": "^14.0.3",
"nx": "14.4.2",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"ts-node": "~10.8.2",
"tslint": "~6.1.0",
"typescript": "~4.4.4"
"typescript": "~4.7.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ describe('AppComponent', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('angular-material-rail-drawer-example app is running!');
expect(compiled.querySelector('.container p').textContent).toContain('Since 2016, the Angular community has been shouting out');
});
});
16 changes: 8 additions & 8 deletions projects/angular-material-rail-drawer/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "angular-material-rail-drawer",
"version": "1.0.0",
"version": "1.1.0",
"homepage": "https://medium.com/@LostDeveloper/angular-material-navigation-drawer-adding-support-mode-rail-mini-variant-behaviour-8f7b107700b3",
"repository": {
"type": "git",
"url": "https://github.com/Jordan-Hall/angular-material-rail-drawer-plugin"
},
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.4.0"
},
"peerDependencies": {
"@angular/common": ">= 10.0.0 < 14.0.0",
"@angular/core": ">= 10.0.0 < 14.0.0",
"@angular/animations": ">= 10.0.0 < 14.0.0",
"@angular/material": ">= 10.0.0 < 14.0.0",
"@angular/cdk": ">= 10.0.0 < 14.0.0",
"rxjs": ">= 6.0.0"
"@angular/common": ">= 10.0.0 < 15.0.0",
"@angular/core": ">= 10.0.0 < 15.0.0",
"@angular/animations": ">= 10.0.0 < 15.0.0",
"@angular/material": ">= 10.0.0 < 15.0.0",
"@angular/cdk": ">= 10.0.0 < 15.0.0",
"rxjs": ">= 7.0.0"
}
}
2 changes: 0 additions & 2 deletions projects/angular-material-rail-drawer/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/*
* Public API Surface of angular-material-rail-drawer
*/

export * from './lib/drawer-rail.module';
export * from './lib/default.config';
export * from './lib/animations.settings';
export * from './lib/drawer-rail.directive';
2 changes: 1 addition & 1 deletion projects/angular-material-rail-drawer/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"declarationMap": true,
"target": "es2015",
"target": "es2020",
"declaration": true,
"strict": true,
"inlineSources": true,
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"target": "es2020",
"lib": [
"es2018",
"dom"
],
"paths": {
"angular-material-rail-drawer": [
"dist/angular-material-rail-drawer/angular-material-rail-drawer",
"dist/angular-material-rail-drawer"
"projects/angular-material-rail-drawer/src/public-api.ts"
]
}
},
Expand All @@ -28,4 +27,4 @@
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
}
Loading

0 comments on commit dd64664

Please sign in to comment.