Skip to content

Commit

Permalink
Merge branch 'master' into feat/support-webpack-multi-compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 24, 2023
2 parents e2f4783 + 00213cf commit ccccc5e
Show file tree
Hide file tree
Showing 76 changed files with 6,315 additions and 21,296 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
build:
working_directory: ~/nest
docker:
- image: circleci/node:16
- image: cimg/node:19.3
steps:
- checkout
- run:
name: Update NPM version
command: 'sudo npm install -g npm@latest'
command: sudo npm install -g npm@latest
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
Expand All @@ -43,7 +43,7 @@ jobs:
unit_tests:
working_directory: ~/nest
docker:
- image: circleci/node:16
- image: cimg/node:19.3
steps:
- checkout
- *restore-cache
Expand Down
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ module.exports = {
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
'prettier'
],
root: true,
env: {
Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea/
.circleci
.github
.gitignore
.prettierrc
.travis.yml
Expand All @@ -23,6 +25,10 @@ tsconfig.json
tools
/test/jest-config.json
/.vscode
.commitlintrc.json
.eslintrc.js
.eslintignore
.release-it.json

# sample
/sample
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ We would love for you to contribute to Nest and help make it even better than it

To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.

If you would like to chat about the question in real-time, you can reach out via our [gitter](https://gitter.im/nestjs/nest-cli) channel.
If you would like to chat about the question in real-time, you can reach out via [our discord channel][discord].

## <a name="issue"></a> Found a Bug?

Expand Down Expand Up @@ -48,7 +48,7 @@ We want to fix all the issues as soon as possible, but before fixing a bug we ne
- version of NestJS-CLI used (`nest info`)
- and most importantly - a use-case that fails

Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced.
Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that doesn't have enough info to be reproduced.

You can file new issues by filling out our [new issue form](https://github.com/nestjs/nest/issues/new).

Expand Down Expand Up @@ -149,7 +149,7 @@ format that includes a **type**, a **scope** and a **subject**:

The **header** is mandatory and the **scope** of the header is optional.

Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
Any line of the commit message cannot be longer than 100 characters! This allows the message to be easier
to read on GitHub as well as in various git tools.

Footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any.
Expand Down Expand Up @@ -217,7 +217,7 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html
[github]: https://github.com/nestjs/nest
[gitter]: https://gitter.im/nestjs/nest
[discord]: https://discord.gg/nestjs
[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
[jsfiddle]: http://jsfiddle.net
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) 2017-2020
Copyright (c) 2017-2022
Kamil Mysliwiec <https://kamilmysliwiec.com>
Thomas Ricart <thomasr2309@gmail.com>

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
Expand All @@ -14,6 +14,7 @@
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>

## Description
Expand Down
16 changes: 9 additions & 7 deletions actions/add.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import { Input } from '../commands';
import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default';
import {
AbstractPackageManager,
PackageManagerFactory,
PackageManagerFactory
} from '../lib/package-managers';
import {
AbstractCollection,
CollectionFactory,
SchematicOption,
SchematicOption
} from '../lib/schematics';
import { MESSAGES } from '../lib/ui';
import { loadConfiguration } from '../lib/utils/load-configuration';
import {
askForProjectName,
hasValidOptionFlag,
moveDefaultProjectToStart,
shouldAskForProject,
shouldAskForProject
} from '../lib/utils/project-utils';
import { AbstractAction } from './abstract.action';

Expand All @@ -27,7 +28,8 @@ export class AddAction extends AbstractAction {
const packageName = this.getPackageName(libraryName);
const collectionName = this.getCollectionName(libraryName, packageName);
const tagName = this.getTagName(packageName);
const packageInstallSuccess = await this.installPackage(
const skipInstall = hasValidOptionFlag('skip-install', options);
const packageInstallSuccess = skipInstall || await this.installPackage(
collectionName,
tagName,
);
Expand All @@ -44,6 +46,7 @@ export class AddAction extends AbstractAction {
MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName),
),
);
throw new Error(MESSAGES.LIBRARY_INSTALLATION_FAILED_BAD_PACKAGE(libraryName));
}
}

Expand Down Expand Up @@ -128,9 +131,8 @@ export class AddAction extends AbstractAction {
const extraFlagsString = extraFlags ? extraFlags.join(' ') : undefined;

try {
const collection: AbstractCollection = CollectionFactory.create(
collectionName,
);
const collection: AbstractCollection =
CollectionFactory.create(collectionName);
await collection.execute(
schematicName,
schematicOptions,
Expand Down
8 changes: 4 additions & 4 deletions actions/build.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { WebpackCompiler } from '../lib/compiler/webpack-compiler';
import { WorkspaceUtils } from '../lib/compiler/workspace-utils';
import {
ConfigurationLoader,
NestConfigurationLoader,
NestConfigurationLoader
} from '../lib/configuration';
import { defaultOutDir } from '../lib/configuration/defaults';
import { FileSystemReader } from '../lib/readers';
Expand Down Expand Up @@ -62,6 +62,7 @@ export class BuildAction extends AbstractAction {
} else {
console.error(`\n${chalk.red(err)}\n`);
}
process.exit(1);
}
}

Expand All @@ -86,9 +87,8 @@ export class BuildAction extends AbstractAction {
'path',
options,
);
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(
pathToTsconfig,
);
const { options: tsOptions } =
this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
const outDir = tsOptions.outDir || defaultOutDir;
const isWebpackEnabled = getValueOrDefault<boolean>(
configuration,
Expand Down
8 changes: 7 additions & 1 deletion actions/generate.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
askForProjectName,
moveDefaultProjectToStart,
shouldAskForProject,
shouldGenerateFlat,
shouldGenerateSpec,
} from '../lib/utils/project-utils';
import { AbstractAction } from './abstract.action';
Expand All @@ -34,6 +35,7 @@ const generateFiles = async (inputs: Input[]) => {
const appName = inputs.find((option) => option.name === 'project')!
.value as string;
const spec = inputs.find((option) => option.name === 'spec');
const flat = inputs.find((option) => option.name === 'flat');

const collection: AbstractCollection = CollectionFactory.create(
collectionOption || configuration.collection || Collection.NESTJS,
Expand All @@ -49,6 +51,7 @@ const generateFiles = async (inputs: Input[]) => {
: configuration.sourceRoot;

const specValue = spec!.value as boolean;
const flatValue = !!flat as boolean;
const specOptions = spec!.options as any;
let generateSpec = shouldGenerateSpec(
configuration,
Expand All @@ -57,6 +60,7 @@ const generateFiles = async (inputs: Input[]) => {
specValue,
specOptions.passedAsInput,
);
let generateFlat = shouldGenerateFlat(configuration, appName, flatValue);

// If you only add a `lib` we actually don't have monorepo: true BUT we do have "projects"
// Ensure we don't run for new app/libs schematics
Expand Down Expand Up @@ -98,11 +102,13 @@ const generateFiles = async (inputs: Input[]) => {
specValue,
specOptions.passedAsInput,
);
generateFlat = shouldGenerateFlat(configuration, answers.appNames, flatValue);
}
}

schematicOptions.push(new SchematicOption('sourceRoot', sourceRoot));
schematicOptions.push(new SchematicOption('spec', generateSpec));
schematicOptions.push(new SchematicOption('flat', generateFlat));
try {
const schematicInput = inputs.find((input) => input.name === 'schematic');
if (!schematicInput) {
Expand All @@ -117,7 +123,7 @@ const generateFiles = async (inputs: Input[]) => {
};

const mapSchematicOptions = (inputs: Input[]): SchematicOption[] => {
const excludedInputNames = ['schematic', 'spec'];
const excludedInputNames = ['schematic', 'spec', 'flat'];
const options: SchematicOption[] = [];
inputs.forEach((input) => {
if (!excludedInputNames.includes(input.name) && input.value !== undefined) {
Expand Down
1 change: 0 additions & 1 deletion actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export * from './build.action';
export * from './generate.action';
export * from './info.action';
export * from './new.action';
export * from './update.action';
export * from './start.action';
export * from './add.action';
28 changes: 21 additions & 7 deletions actions/info.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ export class InfoAction extends AbstractAction {
async displayPackageManagerVersion() {
try {
const version: string = await this.manager.version();
console.info(`${this.manager.name} Version :`, chalk.blue(version), '\n');
console.info(
`${this.manager.name} Version :`,
chalk.blue(version),
'\n',
);
} catch {
console.error(`${this.manager.name} Version :`, chalk.red('Unknown'), '\n');
console.error(
`${this.manager.name} Version :`,
chalk.red('Unknown'),
'\n',
);
}
}

Expand All @@ -61,7 +69,8 @@ export class InfoAction extends AbstractAction {

async displayNestInformationFromPackage(): Promise<void> {
try {
const dependencies: PackageJsonDependencies = this.readProjectPackageDependencies();
const dependencies: PackageJsonDependencies =
this.readProjectPackageDependencies();
this.displayNestVersions(dependencies);
} catch (err) {
console.error(
Expand All @@ -74,7 +83,10 @@ export class InfoAction extends AbstractAction {
console.info(chalk.green('[Nest CLI]'));
console.info(
'Nest CLI Version :',
chalk.blue(JSON.parse(readFileSync(join(__dirname, '../package.json')).toString()).version),
chalk.blue(
JSON.parse(readFileSync(join(__dirname, '../package.json')).toString())
.version,
),
'\n',
);
}
Expand All @@ -85,8 +97,8 @@ export class InfoAction extends AbstractAction {
const dependencies = { ...pack.dependencies, ...pack.devDependencies };
Object.keys(dependencies).forEach((key) => {
dependencies[key] = {
version: dependencies[key]
}
version: dependencies[key],
};
});
return dependencies;
}
Expand All @@ -110,7 +122,9 @@ export class InfoAction extends AbstractAction {
const nestDependencies: NestDependency[] = [];
Object.keys(dependencies).forEach((key) => {
if (key.indexOf('@nestjs') > -1) {
const depPackagePath = require.resolve(key + '/package.json', { paths: [process.cwd()]});
const depPackagePath = require.resolve(key + '/package.json', {
paths: [process.cwd()],
});
const depPackage = readFileSync(depPackagePath).toString();
const value = JSON.parse(depPackage).version;
nestDependencies.push({
Expand Down

0 comments on commit ccccc5e

Please sign in to comment.