mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
chore(nestjs) add scripts directory
This commit is contained in:
2
bundle/common/cache/cache.module.js
vendored
2
bundle/common/cache/cache.module.js
vendored
@@ -45,7 +45,7 @@ let CacheModule = CacheModule_1 = class CacheModule {
|
||||
}
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createCacheOptions(),
|
||||
useFactory: async (optionsFactory) => optionsFactory.createCacheOptions(),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ let MulterModule = MulterModule_1 = class MulterModule {
|
||||
}
|
||||
return {
|
||||
provide: files_constants_1.MULTER_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createMulterOptions(),
|
||||
useFactory: async (optionsFactory) => optionsFactory.createMulterOptions(),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
|
||||
53
package.json
53
package.json
@@ -1,27 +1,36 @@
|
||||
{
|
||||
"name": "nestjs",
|
||||
"version": "5.3.8",
|
||||
"version": "5.3.10",
|
||||
"description": "Modern, fast, powerful node.js web framework",
|
||||
"scripts": {
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"precommit": "lint-staged",
|
||||
"test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec",
|
||||
"integration-test": "mocha integration/**/*.spec.ts --reporter spec --require ts-node/register",
|
||||
"lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
|
||||
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
|
||||
"test":
|
||||
"nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec",
|
||||
"integration-test":
|
||||
"mocha integration/**/*.spec.ts --reporter spec --require ts-node/register",
|
||||
"lint":
|
||||
"tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
|
||||
"format":
|
||||
"prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
|
||||
"build": "gulp build && gulp move",
|
||||
"build:lib": "gulp build --dist bundle",
|
||||
"postinstall": "opencollective",
|
||||
"copy-docs": "gulp copy-docs",
|
||||
"prepare": "npm run build:lib && npm run copy-docs",
|
||||
"prepare:npm": "npm run build:lib && npm run copy-docs",
|
||||
"prepare:rc": "npm run build:lib && npm run copy-docs",
|
||||
"prepare:next": "npm run build:lib && npm run copy-docs",
|
||||
"prepare:beta": "npm run build:lib && npm run copy-docs",
|
||||
"publish": "npm run prepare && ./node_modules/.bin/lerna publish --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:rc": "npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=rc -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:next": "npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:beta": "npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:test": "npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=test --skip-git -m \"chore(@nestjs) publish %s release\""
|
||||
"publish":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:rc":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=rc -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:next":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:beta":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:test":
|
||||
"npm run prepare && ./node_modules/.bin/lerna publish --npm-tag=test --skip-git -m \"chore(@nestjs) publish %s release\""
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.9.0"
|
||||
@@ -130,9 +139,7 @@
|
||||
}
|
||||
},
|
||||
"nyc": {
|
||||
"include": [
|
||||
"packages/**/*.ts"
|
||||
],
|
||||
"include": ["packages/**/*.ts"],
|
||||
"exclude": [
|
||||
"node_modules/",
|
||||
"packages/**/*.spec.ts",
|
||||
@@ -151,23 +158,13 @@
|
||||
"packages/common/serializer/**/*",
|
||||
"packages/common/services/logger.service.ts"
|
||||
],
|
||||
"extension": [
|
||||
".ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"reporter": [
|
||||
"text-summary",
|
||||
"html"
|
||||
],
|
||||
"extension": [".ts"],
|
||||
"require": ["ts-node/register"],
|
||||
"reporter": ["text-summary", "html"],
|
||||
"sourceMap": true,
|
||||
"instrument": true
|
||||
},
|
||||
"lint-staged": {
|
||||
"packages/**/*.{ts,json}": [
|
||||
"npm run format",
|
||||
"git add"
|
||||
]
|
||||
"packages/**/*.{ts,json}": ["npm run format", "git add"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,9 @@ export class Injector {
|
||||
) {
|
||||
const { metatype } = wrapper;
|
||||
const currentMetatype = collection.get(metatype.name);
|
||||
if (currentMetatype.instance !== null) return;
|
||||
|
||||
if (currentMetatype.instance !== null) {
|
||||
return;
|
||||
}
|
||||
await this.resolveConstructorParams(
|
||||
wrapper as any,
|
||||
module,
|
||||
@@ -87,12 +88,13 @@ export class Injector {
|
||||
{ metatype, name }: InstanceWrapper<T>,
|
||||
collection: Map<string, InstanceWrapper<T>>,
|
||||
) {
|
||||
if (!collection) return null;
|
||||
|
||||
const target = collection.get(name);
|
||||
if (target.isResolved || !isNil(target.inject) || !metatype.prototype)
|
||||
if (!collection) {
|
||||
return null;
|
||||
|
||||
}
|
||||
const target = collection.get(name);
|
||||
if (target.isResolved || !isNil(target.inject) || !metatype.prototype) {
|
||||
return null;
|
||||
}
|
||||
collection.set(name, {
|
||||
...collection.get(name),
|
||||
instance: Object.create(metatype.prototype),
|
||||
@@ -125,32 +127,21 @@ export class Injector {
|
||||
return wrapper.done$;
|
||||
}
|
||||
const done = this.applyDoneHook(wrapper);
|
||||
const { metatype, name, inject } = wrapper;
|
||||
const currentMetatype = collection.get(name);
|
||||
if (isUndefined(currentMetatype)) {
|
||||
const { name, inject } = wrapper;
|
||||
|
||||
const targetMetatype = collection.get(name);
|
||||
if (isUndefined(targetMetatype)) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
if (currentMetatype.isResolved) {
|
||||
if (targetMetatype.isResolved) {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
await this.resolveConstructorParams<T>(
|
||||
wrapper,
|
||||
module,
|
||||
inject,
|
||||
async instances => {
|
||||
if (isNil(inject)) {
|
||||
currentMetatype.instance = Object.assign(
|
||||
currentMetatype.instance,
|
||||
new metatype(...instances),
|
||||
);
|
||||
} else {
|
||||
const factoryResult = currentMetatype.metatype(...instances);
|
||||
currentMetatype.instance = await factoryResult;
|
||||
}
|
||||
currentMetatype.isResolved = true;
|
||||
done();
|
||||
},
|
||||
async instances =>
|
||||
this.instantiateClass(instances, wrapper, targetMetatype, done),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -269,17 +260,11 @@ export class Injector {
|
||||
) {
|
||||
const { name } = dependencyContext;
|
||||
const scanInExports = () =>
|
||||
this.lookupComponentInExports(
|
||||
components,
|
||||
dependencyContext,
|
||||
module,
|
||||
wrapper,
|
||||
);
|
||||
this.lookupComponentInExports(dependencyContext, module, wrapper);
|
||||
return components.has(name) ? components.get(name) : scanInExports();
|
||||
}
|
||||
|
||||
public async lookupComponentInExports<T = any>(
|
||||
components: Map<string, any>,
|
||||
dependencyContext: InjectorDependencyContext,
|
||||
module: Module,
|
||||
wrapper: InstanceWrapper<T>,
|
||||
@@ -328,4 +313,26 @@ export class Injector {
|
||||
}
|
||||
return componentRef;
|
||||
}
|
||||
|
||||
public async instantiateClass(
|
||||
instances: any[],
|
||||
wrapper: InstanceWrapper<any>,
|
||||
targetMetatype: InstanceWrapper<any>,
|
||||
done: Function,
|
||||
) {
|
||||
const { metatype, inject } = wrapper;
|
||||
if (isNil(inject)) {
|
||||
targetMetatype.instance = Object.assign(
|
||||
targetMetatype.instance,
|
||||
new metatype(...instances),
|
||||
);
|
||||
} else {
|
||||
const factoryResult = ((targetMetatype.metatype as any) as Function)(
|
||||
...instances,
|
||||
);
|
||||
targetMetatype.instance = await factoryResult;
|
||||
}
|
||||
targetMetatype.isResolved = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
8
scripts/prepare_tests.sh
Normal file
8
scripts/prepare_tests.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
# 1. Install all dependencies
|
||||
for D in integration/*; do [ -d "${D}" ] && npm i; done
|
||||
|
||||
# 2. Build fresh packages and move them to sample and integration directories
|
||||
npm run build &>/dev/null
|
||||
|
||||
# 3. Start docker containers to perform integration tests
|
||||
cd integration && docker-compose up -d
|
||||
Reference in New Issue
Block a user