-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from nestjs/next
chore: publish 5.6.0 release
- Loading branch information
Showing
122 changed files
with
2,614 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,7 @@ | |
.gitignore | ||
|
||
.envrc | ||
|
||
.npmrc | ||
.npmignore | ||
|
||
.travis.yml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
.idea/ | ||
.gitignore | ||
.travis.yml | ||
Makefile | ||
Makefile | ||
|
||
# source | ||
**/*.ts | ||
*.ts | ||
|
||
# definitions | ||
!**/*.d.ts | ||
!*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Input } from '../commands'; | ||
export declare abstract class AbstractAction { | ||
abstract handle(inputs?: Input[], options?: Input[]): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class AbstractAction { | ||
} | ||
exports.AbstractAction = AbstractAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { Input } from '../commands'; | ||
|
||
export abstract class AbstractAction { | ||
public abstract async handle(inputs?: Input[], options?: Input[]): Promise<void>; | ||
public abstract async handle( | ||
inputs?: Input[], | ||
options?: Input[], | ||
): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Input } from '../commands'; | ||
import { AbstractAction } from './abstract.action'; | ||
export declare class AddAction extends AbstractAction { | ||
handle(inputs: Input[]): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const package_managers_1 = require("../lib/package-managers"); | ||
const abstract_action_1 = require("./abstract.action"); | ||
class AddAction extends abstract_action_1.AbstractAction { | ||
handle(inputs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const manager = yield package_managers_1.PackageManagerFactory.find(); | ||
const libraryInput = inputs.find(input => input.name === 'library'); | ||
if (libraryInput) { | ||
const library = libraryInput.value; | ||
yield manager.addProduction([library], 'latest'); | ||
} | ||
}); | ||
} | ||
} | ||
exports.AddAction = AddAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { Input } from '../commands'; | ||
import { AbstractPackageManager, PackageManagerFactory } from '../lib/package-managers'; | ||
import { | ||
AbstractPackageManager, | ||
PackageManagerFactory, | ||
} from '../lib/package-managers'; | ||
import { AbstractAction } from './abstract.action'; | ||
|
||
export class AddAction extends AbstractAction { | ||
public async handle(inputs: Input[]) { | ||
const manager: AbstractPackageManager = await PackageManagerFactory.find(); | ||
const libraryInput: Input = inputs.find((input) => input.name === 'library') as Input; | ||
if (!!libraryInput) { | ||
const libraryInput: Input = inputs.find( | ||
input => input.name === 'library', | ||
) as Input; | ||
if (libraryInput) { | ||
const library: string = libraryInput.value as string; | ||
await manager.addProduction([ library ], 'latest'); | ||
await manager.addProduction([library], 'latest'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Input } from '../commands'; | ||
import { AbstractAction } from './abstract.action'; | ||
export declare class GenerateAction extends AbstractAction { | ||
handle(inputs: Input[], options: Input[]): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = require("chalk"); | ||
const nest_configuration_loader_1 = require("../lib/configuration/nest-configuration.loader"); | ||
const readers_1 = require("../lib/readers"); | ||
const schematics_1 = require("../lib/schematics"); | ||
const abstract_action_1 = require("./abstract.action"); | ||
class GenerateAction extends abstract_action_1.AbstractAction { | ||
handle(inputs, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield generateFiles(inputs.concat(options)); | ||
}); | ||
} | ||
} | ||
exports.GenerateAction = GenerateAction; | ||
const generateFiles = (inputs) => __awaiter(this, void 0, void 0, function* () { | ||
const configuration = yield loadConfiguration(); | ||
const collection = schematics_1.CollectionFactory.create(configuration.collection); | ||
const schematicOptions = mapSchematicOptions(inputs); | ||
schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language)); | ||
schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', configuration.sourceRoot)); | ||
try { | ||
const schematicInput = inputs.find(input => input.name === 'schematic'); | ||
if (!schematicInput) { | ||
throw new Error('Unable to find a schematic for this configuration'); | ||
} | ||
yield collection.execute(schematicInput.value, schematicOptions); | ||
} | ||
catch (error) { | ||
if (error && error.message) { | ||
console.error(chalk_1.default.red(error.message)); | ||
} | ||
} | ||
}); | ||
const loadConfiguration = () => __awaiter(this, void 0, void 0, function* () { | ||
const loader = new nest_configuration_loader_1.NestConfigurationLoader(new readers_1.FileSystemReader(process.cwd())); | ||
return loader.load(); | ||
}); | ||
const mapSchematicOptions = (inputs) => { | ||
const options = []; | ||
inputs.forEach(input => { | ||
if (input.name !== 'schematic' && input.value !== undefined) { | ||
options.push(new schematics_1.SchematicOption(input.name, input.value)); | ||
} | ||
}); | ||
return options; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './abstract.action'; | ||
export * from './generate.action'; | ||
export * from './info.action'; | ||
export * from './new.action'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./abstract.action")); | ||
__export(require("./generate.action")); | ||
__export(require("./info.action")); | ||
__export(require("./new.action")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { AbstractAction } from './abstract.action'; | ||
export declare class InfoAction extends AbstractAction { | ||
handle(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = require("chalk"); | ||
const fs_1 = require("fs"); | ||
const os_1 = require("os"); | ||
const osName = require("os-name"); | ||
const path_1 = require("path"); | ||
const package_managers_1 = require("../lib/package-managers"); | ||
const ui_1 = require("../lib/ui"); | ||
const abstract_action_1 = require("./abstract.action"); | ||
class InfoAction extends abstract_action_1.AbstractAction { | ||
handle() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
displayBanner(); | ||
yield displaySystemInformation(); | ||
yield displayNestInformation(); | ||
}); | ||
} | ||
} | ||
exports.InfoAction = InfoAction; | ||
const displayBanner = () => { | ||
console.info(chalk_1.default.red(ui_1.BANNER)); | ||
}; | ||
const displaySystemInformation = () => __awaiter(this, void 0, void 0, function* () { | ||
console.info(chalk_1.default.green('[System Information]')); | ||
console.info('OS Version :', chalk_1.default.blue(osName(os_1.platform(), os_1.release()))); | ||
console.info('NodeJS Version :', chalk_1.default.blue(process.version)); | ||
yield displayPackageManagerVersion(); | ||
}); | ||
const displayPackageManagerVersion = () => __awaiter(this, void 0, void 0, function* () { | ||
const manager = yield package_managers_1.PackageManagerFactory.find(); | ||
try { | ||
const version = yield manager.version(); | ||
console.info(`${manager.name} Version :`, chalk_1.default.blue(version)); | ||
} | ||
catch (_a) { | ||
console.error(`${manager.name} Version :`, chalk_1.default.red('Unknown')); | ||
} | ||
}); | ||
const displayNestInformation = () => __awaiter(this, void 0, void 0, function* () { | ||
console.info(chalk_1.default.green('[Nest Information]')); | ||
try { | ||
const dependencies = yield readProjectPackageJsonDependencies(); | ||
displayNestVersions(dependencies); | ||
} | ||
catch (_b) { | ||
console.error(chalk_1.default.red(ui_1.messages.NEST_INFORMATION_PACKAGE_MANAGER_FAILED)); | ||
} | ||
}); | ||
const readProjectPackageJsonDependencies = () => __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
fs_1.readFile(path_1.join(process.cwd(), 'package.json'), (error, buffer) => { | ||
if (error !== undefined && error !== null) { | ||
reject(error); | ||
} | ||
else { | ||
resolve(JSON.parse(buffer.toString()).dependencies); | ||
} | ||
}); | ||
}); | ||
}); | ||
const displayNestVersions = (dependencies) => { | ||
buildNestVersionsMessage(dependencies) | ||
.forEach((dependency) => console.info(dependency.name, chalk_1.default.blue(dependency.value))); | ||
}; | ||
const buildNestVersionsMessage = (dependencies) => { | ||
const nestDependencies = collectNestDependencies(dependencies); | ||
return format(nestDependencies); | ||
}; | ||
const collectNestDependencies = (dependencies) => { | ||
const nestDependencies = []; | ||
Object.keys(dependencies).forEach((key) => { | ||
if (key.indexOf('@nestjs') > -1) { | ||
nestDependencies.push({ | ||
name: `${key.replace(/@nestjs\//, '')} version`, | ||
value: dependencies[key], | ||
}); | ||
} | ||
}); | ||
return nestDependencies; | ||
}; | ||
const format = (dependencies) => { | ||
const sorted = dependencies.sort((dependencyA, dependencyB) => dependencyB.name.length - dependencyA.name.length); | ||
const length = sorted[0].name.length; | ||
sorted.forEach((dependency) => { | ||
if (dependency.name.length < length) { | ||
dependency.name = rightPad(dependency.name, length); | ||
} | ||
dependency.name = dependency.name.concat(' :'); | ||
dependency.value = dependency.value.replace(/(\^|\~)/, ''); | ||
}); | ||
return sorted; | ||
}; | ||
const rightPad = (name, length) => { | ||
while (name.length < length) { | ||
name = name.concat(' '); | ||
} | ||
return name; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Input } from '../commands'; | ||
import { AbstractAction } from './abstract.action'; | ||
export declare class NewAction extends AbstractAction { | ||
handle(inputs: Input[], options: Input[]): Promise<void>; | ||
} | ||
export declare const retrieveCols: () => number; |
Oops, something went wrong.