Skip to content

Commit

Permalink
feat(other): Added schematics support
Browse files Browse the repository at this point in the history
  • Loading branch information
Airblader committed Dec 25, 2018
1 parent 39051dd commit 35b0e66
Show file tree
Hide file tree
Showing 10 changed files with 1,907 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/out-tsc

# dependencies
/node_modules
node_modules

# profiling files
chrome-profiler-events.json
Expand Down
133 changes: 68 additions & 65 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,70 @@
{
"name": "ngqp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng lint && ng build",
"build-core": "ng build @ngqp/core",
"serve-demo": "ng serve ngqp-demo",
"release": "cd projects/ngqp/core && standard-version --infile ../../../CHANGELOG.md",
"publish": "yarn build-core && cd dist/ngqp/core && npm publish --access public",
"publish-demo": "yarn build-core && ng build ngqp-demo --prod --base-href=\"https://Airblader.github.io/ngqp/\" && npx ngh --dir=dist/ngqp-demo",
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.1.0",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/forms": "~7.1.0",
"@angular/platform-browser": "~7.1.0",
"@angular/platform-browser-dynamic": "~7.1.0",
"@angular/router": "~7.1.0",
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.10",
"@fortawesome/free-brands-svg-icons": "^5.6.1",
"@fortawesome/free-solid-svg-icons": "^5.6.1",
"@ng-bootstrap/ng-bootstrap": "^4.0.0",
"@ngqp/core": "./projects/ngqp/core",
"add": "^2.0.6",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"yarn": "^1.12.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.11.0",
"@angular-devkit/build-ng-packagr": "~0.11.0",
"@angular/cli": "~7.1.2",
"@angular/compiler-cli": "~7.1.0",
"@angular/language-service": "~7.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"angular-cli-ghpages": "^0.5.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ng-packagr": "^4.2.0",
"protractor": "~5.4.0",
"standard-version": "^4.4.0",
"ts-node": "~7.0.0",
"tsickle": ">=0.29.0",
"tslib": "^1.9.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
"name": "ngqp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"lint": "ng lint",
"test": "ng test",
"core:build": "ng build @ngqp/core",
"core:build:prod": "yarn core:build",
"demo:build": "ng build ngqp-demo",
"demo:build:prod": "yarn demo:build --prod",
"demo:serve": "ng serve ngqp-demo",
"schematics:build": "sh scripts/build-schematics.sh",

"//release": "cd projects/ngqp/core && standard-version --infile ../../../CHANGELOG.md",
"//publish": "yarn build:core && cd dist/ngqp/core && npm publish --access public",
"//publish:demo": "yarn build:core && ng build ngqp-demo --prod --base-href=\"https://Airblader.github.io/ngqp/\" && npx ngh --dir=dist/ngqp-demo"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.1.0",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/forms": "~7.1.0",
"@angular/platform-browser": "~7.1.0",
"@angular/platform-browser-dynamic": "~7.1.0",
"@angular/router": "~7.1.0",
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.10",
"@fortawesome/free-brands-svg-icons": "^5.6.1",
"@fortawesome/free-solid-svg-icons": "^5.6.1",
"@ng-bootstrap/ng-bootstrap": "^4.0.0",
"@ngqp/core": "./projects/ngqp/core",
"add": "^2.0.6",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"yarn": "^1.12.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.11.0",
"@angular-devkit/build-ng-packagr": "~0.11.0",
"@angular/cli": "~7.1.2",
"@angular/compiler-cli": "~7.1.0",
"@angular/language-service": "~7.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"angular-cli-ghpages": "^0.5.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ng-packagr": "^4.2.0",
"protractor": "~5.4.0",
"standard-version": "^4.4.0",
"ts-node": "~7.0.0",
"tsickle": ">=0.29.0",
"tslib": "^1.9.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
}
5 changes: 4 additions & 1 deletion projects/ngqp/core/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"dest": "../../../dist/ngqp/core",
"lib": {
"entryFile": "src/public_api.ts"
}
},
"whitelistedNonPeerDependencies": [
"schematics-utilities"
]
}
54 changes: 29 additions & 25 deletions projects/ngqp/core/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{
"name": "@ngqp/core",
"version": "0.0.3",
"description": "Synchronizing form controls with the URL for Angular",
"homepage": "https://github.com/Airblader/ngqp",
"author": "Ingo Bürk",
"license": "MIT",
"bugs": "https://github.com/Airblader/ngqp/issues",
"repository": {
"type": "git",
"url": "https://github.com/Airblader/ngqp.git"
},
"keywords": [
"angular",
"router",
"url",
"queryparams",
"query-params"
],
"peerDependencies": {
"@angular/common": "^7.x.x",
"@angular/core": "^7.x.x",
"@angular/forms": "^7.x.x",
"@angular/router": "^7.x.x",
"rxjs": "^6.x.x"
}
"name": "@ngqp/core",
"version": "0.0.3",
"description": "Synchronizing form controls with the URL for Angular",
"homepage": "https://github.com/Airblader/ngqp",
"author": "Ingo Bürk",
"license": "MIT",
"bugs": "https://github.com/Airblader/ngqp/issues",
"repository": {
"type": "git",
"url": "https://github.com/Airblader/ngqp.git"
},
"keywords": [
"angular",
"router",
"url",
"queryparams",
"query-params"
],
"schematics": "./schematics/collection.json",
"peerDependencies": {
"@angular/common": "^7.x.x",
"@angular/core": "^7.x.x",
"@angular/forms": "^7.x.x",
"@angular/router": "^7.x.x",
"rxjs": "^6.x.x"
},
"devDependencies": {
"schematics-utilities": "^1.1.1"
}
}
3 changes: 3 additions & 0 deletions projects/ngqp/core/schematics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.js
*.js.map
*.d.ts
9 changes: 9 additions & 0 deletions projects/ngqp/core/schematics/collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"ng-add": {
"description": "Adds @ngqp to a project",
"factory": "./schematics/ng-add/index"
}
}
}
25 changes: 25 additions & 0 deletions projects/ngqp/core/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { chain, noop, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { addModuleImportToRootModule, getProjectFromWorkspace, getWorkspace } from 'schematics-utilities';

const NGQP_MODULE_NAME = 'QueryParamModule';

function addModuleToImports(options: any): Rule {
return (host: Tree, context: SchematicContext) => {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(
workspace,
options.project ? options.project : Object.keys(workspace[ 'projects' ])[ 0 ]
);

addModuleImportToRootModule(host, NGQP_MODULE_NAME, '@ngqp/core', project);
context.logger.log('info', `✅️ "${NGQP_MODULE_NAME}" has been imported`);

return host;
};
}

export default function(options: any): Rule {
return chain([
options && options.skipModuleImport ? noop() : addModuleToImports(options),
]);
}
36 changes: 36 additions & 0 deletions projects/ngqp/core/tsconfig.schematics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"compilerOptions": {
"rootDir": "./schematics",
"outDir": "../../../dist/ngqp/core/schematics",
"lib": [
"es2017",
"dom"
],
"declaration": true,
"module": "commonjs",
"resolveJsonModule": true,
"esModuleInterop": true,
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"sourceMap": false,
"strictNullChecks": true,
"target": "es6",
"types": [
"node"
]
},
"include": [
"schematics/**/*"
],
"exclude": [
"schematics/**/*.test.ts",
"schematics/**/files/**/*"
]
}
Loading

0 comments on commit 35b0e66

Please sign in to comment.