Browse Source

Merge pull request #5279 from abpframework/feat/5277

Added proxy-index as separate command in schematics
pull/5285/head
Bunyamin Coskuner 6 years ago
committed by GitHub
parent
commit
6ab502bbac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      npm/ng-packs/packages/schematics/src/collection.json
  2. 20
      npm/ng-packs/packages/schematics/src/commands/proxy-index/index.ts
  3. 18
      npm/ng-packs/packages/schematics/src/commands/proxy-index/schema.json
  4. 2
      npm/ng-packs/packages/schematics/src/utils/barrel.ts
  5. 1
      npm/ng-packs/scripts/build-schematics.ts

5
npm/ng-packs/packages/schematics/src/collection.json

@ -5,6 +5,11 @@
"factory": "./commands/proxy-add",
"schema": "./commands/proxy-add/schema.json"
},
"proxy-index": {
"description": "ABP Proxy Generator Index Schematics",
"factory": "./commands/proxy-index",
"schema": "./commands/proxy-index/schema.json"
},
"proxy-refresh": {
"description": "ABP Proxy Generator Refresh Schematics",
"factory": "./commands/proxy-refresh",

20
npm/ng-packs/packages/schematics/src/commands/proxy-index/index.ts

@ -0,0 +1,20 @@
import { SchematicContext, Tree } from '@angular-devkit/schematics';
import {
buildDefaultPath,
createProxyIndexGenerator,
removeDefaultPlaceholders,
resolveProject,
} from '../../utils';
export default function(schema: { target?: string }) {
const params = removeDefaultPlaceholders(schema);
return async (host: Tree, _context: SchematicContext) => {
const target = await resolveProject(host, params.target!);
const targetPath = buildDefaultPath(target.definition);
const generateIndex = createProxyIndexGenerator(targetPath);
return generateIndex(host);
};
}

18
npm/ng-packs/packages/schematics/src/commands/proxy-index/schema.json

@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/schema",
"id": "SchematicsAbpIndexProxy",
"title": "ABP Index Proxy Schema",
"type": "object",
"properties": {
"target": {
"description": "Target Angular project to place the generated code",
"type": "string",
"$default": {
"$source": "argv",
"index": 0
},
"x-prompt": "Plese enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
}
},
"required": []
}

2
npm/ng-packs/packages/schematics/src/utils/barrel.ts

@ -21,7 +21,7 @@ export function generateBarrelFromPath(tree: Tree, indexPath: string) {
const _exports: string[] = [];
dir.subfiles.forEach(fragment => {
if (!fragment.endsWith('.ts')) return;
if (!fragment.endsWith('.ts') || fragment === 'index.ts') return;
_exports.push(`export * from './${fragment.replace(/\.ts$/, '')}';`);
});

1
npm/ng-packs/scripts/build-schematics.ts

@ -21,6 +21,7 @@ class FileCopy {
const PACKAGE_TO_BUILD = 'schematics';
const FILES_TO_COPY_AFTER_BUILD: (FileCopy | string)[] = [
{ src: 'src/commands/proxy-add/schema.json', dest: 'commands/proxy-add/schema.json' },
{ src: 'src/commands/proxy-index/schema.json', dest: 'commands/proxy-index/schema.json' },
{ src: 'src/commands/proxy-refresh/schema.json', dest: 'commands/proxy-refresh/schema.json' },
{ src: 'src/commands/proxy-remove/schema.json', dest: 'commands/proxy-remove/schema.json' },
{ src: 'src/commands/api/files-enum', dest: 'commands/api/files-enum' },

Loading…
Cancel
Save