Merge pull request #13586 from abpframework/fix/13504

Fix range error on proxy-generation
pull/13601/head
Mahmut Gundogdu 3 years ago committed by GitHub
commit 7a5ddcabde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,3 +54,5 @@ Thumbs.db
!**/[Pp]ackages/*
*.internal.*
.angular

@ -34,7 +34,9 @@
"dev:schematics": "tsc -p packages/schematics/tsconfig.json -w",
"ci": "yarn affected:lint && yarn affected:build && yarn affected:test",
"lerna": "lerna",
"migrate-nx": "yarn nx migrate --run-migrations"
"migrate-nx": "yarn nx migrate --run-migrations",
"mock:schematics": "cd scripts/mock-schematic && yarn && yarn start",
"debug:schematics": "./node_modules/.bin/ng g ./packages/schematics/src/collection.json:proxy-add --module __default --apiName __default --source __default --target __default --url http://localhost:4300"
},
"private": true,
"devDependencies": {

@ -5,6 +5,7 @@ export * from './method';
export * from './model';
export * from './project';
export * from './proxy-config';
export * from './rule';
export * from './service';
export * from './tree';
export * from './util';

@ -0,0 +1,3 @@
import { Rule } from '@angular-devkit/schematics';
export type RuleReturn = ReturnType<Rule>;

@ -9,11 +9,15 @@ import {
Source,
Tree,
} from '@angular-devkit/schematics';
import { RuleReturn } from '../models/rule';
export function applyWithOverwrite(source: Source, rules: Rule[]): Rule {
return (tree: Tree, _context: SchematicContext) => {
const rule = mergeWith(apply(source, [...rules, overwriteFileIfExists(tree)]));
const mapped = rules.map<Rule>(r => {
return ((_tree: Tree, _ctx: SchematicContext) =>
new Promise<RuleReturn>(res => res(r(_tree, _ctx)))) as Rule;
});
const rule = mergeWith(apply(source, [...mapped, overwriteFileIfExists(tree)]));
return rule(tree, _context);
};
}

@ -0,0 +1,13 @@
import express, { Request, Response } from 'express';
import fs from 'fs';
const port = 4300;
const app = express();
app.get('/api/abp/api-definition', async (req: Request, res: Response) => {
const file = fs.readFileSync('./api-definition.json');
res.contentType('application/json');
res.send(file);
});
app.listen(port, () => console.log(`Server listening on http://localhost:${port}`));

@ -0,0 +1,22 @@
{
"name": "mocks-schematics",
"version": "0.0.1",
"description": "ABP Mock Proxy Generation App",
"scripts": {
"start": "nodemon mock-schematic-json.ts"
},
"author": "",
"dependencies": {
"babel-preset-node6": "^11.0.0",
"express": "^4.18.1"
},
"devDependencies": {
"@types/node": "^13.1.2",
"esm": "^3.2.25",
"ts-node": "^8.5.4",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.4",
"nodemon": "^2.0.19",
"@types/express": "^4.17.13"
}
}

@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
Loading…
Cancel
Save