Browse Source

modify tsconfig file and other commands

pull/13716/head
muhammedaltug 4 years ago
parent
commit
31510763ae
  1. 4
      npm/ng-packs/packages/schematics/src/commands/api/index.ts
  2. 9
      npm/ng-packs/packages/schematics/src/commands/api/schema.json
  3. 2
      npm/ng-packs/packages/schematics/src/commands/create-lib/files-package/__libraryName@kebab__/tsconfig.lib.json.template
  4. 4
      npm/ng-packs/packages/schematics/src/commands/proxy-add/index.ts
  5. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json
  6. 6
      npm/ng-packs/packages/schematics/src/commands/proxy-index/index.ts
  7. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-index/schema.json
  8. 4
      npm/ng-packs/packages/schematics/src/commands/proxy-refresh/index.ts
  9. 10
      npm/ng-packs/packages/schematics/src/commands/proxy-refresh/schema.json
  10. 4
      npm/ng-packs/packages/schematics/src/commands/proxy-remove/index.ts
  11. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-remove/schema.json
  12. 5
      npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts
  13. 17
      npm/ng-packs/packages/schematics/src/utils/workspace.ts

4
npm/ng-packs/packages/schematics/src/commands/api/index.ts

@ -13,7 +13,7 @@ import { Exception } from '../../enums';
import { GenerateProxySchema, ServiceGeneratorParams } from '../../models';
import {
applyWithOverwrite,
buildDefaultPath,
buildTargetPath,
createControllerToServiceMapper,
createImportRefsToModelReducer,
createImportRefToEnumMapper,
@ -42,7 +42,7 @@ export default function (schema: GenerateProxySchema) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const target = await resolveProject(tree, params.target!);
const targetPath = buildDefaultPath(target.definition);
const targetPath = buildTargetPath(target.definition, params.entryPoint);
const readProxyConfig = createProxyConfigReader(targetPath);
const createProxyConfigWriter = createProxyConfigWriterCreator(targetPath);
const data = readProxyConfig(tree);

9
npm/ng-packs/packages/schematics/src/commands/api/schema.json

@ -39,6 +39,15 @@
"index": 3
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"entryPoint": {
"description": "Target Angular project to place the generated code",
"type": "string",
"$default": {
"$source": "argv",
"index": 5
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
}
},
"required": []

2
npm/ng-packs/packages/schematics/src/commands/create-lib/files-package/__libraryName@kebab__/tsconfig.lib.json.template

@ -1,6 +1,6 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.prod.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",

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

@ -1,7 +1,7 @@
import { chain, SchematicContext, Tree } from '@angular-devkit/schematics';
import { GenerateProxySchema } from '../../models';
import {
buildDefaultPath,
buildTargetPath,
createApiDefinitionGetter,
createApisGenerator,
createProxyClearer,
@ -21,7 +21,7 @@ export default function (schema: GenerateProxySchema) {
return chain([
async (host: Tree, _context: SchematicContext) => {
const target = await resolveProject(host, params.target!);
const targetPath = buildDefaultPath(target.definition);
const targetPath = buildTargetPath(target.definition, params.entryPoint);
const readProxyConfig = createProxyConfigReader(targetPath);
let generated: string[] = [];

9
npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json

@ -50,5 +50,14 @@
"x-prompt": "Please enter URL for API definition (default: API Name's url in environment file)"
}
},
"entryPoint": {
"description": "Target Angular project to place the generated code",
"type": "string",
"$default": {
"$source": "argv",
"index": 5
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"required": []
}

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

@ -1,18 +1,18 @@
import { SchematicContext, Tree } from '@angular-devkit/schematics';
import {
buildDefaultPath,
buildTargetPath,
createProxyIndexGenerator,
removeDefaultPlaceholders,
resolveProject,
} from '../../utils';
export default function (schema: { target?: string }) {
export default function (schema: { target?: string; entryPoint?: string }) {
const params = removeDefaultPlaceholders(schema);
return async (host: Tree, _context: SchematicContext) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const target = await resolveProject(host, params.target!);
const targetPath = buildDefaultPath(target.definition);
const targetPath = buildTargetPath(target.definition, params.entryPoint);
const generateIndex = createProxyIndexGenerator(targetPath);

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

@ -12,6 +12,15 @@
"index": 0
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"entryPoint": {
"description": "Target Angular project to place the generated code",
"type": "string",
"$default": {
"$source": "argv",
"index": 5
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
}
},
"required": []

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

@ -1,7 +1,7 @@
import { chain, SchematicContext, Tree } from '@angular-devkit/schematics';
import { GenerateProxySchema } from '../../models';
import {
buildDefaultPath,
buildTargetPath,
createApiDefinitionGetter,
createApisGenerator,
createProxyClearer,
@ -18,7 +18,7 @@ export default function (schema: GenerateProxySchema) {
return async (host: Tree, _context: SchematicContext) => {
const target = await resolveProject(host, params.target!);
const targetPath = buildDefaultPath(target.definition);
const targetPath = buildTargetPath(target.definition, params.entryPoint);
const readProxyConfig = createProxyConfigReader(targetPath);
const { generated } = readProxyConfig(host);

10
npm/ng-packs/packages/schematics/src/commands/proxy-refresh/schema.json

@ -48,7 +48,17 @@
"index": 4
},
"x-prompt": "Please enter URL for api definition (default: API Name's url in environment file)"
},
"entryPoint": {
"description": "Target Angular project to place the generated code",
"type": "string",
"$default": {
"$source": "argv",
"index": 5
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
}
},
"required": []
}

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

@ -1,7 +1,7 @@
import { chain, SchematicContext, Tree } from '@angular-devkit/schematics';
import { GenerateProxySchema } from '../../models';
import {
buildDefaultPath,
buildTargetPath,
createApiDefinitionGetter,
createApisGenerator,
createProxyClearer,
@ -20,7 +20,7 @@ export default function (schema: GenerateProxySchema) {
return async (host: Tree, _context: SchematicContext) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const target = await resolveProject(host, params.target!);
const targetPath = buildDefaultPath(target.definition);
const targetPath = buildTargetPath(target.definition, params.entryPoint);
const readProxyConfig = createProxyConfigReader(targetPath);
const { generated } = readProxyConfig(host);

9
npm/ng-packs/packages/schematics/src/commands/proxy-remove/schema.json

@ -48,6 +48,15 @@
"index": 4
},
"x-prompt": "Please enter URL for API definition (default: API Name's url in environment file)"
},
"entryPoint": {
"description": "Target Angular project to place the generated code",
"type": "string",
"$default": {
"$source": "argv",
"index": 5
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
}
},
"required": []

5
npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts

@ -24,11 +24,6 @@ export interface GenerateProxySchema {
*/
url?: string;
/**
* Create a lib for proxy generation
*/
createTarget?: boolean;
/**
* Secondary entrypoint for proxy generation
*/

17
npm/ng-packs/packages/schematics/src/utils/workspace.ts

@ -3,7 +3,7 @@ import { strings, workspaces } from '@angular-devkit/core';
import { SchematicsException, Tree } from '@angular-devkit/schematics';
import { Exception } from '../enums';
import { Project } from '../models';
import { getWorkspace, ProjectType, WorkspaceSchema } from './angular';
import { buildDefaultPath, getWorkspace, ProjectType, WorkspaceSchema } from './angular';
import { findEnvironmentExpression } from './ast';
import { readFileInTree } from './common';
import { NOT_FOUND_VALUE } from '../constants/symbols';
@ -93,3 +93,18 @@ export function getWorkspacePath(host: Tree): string {
return path;
}
/**
* Build a default project path for generating.
* @param project The project which will have its default path generated.
* @param entryPoint The secondary-entry-point.
*/
export function buildTargetPath(
project: workspaces.ProjectDefinition,
entryPoint?: string,
): string {
if (entryPoint) {
return `${project.root}/${entryPoint}/src`;
}
return buildDefaultPath(project);
}

Loading…
Cancel
Save