diff --git a/package.json b/package.json index c4503f67fc..c621d0d8e2 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "@types/css-minimizer-webpack-plugin": "^3.0.2", "@types/cytoscape": "^3.18.2", "@types/eslint": "~8.4.1", - "@types/express": "4.17.0", + "@types/express": "4.17.13", "@types/flat": "^5.0.1", "@types/fs-extra": "^9.0.11", "@types/is-ci": "^3.0.0", @@ -148,7 +148,7 @@ "eslint-plugin-jsx-a11y": "6.5.1", "eslint-plugin-react": "7.27.0", "eslint-plugin-react-hooks": "4.3.0", - "express": "4.17.1", + "express": "4.17.2", "file-loader": "^6.2.0", "file-type": "^16.2.0", "flat": "^5.0.2", diff --git a/packages/express/migrations.json b/packages/express/migrations.json index 63001b4458..a935a0b37a 100644 --- a/packages/express/migrations.json +++ b/packages/express/migrations.json @@ -1,3 +1,18 @@ { - "schematics": {} + "schematics": {}, + "packageJsonUpdates": { + "13.7.0": { + "version": "13.7.0", + "packages": { + "express": { + "version": "4.17.2", + "alwaysAddToPackageJson": false + }, + "@types/express": { + "version": "4.17.13", + "alwaysAddToPackageJson": false + } + } + } + } } diff --git a/packages/express/package.json b/packages/express/package.json index 77d9f69f04..0bd0a47f10 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -31,7 +31,14 @@ "dependencies": { "@nrwl/devkit": "*", "@nrwl/node": "*", - "@nrwl/jest": "*", "@nrwl/workspace": "*" + }, + "peerDependencies": { + "express": "4.17.2" + }, + "peerDependenciesMeta": { + "express": { + "optional": true + } } } diff --git a/packages/express/src/generators/application/application.spec.ts b/packages/express/src/generators/application/application.spec.ts index 47844d23e4..620a4e6205 100644 --- a/packages/express/src/generators/application/application.spec.ts +++ b/packages/express/src/generators/application/application.spec.ts @@ -1,6 +1,5 @@ import { readJson, Tree } from '@nrwl/devkit'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; - import { applicationGenerator } from './application'; import { Schema } from './schema'; diff --git a/packages/express/src/generators/application/application.ts b/packages/express/src/generators/application/application.ts index e5e60a1090..88c73005a7 100644 --- a/packages/express/src/generators/application/application.ts +++ b/packages/express/src/generators/application/application.ts @@ -5,29 +5,30 @@ import { joinPathFragments, names, toJS, - Tree, updateJson, } from '@nrwl/devkit'; - +import type { Tree } from '@nrwl/devkit'; import { applicationGenerator as nodeApplicationGenerator } from '@nrwl/node'; - import { join } from 'path'; -import { Schema } from './schema'; import { initGenerator } from '../init/init'; +import type { Schema } from './schema'; interface NormalizedSchema extends Schema { appProjectRoot: string; } function addTypes(tree: Tree, options: NormalizedSchema) { - const tsConfigPath = join(options.appProjectRoot, 'tsconfig.app.json'); - updateJson(tree, tsConfigPath, (json) => { - json.compilerOptions.types = [...json.compilerOptions.types, 'express']; - return json; - }); + updateJson( + tree, + join(options.appProjectRoot, 'tsconfig.app.json'), + (json) => { + json.compilerOptions.types = [...json.compilerOptions.types, 'express']; + return json; + } + ); } -function addAppFiles(tree: Tree, options: NormalizedSchema) { +function addMainFile(tree: Tree, options: NormalizedSchema) { tree.write( join(options.appProjectRoot, `src/main.${options.js ? 'js' : 'ts'}`), `/** @@ -63,9 +64,12 @@ export async function applicationGenerator(tree: Tree, schema: Schema) { ...schema, skipFormat: true, }); - addAppFiles(tree, options); + addMainFile(tree, options); addTypes(tree, options); - await formatFiles(tree); + + if (!options.skipFormat) { + await formatFiles(tree); + } return async () => { await initTask(); diff --git a/packages/express/src/generators/init/init.spec.ts b/packages/express/src/generators/init/init.spec.ts index ca9af10b77..827dd1a23f 100644 --- a/packages/express/src/generators/init/init.spec.ts +++ b/packages/express/src/generators/init/init.spec.ts @@ -1,12 +1,12 @@ import { addDependenciesToPackageJson, + readJson, NxJsonConfiguration, Tree, } from '@nrwl/devkit'; import { expressVersion } from '../../utils/versions'; import initGenerator from './init'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; -import { readJson } from '@nrwl/devkit'; describe('init', () => { let tree: Tree; diff --git a/packages/express/src/generators/init/init.ts b/packages/express/src/generators/init/init.ts index c8a0a02023..98406891c0 100644 --- a/packages/express/src/generators/init/init.ts +++ b/packages/express/src/generators/init/init.ts @@ -1,48 +1,41 @@ import { addDependenciesToPackageJson, - Tree, updateJson, formatFiles, convertNxGenerator, + Tree, } from '@nrwl/devkit'; - import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection'; - import { initGenerator as nodeInitGenerator } from '@nrwl/node'; - import { expressTypingsVersion, expressVersion, nxVersion, } from '../../utils/versions'; -import { Schema } from './schema'; +import type { Schema } from './schema'; -function removeNrwlExpressFromDeps(tree: Tree) { +function updateDependencies(tree: Tree) { updateJson(tree, 'package.json', (json) => { delete json.dependencies['@nrwl/express']; return json; }); -} - -export async function initGenerator(tree: Tree, schema: Schema) { - setDefaultCollection(tree, '@nrwl/express'); - - const initTask = await nodeInitGenerator(tree, { - unitTestRunner: schema.unitTestRunner, - skipFormat: true, - }); - removeNrwlExpressFromDeps(tree); - const installTask = addDependenciesToPackageJson( + return addDependenciesToPackageJson( tree, { express: expressVersion, - tslib: '^2.0.0', }, { '@types/express': expressTypingsVersion, '@nrwl/express': nxVersion, } ); +} + +export async function initGenerator(tree: Tree, schema: Schema) { + setDefaultCollection(tree, '@nrwl/express'); + + const initTask = await nodeInitGenerator(tree, schema); + const installTask = updateDependencies(tree); if (!schema.skipFormat) { await formatFiles(tree); } diff --git a/packages/express/src/utils/versions.ts b/packages/express/src/utils/versions.ts index 7f5a6d9269..692bcaab0f 100644 --- a/packages/express/src/utils/versions.ts +++ b/packages/express/src/utils/versions.ts @@ -1,4 +1,4 @@ export const nxVersion = '*'; -export const expressVersion = '4.17.1'; -export const expressTypingsVersion = '4.17.0'; +export const expressVersion = '4.17.2'; +export const expressTypingsVersion = '4.17.13'; diff --git a/yarn.lock b/yarn.lock index a97ebfe5f6..4f116cd1a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5853,16 +5853,7 @@ resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== -"@types/express-serve-static-core@*": - version "4.17.25" - resolved "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.25.tgz" - integrity sha512-OUJIVfRMFijZukGGwTpKNFprqCCXk5WjNGvUgB/CxxBR40QWSjsNK86+yvGKlCOGc7sbwfHLaXhkG+NsytwBaQ== - dependencies: - "@types/node" "*" - "@types/qs" "*" - "@types/range-parser" "*" - -"@types/express-serve-static-core@^4.17.18": +"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.18": version "4.17.28" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8" integrity sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig== @@ -5871,7 +5862,7 @@ "@types/qs" "*" "@types/range-parser" "*" -"@types/express@*": +"@types/express@*", "@types/express@4.17.13": version "4.17.13" resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.13.tgz#a76e2995728999bab51a33fabce1d705a3709034" integrity sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA== @@ -5881,15 +5872,6 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/express@4.17.0": - version "4.17.0" - resolved "https://registry.npmjs.org/@types/express/-/express-4.17.0.tgz" - integrity sha512-CjaMu57cjgjuZbh9DpkloeGxV45CnMGlVd+XpG7Gm9QgVrd7KFq+X4HY0vM+2v0bczS48Wg7bvnMY5TN+Xmcfw== - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "*" - "@types/serve-static" "*" - "@types/flat@^5.0.1": version "5.0.2" resolved "https://registry.npmjs.org/@types/flat/-/flat-5.0.2.tgz" @@ -8260,6 +8242,22 @@ body-parser@1.19.0, body-parser@^1.16.1: raw-body "2.4.0" type-is "~1.6.17" +body-parser@1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.1.tgz#1499abbaa9274af3ecc9f6f10396c995943e31d4" + integrity sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA== + dependencies: + bytes "3.1.1" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.2" + http-errors "1.8.1" + iconv-lite "0.4.24" + on-finished "~2.3.0" + qs "6.9.6" + raw-body "2.4.2" + type-is "~1.6.18" + bonjour@^3.5.0: version "3.5.0" resolved "https://registry.npmjs.org/bonjour/-/bonjour-3.5.0.tgz" @@ -8573,7 +8571,7 @@ bytes@3.1.0: resolved "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz" integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== -bytes@^3.1.0: +bytes@3.1.1, bytes@^3.1.0: version "3.1.1" resolved "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz" integrity sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg== @@ -9465,6 +9463,13 @@ content-disposition@0.5.3: dependencies: safe-buffer "5.1.2" +content-disposition@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== + dependencies: + safe-buffer "5.2.1" + content-type@~1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz" @@ -9659,6 +9664,11 @@ cookie@0.4.0: resolved "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== +cookie@0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" + integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== + cookies@0.8.0: version "0.8.0" resolved "https://registry.npmjs.org/cookies/-/cookies-0.8.0.tgz" @@ -12292,6 +12302,42 @@ express@4.17.1, express@^4.17.1: utils-merge "1.0.1" vary "~1.1.2" +express@4.17.2: + version "4.17.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.17.2.tgz#c18369f265297319beed4e5558753cc8c1364cb3" + integrity sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg== + dependencies: + accepts "~1.3.7" + array-flatten "1.1.1" + body-parser "1.19.1" + content-disposition "0.5.4" + content-type "~1.0.4" + cookie "0.4.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.2" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "~1.1.2" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.3" + path-to-regexp "0.1.7" + proxy-addr "~2.0.7" + qs "6.9.6" + range-parser "~1.2.1" + safe-buffer "5.2.1" + send "0.17.2" + serve-static "1.14.2" + setprototypeof "1.2.0" + statuses "~1.5.0" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + ext@^1.1.2: version "1.6.0" resolved "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz" @@ -13993,6 +14039,17 @@ http-errors@1.8.0: statuses ">= 1.5.0 < 2" toidentifier "1.0.0" +http-errors@1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" + integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== + dependencies: + depd "~1.1.2" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.1" + http-errors@~1.6.2: version "1.6.3" resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz" @@ -17534,7 +17591,7 @@ ms@2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@^2.0.0, ms@^2.1.1: +ms@2.1.3, ms@^2.0.0, ms@^2.1.1: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -20228,7 +20285,7 @@ protractor@5.4.3: webdriver-js-extender "2.1.0" webdriver-manager "^12.0.6" -proxy-addr@~2.0.5: +proxy-addr@~2.0.5, proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz" integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== @@ -20335,6 +20392,11 @@ qs@6.7.0: resolved "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== +qs@6.9.6: + version "6.9.6" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.6.tgz#26ed3c8243a431b2924aca84cc90471f35d5a0ee" + integrity sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ== + qs@^6.10.0, qs@^6.4.0, qs@^6.9.4: version "6.10.1" resolved "https://registry.npmjs.org/qs/-/qs-6.10.1.tgz" @@ -20451,6 +20513,16 @@ raw-body@2.4.1: iconv-lite "0.4.24" unpipe "1.0.0" +raw-body@2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.2.tgz#baf3e9c21eebced59dd6533ac872b71f7b61cb32" + integrity sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ== + dependencies: + bytes "3.1.1" + http-errors "1.8.1" + iconv-lite "0.4.24" + unpipe "1.0.0" + raw-loader@^4.0.2: version "4.0.2" resolved "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.2.tgz" @@ -21701,7 +21773,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: +safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -21978,6 +22050,25 @@ send@0.17.1: range-parser "~1.2.1" statuses "~1.5.0" +send@0.17.2: + version "0.17.2" + resolved "https://registry.yarnpkg.com/send/-/send-0.17.2.tgz#926622f76601c41808012c8bf1688fe3906f7820" + integrity sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww== + dependencies: + debug "2.6.9" + depd "~1.1.2" + destroy "~1.0.4" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "1.8.1" + mime "1.6.0" + ms "2.1.3" + on-finished "~2.3.0" + range-parser "~1.2.1" + statuses "~1.5.0" + serialize-javascript@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz" @@ -22033,6 +22124,16 @@ serve-static@1.14.1: parseurl "~1.3.3" send "0.17.1" +serve-static@1.14.2: + version "1.14.2" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.2.tgz#722d6294b1d62626d41b43a013ece4598d292bfa" + integrity sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.17.2" + set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" @@ -23458,6 +23559,11 @@ toidentifier@1.0.0: resolved "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz" integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + token-types@^4.1.1: version "4.1.1" resolved "https://registry.npmjs.org/token-types/-/token-types-4.1.1.tgz"