@nx/express 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 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,68 @@
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
+ [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
+ [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
+ [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
+ [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](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
+ This package is an [Express plugin for Nx](https://nx.dev/express/overview).
28
+
29
+ ## Getting Started
30
+
31
+ ### Creating an Nx Workspace
32
+
33
+ **Using `npx`**
34
+
35
+ ```bash
36
+ npx create-nx-workspace
37
+ ```
38
+
39
+ **Using `npm init`**
40
+
41
+ ```bash
42
+ npm init nx-workspace
43
+ ```
44
+
45
+ **Using `yarn create`**
46
+
47
+ ```bash
48
+ yarn create nx-workspace
49
+ ```
50
+
51
+ ### Adding Nx to an Existing Repository
52
+
53
+ Run:
54
+
55
+ ```bash
56
+ npx nx@latest init
57
+ ```
58
+
59
+ ## Documentation & Resources
60
+
61
+ - [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
62
+ - [Intro to Nx](https://nx.dev/getting-started/intro)
63
+ - [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
64
+ - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
65
+
66
+ <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"
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
68
+
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "Nx Express",
3
+ "version": "0.1",
4
+ "extends": ["@nx/workspace"],
5
+ "generators": {
6
+ "init": {
7
+ "factory": "./src/generators/init/init#initGenerator",
8
+ "schema": "./src/generators/init/schema.json",
9
+ "description": "Initialize the `@nrwl/express` 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 an Express application."
19
+ }
20
+ }
21
+ }
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { applicationGenerator } from './src/generators/application/application';
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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; } });
@@ -0,0 +1,11 @@
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/express with @nx/express",
7
+ "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
+ }
9
+ },
10
+ "packageJsonUpdates": {}
11
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@nx/express",
3
+ "version": "0.0.0-pr-22179-271588f",
4
+ "private": false,
5
+ "description": "The Nx Plugin for Express contains executors and generators for allowing your workspace to create powerful Express Node applications and APIs.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nrwl/nx.git",
9
+ "directory": "packages/express"
10
+ },
11
+ "keywords": [
12
+ "Monorepo",
13
+ "Node",
14
+ "Express",
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
+ "@nx/devkit": "0.0.0-pr-22179-271588f",
34
+ "@nx/node": "0.0.0-pr-22179-271588f",
35
+ "tslib": "^2.3.0",
36
+ "@nrwl/express": "0.0.0-pr-22179-271588f"
37
+ },
38
+ "peerDependencies": {
39
+ "express": "^4.18.1"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "express": {
43
+ "optional": true
44
+ }
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "type": "commonjs"
50
+ }
@@ -0,0 +1,5 @@
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import type { Schema } from './schema';
3
+ export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
5
+ export default applicationGenerator;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applicationGeneratorInternal = exports.applicationGenerator = 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 node_1 = require("@nx/node");
7
+ const versions_1 = require("@nx/node/src/utils/versions");
8
+ const path_1 = require("path");
9
+ const versions_2 = require("../../utils/versions");
10
+ const init_1 = require("../init/init");
11
+ function addTypes(tree, options) {
12
+ (0, devkit_1.updateJson)(tree, (0, path_1.join)(options.appProjectRoot, 'tsconfig.app.json'), (json) => {
13
+ json.compilerOptions.types = [...json.compilerOptions.types, 'express'];
14
+ return json;
15
+ });
16
+ }
17
+ function addMainFile(tree, options) {
18
+ tree.write((0, path_1.join)(options.appProjectRoot, `src/main.${options.js ? 'js' : 'ts'}`), `/**
19
+ * This is not a production server yet!
20
+ * This is only a minimal backend to get started.
21
+ */
22
+
23
+ import express from 'express';
24
+ import * as path from 'path';
25
+
26
+ const app = express();
27
+
28
+ app.use('/assets', express.static(path.join(__dirname, 'assets')));
29
+
30
+ app.get('/api', (req, res) => {
31
+ res.send({ message: 'Welcome to ${options.appProjectName}!' });
32
+ });
33
+
34
+ const port = process.env.PORT || 3333;
35
+ const server = app.listen(port, () => {
36
+ console.log(\`Listening at http://localhost:\${port}/api\`);
37
+ });
38
+ server.on('error', console.error);
39
+ `);
40
+ if (options.js) {
41
+ (0, devkit_1.toJS)(tree);
42
+ }
43
+ }
44
+ async function applicationGenerator(tree, schema) {
45
+ return await applicationGeneratorInternal(tree, {
46
+ addPlugin: false,
47
+ projectNameAndRootFormat: 'derived',
48
+ ...schema,
49
+ });
50
+ }
51
+ exports.applicationGenerator = applicationGenerator;
52
+ async function applicationGeneratorInternal(tree, schema) {
53
+ const options = await normalizeOptions(tree, schema);
54
+ const tasks = [];
55
+ const initTask = await (0, init_1.initGenerator)(tree, { ...options, skipFormat: true });
56
+ tasks.push(initTask);
57
+ const applicationTask = await (0, node_1.applicationGenerator)(tree, {
58
+ ...options,
59
+ bundler: 'webpack',
60
+ skipFormat: true,
61
+ });
62
+ tasks.push(applicationTask);
63
+ addMainFile(tree, options);
64
+ addTypes(tree, options);
65
+ if (!options.skipPackageJson) {
66
+ tasks.push(ensureDependencies(tree));
67
+ }
68
+ if (!options.skipFormat) {
69
+ await (0, devkit_1.formatFiles)(tree);
70
+ }
71
+ return (0, devkit_1.runTasksInSerial)(...tasks);
72
+ }
73
+ exports.applicationGeneratorInternal = applicationGeneratorInternal;
74
+ exports.default = applicationGenerator;
75
+ async function normalizeOptions(host, options) {
76
+ const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
77
+ name: options.name,
78
+ projectType: 'application',
79
+ directory: options.directory,
80
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
81
+ callingGenerator: '@nx/express:application',
82
+ });
83
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
84
+ const nxJson = (0, devkit_1.readNxJson)(host);
85
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
86
+ nxJson.useInferencePlugins !== false;
87
+ options.addPlugin ??= addPlugin;
88
+ return {
89
+ ...options,
90
+ appProjectName,
91
+ appProjectRoot,
92
+ };
93
+ }
94
+ function ensureDependencies(tree) {
95
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, { tslib: versions_1.tslibVersion }, { '@nx/express': versions_2.nxVersion });
96
+ }
@@ -0,0 +1,23 @@
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/eslint';
3
+ import type { UnitTestRunner } from '../../utils/test-runners';
4
+
5
+ export interface Schema {
6
+ name: string;
7
+ skipFormat: boolean;
8
+ skipPackageJson: boolean;
9
+ directory?: string;
10
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
+ unitTestRunner: UnitTestRunner;
12
+ tags?: string;
13
+ linter: Linter;
14
+ frontendProject?: string;
15
+ swcJest?: boolean;
16
+ /** @deprecated use `swcJest` instead */
17
+ babelJest?: boolean;
18
+ js: boolean;
19
+ pascalCaseFiles: boolean;
20
+ standaloneConfig?: boolean;
21
+ setParserOptionsProject?: boolean;
22
+ addPlugin?: boolean;
23
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "SchematicsNxExpressApp",
5
+ "title": "Nx Application Options Schema",
6
+ "description": "Nx Application Options Schema.",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "description": "The name of the application.",
11
+ "type": "string",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What name would you like to use for the node application?",
17
+ "pattern": "^[a-zA-Z][^:]*$"
18
+ },
19
+ "directory": {
20
+ "description": "The directory of the new application.",
21
+ "type": "string"
22
+ },
23
+ "projectNameAndRootFormat": {
24
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
25
+ "type": "string",
26
+ "enum": ["as-provided", "derived"]
27
+ },
28
+ "skipFormat": {
29
+ "description": "Skip formatting files.",
30
+ "type": "boolean",
31
+ "default": false
32
+ },
33
+ "skipPackageJson": {
34
+ "type": "boolean",
35
+ "default": false,
36
+ "description": "Do not add dependencies to `package.json`."
37
+ },
38
+ "linter": {
39
+ "description": "The tool to use for running lint checks.",
40
+ "type": "string",
41
+ "enum": ["eslint"],
42
+ "default": "eslint"
43
+ },
44
+ "unitTestRunner": {
45
+ "type": "string",
46
+ "enum": ["jest", "none"],
47
+ "description": "Test runner to use for unit tests.",
48
+ "default": "jest"
49
+ },
50
+ "tags": {
51
+ "type": "string",
52
+ "description": "Add tags to the application (used for linting)."
53
+ },
54
+ "frontendProject": {
55
+ "type": "string",
56
+ "description": "Frontend project that needs to access this application. This sets up proxy configuration."
57
+ },
58
+ "swcJest": {
59
+ "type": "boolean",
60
+ "description": "Use `@swc/jest` instead `ts-jest` for faster test compilation.",
61
+ "default": false
62
+ },
63
+ "babelJest": {
64
+ "type": "boolean",
65
+ "description": "Use `babel` instead `ts-jest`.",
66
+ "default": false,
67
+ "x-deprecated": "Use --swcJest instead for faster compilation"
68
+ },
69
+ "pascalCaseFiles": {
70
+ "type": "boolean",
71
+ "description": "Use pascal case file names.",
72
+ "alias": "P",
73
+ "default": false
74
+ },
75
+ "js": {
76
+ "type": "boolean",
77
+ "description": "Generate JavaScript files rather than TypeScript files.",
78
+ "default": false
79
+ },
80
+ "standaloneConfig": {
81
+ "description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
82
+ "type": "boolean",
83
+ "default": true,
84
+ "x-deprecated": "Nx only supports standaloneConfig"
85
+ },
86
+ "setParserOptionsProject": {
87
+ "type": "boolean",
88
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
89
+ "default": false
90
+ }
91
+ },
92
+ "required": []
93
+ }
@@ -0,0 +1,4 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import type { Schema } from './schema';
3
+ export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export default initGenerator;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ function updateDependencies(tree, schema) {
7
+ const tasks = [];
8
+ tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/express'], []));
9
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, { express: versions_1.expressVersion }, { '@nx/express': versions_1.nxVersion }, undefined, schema.keepExistingVersions));
10
+ return (0, devkit_1.runTasksInSerial)(...tasks);
11
+ }
12
+ async function initGenerator(tree, schema) {
13
+ let installTask = () => { };
14
+ if (!schema.skipPackageJson) {
15
+ installTask = updateDependencies(tree, schema);
16
+ }
17
+ if (!schema.skipFormat) {
18
+ await (0, devkit_1.formatFiles)(tree);
19
+ }
20
+ return installTask;
21
+ }
22
+ exports.initGenerator = initGenerator;
23
+ exports.default = initGenerator;
@@ -0,0 +1,5 @@
1
+ export interface Schema {
2
+ skipFormat?: boolean;
3
+ skipPackageJson?: boolean;
4
+ keepExistingVersions?: boolean;
5
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxExpressInit",
5
+ "title": "Init Express Plugin",
6
+ "description": "Init Express Plugin.",
7
+ "type": "object",
8
+ "properties": {
9
+ "skipFormat": {
10
+ "description": "Skip formatting files.",
11
+ "type": "boolean",
12
+ "default": false
13
+ },
14
+ "skipPackageJson": {
15
+ "type": "boolean",
16
+ "default": false,
17
+ "description": "Do not add dependencies to `package.json`."
18
+ },
19
+ "keepExistingVersions": {
20
+ "type": "boolean",
21
+ "x-priority": "internal",
22
+ "description": "Keep existing dependencies versions",
23
+ "default": false
24
+ }
25
+ },
26
+ "required": []
27
+ }
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function replacePackage(tree: Tree): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
5
+ async function replacePackage(tree) {
6
+ await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/express', '@nx/express');
7
+ await (0, devkit_1.formatFiles)(tree);
8
+ }
9
+ exports.default = replacePackage;
@@ -0,0 +1,3 @@
1
+ export declare const nxVersion: any;
2
+ export declare const expressVersion = "^4.18.1";
3
+ export declare const expressTypingsVersion = "4.17.13";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expressTypingsVersion = exports.expressVersion = exports.nxVersion = void 0;
4
+ exports.nxVersion = require('../../package.json').version;
5
+ exports.expressVersion = '^4.18.1';
6
+ exports.expressTypingsVersion = '4.17.13';