@nx/node 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +66 -0
- package/generators.json +34 -0
- package/index.d.ts +3 -0
- package/index.js +9 -0
- package/migrations.json +48 -0
- package/package.json +44 -0
- package/src/generators/application/application.d.ts +10 -0
- package/src/generators/application/application.js +412 -0
- package/src/generators/application/files/common/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/common/src/main.ts__tmpl__ +1 -0
- package/src/generators/application/files/common/tsconfig.app.json +10 -0
- package/src/generators/application/files/common/tsconfig.json +10 -0
- package/src/generators/application/files/common/webpack.config.js__tmpl__ +35 -0
- package/src/generators/application/files/express/src/main.ts__tmpl__ +14 -0
- package/src/generators/application/files/fastify/src/app/app.spec.ts__tmpl__ +20 -0
- package/src/generators/application/files/fastify/src/app/app.ts__tmpl__ +27 -0
- package/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ +12 -0
- package/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ +7 -0
- package/src/generators/application/files/fastify/src/main.ts__tmpl__ +23 -0
- package/src/generators/application/files/koa/src/main.ts__tmpl__ +14 -0
- package/src/generators/application/schema.d.ts +31 -0
- package/src/generators/application/schema.json +136 -0
- package/src/generators/e2e-project/e2e-project.d.ts +5 -0
- package/src/generators/e2e-project/e2e-project.js +123 -0
- package/src/generators/e2e-project/files/cli/jest.config.ts__tmpl__ +14 -0
- package/src/generators/e2e-project/files/cli/src/__fileName__/__fileName__.spec.ts__tmpl__ +13 -0
- package/src/generators/e2e-project/files/cli/src/test-setup.ts__tmpl__ +1 -0
- package/src/generators/e2e-project/files/cli/tsconfig.json__tmpl__ +13 -0
- package/src/generators/e2e-project/files/cli/tsconfig.spec.json__tmpl__ +12 -0
- package/src/generators/e2e-project/files/server/common/jest.config.ts__tmpl__ +16 -0
- package/src/generators/e2e-project/files/server/common/src/__fileName__/__fileName__.spec.ts__tmpl__ +10 -0
- package/src/generators/e2e-project/files/server/common/src/support/global-setup.ts__tmpl__ +11 -0
- package/src/generators/e2e-project/files/server/common/src/support/global-teardown.ts__tmpl__ +7 -0
- package/src/generators/e2e-project/files/server/common/src/support/test-setup.ts__tmpl__ +10 -0
- package/src/generators/e2e-project/files/server/common/tsconfig.json__tmpl__ +13 -0
- package/src/generators/e2e-project/files/server/common/tsconfig.spec.json__tmpl__ +12 -0
- package/src/generators/e2e-project/files/server/nest/src/__fileName__/__fileName__.spec.ts__tmpl__ +10 -0
- package/src/generators/e2e-project/schema.d.ts +15 -0
- package/src/generators/e2e-project/schema.json +70 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +23 -0
- package/src/generators/init/schema.d.ts +5 -0
- package/src/generators/init/schema.json +27 -0
- package/src/generators/library/files/lib/package.json__tmpl__ +4 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
- package/src/generators/library/files/lib/tsconfig.lib.json +11 -0
- package/src/generators/library/library.d.ts +12 -0
- package/src/generators/library/library.js +141 -0
- package/src/generators/library/schema.d.ts +27 -0
- package/src/generators/library/schema.json +136 -0
- package/src/generators/setup-docker/files/Dockerfile__tmpl__ +24 -0
- package/src/generators/setup-docker/schema.d.ts +6 -0
- package/src/generators/setup-docker/schema.json +29 -0
- package/src/generators/setup-docker/setup-docker.d.ts +5 -0
- package/src/generators/setup-docker/setup-docker.js +53 -0
- package/src/migrations/update-16-0-0/update-webpack-executor.d.ts +2 -0
- package/src/migrations/update-16-0-0/update-webpack-executor.js +17 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-3-1/update-webpack-executor.d.ts +2 -0
- package/src/migrations/update-16-3-1/update-webpack-executor.js +17 -0
- package/src/migrations/update-16-4-0/replace-node-executor.d.ts +2 -0
- package/src/migrations/update-16-4-0/replace-node-executor.js +14 -0
- package/src/utils/has-webpack-plugin.d.ts +2 -0
- package/src/utils/has-webpack-plugin.js +11 -0
- package/src/utils/versions.d.ts +12 -0
- package/src/utils/versions.js +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2023 Narwhal Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<div style="text-align: center;">
|
|
9
|
+
|
|
10
|
+
[](https://circleci.com/gh/nrwl/nx)
|
|
11
|
+
[]()
|
|
12
|
+
[](https://www.npmjs.com/@nx/workspace)
|
|
13
|
+
[]()
|
|
14
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
+
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
|
+
[](https://go.nx.dev/community)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<hr>
|
|
22
|
+
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
24
|
+
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
26
|
+
|
|
27
|
+
## Getting Started
|
|
28
|
+
|
|
29
|
+
### Creating an Nx Workspace
|
|
30
|
+
|
|
31
|
+
**Using `npx`**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx create-nx-workspace
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Using `npm init`**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm init nx-workspace
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Using `yarn create`**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn create nx-workspace
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Adding Nx to an Existing Repository
|
|
50
|
+
|
|
51
|
+
Run:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx nx@latest init
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Documentation & Resources
|
|
58
|
+
|
|
59
|
+
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
60
|
+
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
61
|
+
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
62
|
+
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
63
|
+
|
|
64
|
+
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
65
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
66
|
+
|
package/generators.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nx/node",
|
|
3
|
+
"version": "0.1",
|
|
4
|
+
"extends": ["@nx/workspace"],
|
|
5
|
+
"generators": {
|
|
6
|
+
"init": {
|
|
7
|
+
"factory": "./src/generators/init/init",
|
|
8
|
+
"schema": "./src/generators/init/schema.json",
|
|
9
|
+
"description": "Initialize the `@nrwl/node` plugin.",
|
|
10
|
+
"aliases": ["ng-add"],
|
|
11
|
+
"hidden": true
|
|
12
|
+
},
|
|
13
|
+
"application": {
|
|
14
|
+
"factory": "./src/generators/application/application#applicationGeneratorInternal",
|
|
15
|
+
"schema": "./src/generators/application/schema.json",
|
|
16
|
+
"aliases": ["app"],
|
|
17
|
+
"x-type": "application",
|
|
18
|
+
"description": "Create a node application."
|
|
19
|
+
},
|
|
20
|
+
"library": {
|
|
21
|
+
"factory": "./src/generators/library/library#libraryGeneratorInternal",
|
|
22
|
+
"schema": "./src/generators/library/schema.json",
|
|
23
|
+
"aliases": ["lib"],
|
|
24
|
+
"x-type": "library",
|
|
25
|
+
"description": "Create a node library."
|
|
26
|
+
},
|
|
27
|
+
"setup-docker": {
|
|
28
|
+
"factory": "./src/generators/setup-docker/setup-docker",
|
|
29
|
+
"schema": "./src/generators/setup-docker/schema.json",
|
|
30
|
+
"description": "Set up Docker configuration for a project.",
|
|
31
|
+
"hidden": false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initGenerator = exports.libraryGenerator = exports.applicationGenerator = void 0;
|
|
4
|
+
var application_1 = require("./src/generators/application/application");
|
|
5
|
+
Object.defineProperty(exports, "applicationGenerator", { enumerable: true, get: function () { return application_1.applicationGenerator; } });
|
|
6
|
+
var library_1 = require("./src/generators/library/library");
|
|
7
|
+
Object.defineProperty(exports, "libraryGenerator", { enumerable: true, get: function () { return library_1.libraryGenerator; } });
|
|
8
|
+
var init_1 = require("./src/generators/init/init");
|
|
9
|
+
Object.defineProperty(exports, "initGenerator", { enumerable: true, get: function () { return init_1.initGenerator; } });
|
package/migrations.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"update-16-0-0-add-nx-packages": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "16.0.0-beta.1",
|
|
6
|
+
"description": "Replace @nrwl/node with @nx/node",
|
|
7
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
+
},
|
|
9
|
+
"update-16-0-0-update-executor": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "16.0.0-beta.5",
|
|
12
|
+
"description": "Replace @nrwl/node:webpack with @nx/node:webpack",
|
|
13
|
+
"implementation": "./src/migrations/update-16-0-0/update-webpack-executor"
|
|
14
|
+
},
|
|
15
|
+
"update-16-3-1-update-executor": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "16.3.1-beta.0",
|
|
18
|
+
"description": "Replace @nrwl/node:webpack and @nx/node:webpack with @nx/webpack:webpack for all project targets",
|
|
19
|
+
"implementation": "./src/migrations/update-16-3-1/update-webpack-executor"
|
|
20
|
+
},
|
|
21
|
+
"update-16-4-0-replace-node-executor": {
|
|
22
|
+
"cli": "nx",
|
|
23
|
+
"version": "16.4.0-beta.8",
|
|
24
|
+
"description": "Replace @nx/node:node with @nx/js:node for all project targets",
|
|
25
|
+
"implementation": "./src/migrations/update-16-4-0/replace-node-executor"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"packageJsonUpdates": {
|
|
29
|
+
"17.3.0": {
|
|
30
|
+
"version": "17.3.0-beta.3",
|
|
31
|
+
"packages": {
|
|
32
|
+
"@types/node": {
|
|
33
|
+
"version": "18.16.9",
|
|
34
|
+
"alwaysAddToPackageJson": false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"17.3.1": {
|
|
39
|
+
"version": "17.3.1-beta.0",
|
|
40
|
+
"packages": {
|
|
41
|
+
"axios": {
|
|
42
|
+
"version": "^1.6.0",
|
|
43
|
+
"alwaysAddToPackageJson": false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx/node",
|
|
3
|
+
"version": "0.0.0-pr-22179-271588f",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nrwl/nx.git",
|
|
9
|
+
"directory": "packages/node"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Monorepo",
|
|
13
|
+
"Node",
|
|
14
|
+
"Nest",
|
|
15
|
+
"Jest",
|
|
16
|
+
"Cypress",
|
|
17
|
+
"CLI"
|
|
18
|
+
],
|
|
19
|
+
"main": "./index.js",
|
|
20
|
+
"typings": "./index.d.ts",
|
|
21
|
+
"author": "Victor Savkin",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/nrwl/nx/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://nx.dev",
|
|
27
|
+
"generators": "./generators.json",
|
|
28
|
+
"ng-update": {
|
|
29
|
+
"requirements": {},
|
|
30
|
+
"migrations": "./migrations.json"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"tslib": "^2.3.0",
|
|
34
|
+
"@nx/devkit": "0.0.0-pr-22179-271588f",
|
|
35
|
+
"@nx/jest": "0.0.0-pr-22179-271588f",
|
|
36
|
+
"@nx/js": "0.0.0-pr-22179-271588f",
|
|
37
|
+
"@nx/eslint": "0.0.0-pr-22179-271588f",
|
|
38
|
+
"@nrwl/node": "0.0.0-pr-22179-271588f"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"type": "commonjs"
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export interface NormalizedSchema extends Schema {
|
|
4
|
+
appProjectRoot: string;
|
|
5
|
+
parsedTags: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
8
|
+
export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
9
|
+
export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
10
|
+
export default applicationGenerator;
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applicationGeneratorInternal = exports.applicationGenerator = exports.addLintingToApplication = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
+
const jest_1 = require("@nx/jest");
|
|
7
|
+
const js_1 = require("@nx/js");
|
|
8
|
+
const versions_1 = require("@nx/js/src/utils/versions");
|
|
9
|
+
const eslint_1 = require("@nx/eslint");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const versions_2 = require("../../utils/versions");
|
|
12
|
+
const e2e_project_1 = require("../e2e-project/e2e-project");
|
|
13
|
+
const init_1 = require("../init/init");
|
|
14
|
+
const setup_docker_1 = require("../setup-docker/setup-docker");
|
|
15
|
+
const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
|
|
16
|
+
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
17
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
18
|
+
function getWebpackBuildConfig(project, options) {
|
|
19
|
+
return {
|
|
20
|
+
executor: `@nx/webpack:webpack`,
|
|
21
|
+
outputs: ['{options.outputPath}'],
|
|
22
|
+
defaultConfiguration: 'production',
|
|
23
|
+
options: {
|
|
24
|
+
target: 'node',
|
|
25
|
+
compiler: 'tsc',
|
|
26
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : options.appProjectRoot),
|
|
27
|
+
main: (0, devkit_1.joinPathFragments)(project.sourceRoot, 'main' + (options.js ? '.js' : '.ts')),
|
|
28
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
29
|
+
assets: [(0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets')],
|
|
30
|
+
webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
|
|
31
|
+
},
|
|
32
|
+
configurations: {
|
|
33
|
+
development: {},
|
|
34
|
+
production: {
|
|
35
|
+
...(options.docker && { generateLockfile: true }),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function getEsBuildConfig(project, options) {
|
|
41
|
+
return {
|
|
42
|
+
executor: '@nx/esbuild:esbuild',
|
|
43
|
+
outputs: ['{options.outputPath}'],
|
|
44
|
+
defaultConfiguration: 'production',
|
|
45
|
+
options: {
|
|
46
|
+
platform: 'node',
|
|
47
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : options.appProjectRoot),
|
|
48
|
+
// Use CJS for Node apps for widest compatibility.
|
|
49
|
+
format: ['cjs'],
|
|
50
|
+
bundle: false,
|
|
51
|
+
main: (0, devkit_1.joinPathFragments)(project.sourceRoot, 'main' + (options.js ? '.js' : '.ts')),
|
|
52
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
53
|
+
assets: [(0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets')],
|
|
54
|
+
generatePackageJson: true,
|
|
55
|
+
esbuildOptions: {
|
|
56
|
+
sourcemap: true,
|
|
57
|
+
// Generate CJS files as .js so imports can be './foo' rather than './foo.cjs'.
|
|
58
|
+
outExtension: { '.js': '.js' },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
configurations: {
|
|
62
|
+
development: {},
|
|
63
|
+
production: {
|
|
64
|
+
...(options.docker && { generateLockfile: true }),
|
|
65
|
+
esbuildOptions: {
|
|
66
|
+
sourcemap: false,
|
|
67
|
+
// Generate CJS files as .js so imports can be './foo' rather than './foo.cjs'.
|
|
68
|
+
outExtension: { '.js': '.js' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function getServeConfig(options) {
|
|
75
|
+
return {
|
|
76
|
+
executor: '@nx/js:node',
|
|
77
|
+
defaultConfiguration: 'development',
|
|
78
|
+
options: {
|
|
79
|
+
buildTarget: `${options.name}:build`,
|
|
80
|
+
},
|
|
81
|
+
configurations: {
|
|
82
|
+
development: {
|
|
83
|
+
buildTarget: `${options.name}:build:development`,
|
|
84
|
+
},
|
|
85
|
+
production: {
|
|
86
|
+
buildTarget: `${options.name}:build:production`,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function addProject(tree, options) {
|
|
92
|
+
const project = {
|
|
93
|
+
root: options.appProjectRoot,
|
|
94
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src'),
|
|
95
|
+
projectType: 'application',
|
|
96
|
+
targets: {},
|
|
97
|
+
tags: options.parsedTags,
|
|
98
|
+
};
|
|
99
|
+
if (options.bundler === 'esbuild') {
|
|
100
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, '@nx/esbuild:esbuild');
|
|
101
|
+
project.targets.build = getEsBuildConfig(project, options);
|
|
102
|
+
}
|
|
103
|
+
else if (options.bundler === 'webpack') {
|
|
104
|
+
if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) {
|
|
105
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, `@nx/webpack:webpack`);
|
|
106
|
+
project.targets.build = getWebpackBuildConfig(project, options);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
project.targets.serve = getServeConfig(options);
|
|
110
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
111
|
+
}
|
|
112
|
+
function addAppFiles(tree, options) {
|
|
113
|
+
const sourceRoot = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src');
|
|
114
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
115
|
+
...options,
|
|
116
|
+
tmpl: '',
|
|
117
|
+
name: options.name,
|
|
118
|
+
root: options.appProjectRoot,
|
|
119
|
+
offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
120
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
121
|
+
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
|
|
122
|
+
? {
|
|
123
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : options.appProjectRoot),
|
|
124
|
+
main: './src/main' + (options.js ? '.js' : '.ts'),
|
|
125
|
+
tsConfig: './tsconfig.app.json',
|
|
126
|
+
assets: ['./src/assets'],
|
|
127
|
+
}
|
|
128
|
+
: null,
|
|
129
|
+
});
|
|
130
|
+
if (options.bundler !== 'webpack') {
|
|
131
|
+
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'));
|
|
132
|
+
}
|
|
133
|
+
if (options.framework && options.framework !== 'none') {
|
|
134
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, `./files/${options.framework}`), options.appProjectRoot, {
|
|
135
|
+
...options,
|
|
136
|
+
tmpl: '',
|
|
137
|
+
name: options.name,
|
|
138
|
+
root: options.appProjectRoot,
|
|
139
|
+
offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
140
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (options.js) {
|
|
144
|
+
(0, devkit_1.toJS)(tree);
|
|
145
|
+
}
|
|
146
|
+
if (options.pascalCaseFiles) {
|
|
147
|
+
devkit_1.logger.warn('NOTE: --pascalCaseFiles is a noop');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function addProxy(tree, options) {
|
|
151
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.frontendProject);
|
|
152
|
+
if (projectConfig.targets && projectConfig.targets.serve) {
|
|
153
|
+
const pathToProxyFile = `${projectConfig.root}/proxy.conf.json`;
|
|
154
|
+
projectConfig.targets.serve.options = {
|
|
155
|
+
...projectConfig.targets.serve.options,
|
|
156
|
+
proxyConfig: pathToProxyFile,
|
|
157
|
+
};
|
|
158
|
+
if (!tree.exists(pathToProxyFile)) {
|
|
159
|
+
tree.write(pathToProxyFile, JSON.stringify({
|
|
160
|
+
'/api': {
|
|
161
|
+
target: `http://localhost:${options.port}`,
|
|
162
|
+
secure: false,
|
|
163
|
+
},
|
|
164
|
+
}, null, 2));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
//add new entry to existing config
|
|
168
|
+
const proxyFileContent = tree.read(pathToProxyFile).toString();
|
|
169
|
+
const proxyModified = {
|
|
170
|
+
...JSON.parse(proxyFileContent),
|
|
171
|
+
[`/${options.name}-api`]: {
|
|
172
|
+
target: `http://localhost:${options.port}`,
|
|
173
|
+
secure: false,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
tree.write(pathToProxyFile, JSON.stringify(proxyModified, null, 2));
|
|
177
|
+
}
|
|
178
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.frontendProject, projectConfig);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function addLintingToApplication(tree, options) {
|
|
182
|
+
const lintTask = await (0, eslint_1.lintProjectGenerator)(tree, {
|
|
183
|
+
linter: options.linter,
|
|
184
|
+
project: options.name,
|
|
185
|
+
tsConfigPaths: [
|
|
186
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
187
|
+
],
|
|
188
|
+
unitTestRunner: options.unitTestRunner,
|
|
189
|
+
skipFormat: true,
|
|
190
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
191
|
+
rootProject: options.rootProject,
|
|
192
|
+
addPlugin: options.addPlugin,
|
|
193
|
+
});
|
|
194
|
+
return lintTask;
|
|
195
|
+
}
|
|
196
|
+
exports.addLintingToApplication = addLintingToApplication;
|
|
197
|
+
function addProjectDependencies(tree, options) {
|
|
198
|
+
const bundlers = {
|
|
199
|
+
webpack: {
|
|
200
|
+
'@nx/webpack': versions_2.nxVersion,
|
|
201
|
+
},
|
|
202
|
+
esbuild: {
|
|
203
|
+
'@nx/esbuild': versions_2.nxVersion,
|
|
204
|
+
esbuild: versions_1.esbuildVersion,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
const frameworkDependencies = {
|
|
208
|
+
express: {
|
|
209
|
+
express: versions_2.expressVersion,
|
|
210
|
+
},
|
|
211
|
+
koa: {
|
|
212
|
+
koa: versions_2.koaVersion,
|
|
213
|
+
},
|
|
214
|
+
fastify: {
|
|
215
|
+
fastify: versions_2.fastifyVersion,
|
|
216
|
+
'fastify-plugin': versions_2.fastifyPluginVersion,
|
|
217
|
+
'@fastify/autoload': versions_2.fastifyAutoloadVersion,
|
|
218
|
+
'@fastify/sensible': versions_2.fastifySensibleVersion,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
const frameworkDevDependencies = {
|
|
222
|
+
express: {
|
|
223
|
+
'@types/express': versions_2.expressTypingsVersion,
|
|
224
|
+
},
|
|
225
|
+
koa: {
|
|
226
|
+
'@types/koa': versions_2.koaTypingsVersion,
|
|
227
|
+
},
|
|
228
|
+
fastify: {},
|
|
229
|
+
};
|
|
230
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
231
|
+
...frameworkDependencies[options.framework],
|
|
232
|
+
tslib: versions_2.tslibVersion,
|
|
233
|
+
}, {
|
|
234
|
+
...frameworkDevDependencies[options.framework],
|
|
235
|
+
...bundlers[options.bundler],
|
|
236
|
+
'@types/node': versions_2.typesNodeVersion,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function updateTsConfigOptions(tree, options) {
|
|
240
|
+
(0, devkit_1.updateJson)(tree, `${options.appProjectRoot}/tsconfig.json`, (json) => {
|
|
241
|
+
if (options.rootProject) {
|
|
242
|
+
return {
|
|
243
|
+
compilerOptions: {
|
|
244
|
+
...js_1.tsConfigBaseOptions,
|
|
245
|
+
...json.compilerOptions,
|
|
246
|
+
esModuleInterop: true,
|
|
247
|
+
},
|
|
248
|
+
...json,
|
|
249
|
+
extends: undefined,
|
|
250
|
+
exclude: ['node_modules', 'tmp'],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
return {
|
|
255
|
+
...json,
|
|
256
|
+
compilerOptions: {
|
|
257
|
+
...json.compilerOptions,
|
|
258
|
+
esModuleInterop: true,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
async function applicationGenerator(tree, schema) {
|
|
265
|
+
return await applicationGeneratorInternal(tree, {
|
|
266
|
+
addPlugin: false,
|
|
267
|
+
projectNameAndRootFormat: 'derived',
|
|
268
|
+
...schema,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
exports.applicationGenerator = applicationGenerator;
|
|
272
|
+
async function applicationGeneratorInternal(tree, schema) {
|
|
273
|
+
const options = await normalizeOptions(tree, schema);
|
|
274
|
+
const tasks = [];
|
|
275
|
+
if (options.framework === 'nest') {
|
|
276
|
+
// nx-ignore-next-line
|
|
277
|
+
const { applicationGenerator } = (0, devkit_1.ensurePackage)('@nx/nest', versions_2.nxVersion);
|
|
278
|
+
const nestTasks = await applicationGenerator(tree, {
|
|
279
|
+
...options,
|
|
280
|
+
skipFormat: true,
|
|
281
|
+
});
|
|
282
|
+
return (0, devkit_1.runTasksInSerial)(...[
|
|
283
|
+
nestTasks,
|
|
284
|
+
() => {
|
|
285
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
286
|
+
},
|
|
287
|
+
]);
|
|
288
|
+
}
|
|
289
|
+
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
290
|
+
...schema,
|
|
291
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
292
|
+
skipFormat: true,
|
|
293
|
+
});
|
|
294
|
+
tasks.push(jsInitTask);
|
|
295
|
+
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
296
|
+
...schema,
|
|
297
|
+
skipFormat: true,
|
|
298
|
+
});
|
|
299
|
+
tasks.push(initTask);
|
|
300
|
+
const installTask = addProjectDependencies(tree, options);
|
|
301
|
+
tasks.push(installTask);
|
|
302
|
+
if (options.bundler === 'webpack') {
|
|
303
|
+
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_2.nxVersion);
|
|
304
|
+
const webpackInitTask = await webpackInitGenerator(tree, {
|
|
305
|
+
skipPackageJson: options.skipPackageJson,
|
|
306
|
+
skipFormat: true,
|
|
307
|
+
addPlugin: options.addPlugin,
|
|
308
|
+
});
|
|
309
|
+
tasks.push(webpackInitTask);
|
|
310
|
+
if (!options.skipPackageJson) {
|
|
311
|
+
const { ensureDependencies } = await Promise.resolve().then(() => require('@nx/webpack/src/utils/ensure-dependencies'));
|
|
312
|
+
tasks.push(ensureDependencies(tree, {
|
|
313
|
+
uiFramework: options.isNest ? 'none' : 'react',
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
addAppFiles(tree, options);
|
|
318
|
+
addProject(tree, options);
|
|
319
|
+
updateTsConfigOptions(tree, options);
|
|
320
|
+
if (options.linter === eslint_1.Linter.EsLint) {
|
|
321
|
+
const lintTask = await addLintingToApplication(tree, options);
|
|
322
|
+
tasks.push(lintTask);
|
|
323
|
+
}
|
|
324
|
+
if (options.unitTestRunner === 'jest') {
|
|
325
|
+
const jestTask = await (0, jest_1.configurationGenerator)(tree, {
|
|
326
|
+
...options,
|
|
327
|
+
project: options.name,
|
|
328
|
+
setupFile: 'none',
|
|
329
|
+
skipSerializers: true,
|
|
330
|
+
supportTsx: options.js,
|
|
331
|
+
testEnvironment: 'node',
|
|
332
|
+
compiler: options.swcJest ? 'swc' : 'tsc',
|
|
333
|
+
skipFormat: true,
|
|
334
|
+
});
|
|
335
|
+
tasks.push(jestTask);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
// No need for default spec file if unit testing is not setup.
|
|
339
|
+
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/app/app.spec.ts'));
|
|
340
|
+
}
|
|
341
|
+
if (options.e2eTestRunner === 'jest') {
|
|
342
|
+
const e2eTask = await (0, e2e_project_1.e2eProjectGenerator)(tree, {
|
|
343
|
+
...options,
|
|
344
|
+
projectType: options.framework === 'none' ? 'cli' : 'server',
|
|
345
|
+
name: options.rootProject ? 'e2e' : `${options.name}-e2e`,
|
|
346
|
+
directory: options.rootProject ? 'e2e' : `${options.appProjectRoot}-e2e`,
|
|
347
|
+
projectNameAndRootFormat: 'as-provided',
|
|
348
|
+
project: options.name,
|
|
349
|
+
port: options.port,
|
|
350
|
+
isNest: options.isNest,
|
|
351
|
+
skipFormat: true,
|
|
352
|
+
});
|
|
353
|
+
tasks.push(e2eTask);
|
|
354
|
+
}
|
|
355
|
+
if (options.js) {
|
|
356
|
+
(0, devkit_1.updateTsConfigsToJs)(tree, { projectRoot: options.appProjectRoot });
|
|
357
|
+
}
|
|
358
|
+
if (options.frontendProject) {
|
|
359
|
+
addProxy(tree, options);
|
|
360
|
+
}
|
|
361
|
+
if (options.docker) {
|
|
362
|
+
const dockerTask = await (0, setup_docker_1.setupDockerGenerator)(tree, {
|
|
363
|
+
...options,
|
|
364
|
+
project: options.name,
|
|
365
|
+
skipFormat: true,
|
|
366
|
+
});
|
|
367
|
+
tasks.push(dockerTask);
|
|
368
|
+
}
|
|
369
|
+
if (!options.skipFormat) {
|
|
370
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
371
|
+
}
|
|
372
|
+
tasks.push(() => {
|
|
373
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
374
|
+
});
|
|
375
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
376
|
+
}
|
|
377
|
+
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
378
|
+
async function normalizeOptions(host, options) {
|
|
379
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
380
|
+
name: options.name,
|
|
381
|
+
projectType: 'application',
|
|
382
|
+
directory: options.directory,
|
|
383
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
384
|
+
rootProject: options.rootProject,
|
|
385
|
+
callingGenerator: '@nx/node:application',
|
|
386
|
+
});
|
|
387
|
+
options.rootProject = appProjectRoot === '.';
|
|
388
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
389
|
+
options.bundler = options.bundler ?? 'esbuild';
|
|
390
|
+
options.e2eTestRunner = options.e2eTestRunner ?? 'jest';
|
|
391
|
+
const parsedTags = options.tags
|
|
392
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
393
|
+
: [];
|
|
394
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
395
|
+
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
396
|
+
nxJson.useInferencePlugins !== false;
|
|
397
|
+
return {
|
|
398
|
+
addPlugin,
|
|
399
|
+
...options,
|
|
400
|
+
name: appProjectName,
|
|
401
|
+
frontendProject: options.frontendProject
|
|
402
|
+
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
403
|
+
: undefined,
|
|
404
|
+
appProjectRoot,
|
|
405
|
+
parsedTags,
|
|
406
|
+
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
407
|
+
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
408
|
+
rootProject: options.rootProject ?? false,
|
|
409
|
+
port: options.port ?? 3000,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
exports.default = applicationGenerator;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('Hello World');
|