Skip to content

Commit

Permalink
Merge pull request #38 from ngxpert/feat/schematics
Browse files Browse the repository at this point in the history
feat: add schematics
  • Loading branch information
shhdharmen authored Dec 10, 2024
2 parents d720614 + 62570f9 commit 1bddedb
Show file tree
Hide file tree
Showing 15 changed files with 707 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ https://github.com/ngxpert/hot-toast/assets/6831283/ae718568-d5ea-47bf-a41d-6aab

## Installation

### Angular 19+

Using **Angular CLI**:

```bash
ng add @ngxpert/hot-toast
```

### Other Angular Versions

With **npm**:

```bash
Expand Down
244 changes: 243 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
},
"dependencies": {
"@angular/animations": "^19.0.3",
"@angular/cdk": "~19.0.2",
"@angular/common": "^19.0.3",
"@angular/compiler": "^19.0.3",
"@angular/core": "^19.0.3",
Expand All @@ -61,6 +60,7 @@
"@angular-eslint/eslint-plugin-template": "19.0.2",
"@angular-eslint/schematics": "19.0.2",
"@angular-eslint/template-parser": "19.0.2",
"@angular/cdk": "^19.0.2",
"@angular/cli": "^19.0.4",
"@angular/compiler-cli": "^19.0.3",
"@commitlint/cli": "^17.3.0",
Expand All @@ -79,6 +79,7 @@
"angular-cli-ghpages": "^2.0.0-beta.2",
"codelyzer": "^6.0.0",
"commitizen": "^4.2.4",
"copyfiles": "^2.4.1",
"cpx": "^1.5.0",
"cross-env": "^7.0.3",
"cypress": "^13.16.1",
Expand Down
24 changes: 21 additions & 3 deletions projects/ngxpert/hot-toast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
"version": "0.0.0-development",
"description": "Smoking hot Notifications for Angular. Lightweight, customizable and beautiful by default.",
"scripts": {
"build": "npm run build:sass",
"build": "npm run build:sass && tsc -p tsconfig.schematics.json",
"build:sass": "sass ./src/styles/styles.scss ../../../dist/ngxpert/hot-toast/src/styles/styles.css",
"postpublish": "cpx package.json ../../../../../projects/ngxpert/hot-toast/ && cpx npm-shrinkwrap.json ../../../../../projects/ngxpert/hot-toast/"
"postpublish": "cpx package.json ../../../../../projects/ngxpert/hot-toast/ && cpx npm-shrinkwrap.json ../../../../../projects/ngxpert/hot-toast/",
"postbuild": "copyfiles schematics/*/schema.json schematics/*/files/** schematics/collection.json ../../../dist/ngxpert/hot-toast/"
},
"peerDependencies": {
"@angular/common": ">= 19.0.0",
"@angular/core": ">= 19.0.0",
"@ngneat/overview": "6.1.1"
},
"devDependencies": {
"copyfiles": "file:../../../node_modules/copyfiles",
"typescript": "file:../../../node_modules/typescript",
"cpx": "file:../../../node_modules/cpx",
"sass": "file:../../../node_modules/sass",
"@angular/cdk": "file:../../../node_modules/@angular/cdk"
},
"keywords": [
"angular",
"angular 2",
Expand All @@ -31,7 +40,16 @@
"type": "git",
"url": "https://github.com/ngxpert/hot-toast"
},
"exports": {
"./styles.css": {
"style": "./src/styles/styles.css"
},
"./styles": {
"sass": "./src/styles/styles.scss"
}
},
"ng-add": {
"save": true
}
},
"schematics": "./schematics/collection.json"
}
17 changes: 17 additions & 0 deletions projects/ngxpert/hot-toast/schematics/collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"ng-add": {
"description": "Add @ngxpert/hot-toast to the project.",
"factory": "./ng-add/index#ngAdd",
"schema": "./ng-add/schema.json"
},
"ng-add-setup-project": {
"description": "Sets up the specified project after the ng-add dependencies have been installed.",
"private": true,
"factory": "./ng-add/setup-project",
"schema": "./ng-add/schema.json",
"hidden": true
}
}
}
12 changes: 12 additions & 0 deletions projects/ngxpert/hot-toast/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Rule, Tree, SchematicContext } from '@angular-devkit/schematics';
import { NodePackageInstallTask, RunSchematicTask } from '@angular-devkit/schematics/tasks';
import { addPackageToPackageJson } from './package-config';
import { Schema } from './schema';
export function ngAdd(options: Schema): Rule {
return (host: Tree, context: SchematicContext) => {
addPackageToPackageJson(host, '@ngneat/overview', '6.1.1');
const installTaskId = context.addTask(new NodePackageInstallTask());

context.addTask(new RunSchematicTask('ng-add-setup-project', options), [installTaskId]);
};
}
Loading

0 comments on commit 1bddedb

Please sign in to comment.