diff --git a/package-lock.json b/package-lock.json index 4ce4d34..23fa177 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9655,8 +9655,7 @@ "parse5": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", - "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==", - "optional": true + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" }, "parseqs": { "version": "0.0.5", @@ -11084,6 +11083,94 @@ "ajv-keywords": "^3.1.0" } }, + "schematics-utilities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/schematics-utilities/-/schematics-utilities-1.1.2.tgz", + "integrity": "sha512-HhY15I4pugKtzu/g3gnSNPkz3ah8fAm1asp+fbElzp7rpm69PgGWkp4ta0ubyCbpj2qSV4TvZE87n10KpdE9zw==", + "dev": true, + "requires": { + "@angular-devkit/core": "^7.3.6", + "@angular-devkit/schematics": "^7.3.6", + "npm-registry-client": "^8.5.1", + "parse5": "^5.0.0", + "rxjs": "^6.4.0", + "typescript": "^3.3.3333" + }, + "dependencies": { + "@angular-devkit/core": { + "version": "7.3.9", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-7.3.9.tgz", + "integrity": "sha512-SaxD+nKFW3iCBKsxNR7+66J30EexW/y7tm8m5AvUH+GwSAgIj0ZYmRUzFEPggcaLVA4WnE/YWqIXZMJW5dT7gw==", + "dev": true, + "requires": { + "ajv": "6.9.1", + "chokidar": "2.0.4", + "fast-json-stable-stringify": "2.0.0", + "rxjs": "6.3.3", + "source-map": "0.7.3" + }, + "dependencies": { + "rxjs": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", + "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + } + } + }, + "@angular-devkit/schematics": { + "version": "7.3.9", + "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-7.3.9.tgz", + "integrity": "sha512-xzROGCYp7aQbeJ3V6YC0MND7wKEAdWqmm/GaCufEk0dDS8ZGe0sQhcM2oBRa2nQqGQNeThFIH51kx+FayrJP0w==", + "dev": true, + "requires": { + "@angular-devkit/core": "7.3.9", + "rxjs": "6.3.3" + }, + "dependencies": { + "rxjs": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", + "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + } + } + }, + "ajv": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.9.1.tgz", + "integrity": "sha512-XDN92U311aINL77ieWHmqCcNlwjoP5cHXDxIxbf2MaPYuCXOHS7gHH8jktxeK5omgd52XbSTX6a4Piwd1pQmzA==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "rxjs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", + "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "typescript": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", + "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", + "dev": true + } + } + }, "scss-tokenizer": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", diff --git a/package.json b/package.json index 6a15858..9370fdc 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "start:prod": "node --max-old-space-size=4096 ./node_modules/.bin/ng serve --prod", "build": "ng build --prod", "build:core": "ng build core --prod", + "postbuild:core": "cd ./projects/core && npm run build", "build:forms": "ng build forms --prod", "build:core:watch": "ng build core", "build:forms:watch": "ng build forms", @@ -67,6 +68,7 @@ "ng-packagr": "^4.7.1", "prettier": "1.16.4", "protractor": "~5.1.2", + "schematics-utilities": "^1.1.2", "ts-node": "~4.1.0", "tsickle": ">=0.25.5", "tslib": "^1.7.1", diff --git a/projects/core/package.json b/projects/core/package.json index c9407e9..596a1d1 100644 --- a/projects/core/package.json +++ b/projects/core/package.json @@ -13,6 +13,13 @@ ], "author": "thekiba ", "license": "MIT", + "scripts": { + "build": "../../node_modules/.bin/tsc -p tsconfig.schematics.json", + "copy:schemas": "cp --parents schematics/*/schema.json ../../dist/core/", + "copy:files": "cp --parents -p schematics/*/files/** ../../dist/core/", + "copy:collection": "cp schematics/collection.json ../../dist/core/schematics/collection.json", + "postbuild": "npm run copy:collection" + }, "repository": { "type": "git", "url": "git+https://github.com/IndigoSoft/ngxd.git" @@ -27,6 +34,7 @@ "url": "https://github.com/IndigoSoft/ngxd/issues" }, "homepage": "https://github.com/IndigoSoft/ngxd", + "schematics": "./schematics/collection.json", "peerDependencies": { "@angular/common": "^6.0.0-rc.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", "@angular/core": "^6.0.0-rc.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", diff --git a/projects/core/schematics/collection.json b/projects/core/schematics/collection.json new file mode 100644 index 0000000..03bd21a --- /dev/null +++ b/projects/core/schematics/collection.json @@ -0,0 +1,9 @@ +{ + "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json", + "schematics": { + "ng-add": { + "description": "Add my library to the project.", + "factory": "./ng-add/index#ngAdd" + } + } +} diff --git a/projects/core/schematics/ng-add/index.ts b/projects/core/schematics/ng-add/index.ts new file mode 100644 index 0000000..dc3499a --- /dev/null +++ b/projects/core/schematics/ng-add/index.ts @@ -0,0 +1,20 @@ +import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; +import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; +import { addPackageJsonDependency, NodeDependencyType } from 'schematics-utilities'; +import { readFileSync } from 'fs'; +import * as path from 'path'; + +const packageJson = readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf8'); +const version = JSON.parse(packageJson).version; +// Just return the tree +export function ngAdd(): Rule { + return (tree: Tree, _context: SchematicContext) => { + addPackageJsonDependency(tree, { + type: NodeDependencyType.Default, + version: version, + name: '@ngxd/core', + }); + _context.addTask(new NodePackageInstallTask()); + return tree; + }; +} diff --git a/projects/core/tsconfig.schematics.json b/projects/core/tsconfig.schematics.json new file mode 100644 index 0000000..b2b0c86 --- /dev/null +++ b/projects/core/tsconfig.schematics.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "lib": [ + "es2018", + "dom" + ], + "declaration": true, + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedParameters": true, + "noUnusedLocals": true, + "rootDir": "schematics", + "outDir": "../../dist/core/schematics", + "skipDefaultLibCheck": true, + "skipLibCheck": true, + "sourceMap": true, + "strictNullChecks": true, + "target": "es6", + "types": [ + "jasmine", + "node" + ] + }, + "include": [ + "schematics/**/*" + ], + "exclude": [ + "schematics/*/files/**/*" + ] +}