diff --git a/.projen/deps.json b/.projen/deps.json index 7355fe4a..4feae09f 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -77,10 +77,18 @@ "version": "^8", "type": "build" }, + { + "name": "fs-monkey", + "type": "build" + }, { "name": "jest", "type": "build" }, + { + "name": "memfs", + "type": "build" + }, { "name": "mock-fs", "type": "build" diff --git a/.projen/tasks.json b/.projen/tasks.json index df6d84aa..15ff28b9 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -211,13 +211,13 @@ "exec": "yarn upgrade npm-check-updates" }, { - "exec": "npm-check-updates --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@actions/core,@actions/github,@types/commonmark,@types/jest,@types/mock-fs,@types/node,@types/stream-json,@types/tar,@types/workerpool,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,constructs,eslint-config-prettier,eslint-import-resolver-typescript,eslint-plugin-import,eslint-plugin-prettier,eslint-plugin-unicorn,eslint,jest,mock-fs,npm-check-updates,prettier,projen,tar,ts-jest,ts-node,@jsii/check-node,@jsii/spec,@xmldom/xmldom,chalk,commonmark,fast-glob,semver,semver-intersect,stream-json,workerpool,yargs" + "exec": "npm-check-updates --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@actions/core,@actions/github,@types/commonmark,@types/jest,@types/mock-fs,@types/node,@types/stream-json,@types/tar,@types/workerpool,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,constructs,eslint-config-prettier,eslint-import-resolver-typescript,eslint-plugin-import,eslint-plugin-prettier,eslint-plugin-unicorn,eslint,fs-monkey,jest,memfs,mock-fs,npm-check-updates,prettier,projen,tar,ts-jest,ts-node,@jsii/check-node,@jsii/spec,@xmldom/xmldom,chalk,commonmark,fast-glob,semver,semver-intersect,stream-json,workerpool,yargs" }, { "exec": "yarn install --check-files" }, { - "exec": "yarn upgrade @actions/core @actions/github @types/commonmark @types/jest @types/mock-fs @types/node @types/stream-json @types/tar @types/workerpool @typescript-eslint/eslint-plugin @typescript-eslint/parser constructs eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint-plugin-unicorn eslint jest mock-fs npm-check-updates prettier projen tar ts-jest ts-node @jsii/check-node @jsii/spec @xmldom/xmldom chalk commonmark fast-glob semver semver-intersect stream-json workerpool yargs" + "exec": "yarn upgrade @actions/core @actions/github @types/commonmark @types/jest @types/mock-fs @types/node @types/stream-json @types/tar @types/workerpool @typescript-eslint/eslint-plugin @typescript-eslint/parser constructs eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint-plugin-unicorn eslint fs-monkey jest memfs mock-fs npm-check-updates prettier projen tar ts-jest ts-node @jsii/check-node @jsii/spec @xmldom/xmldom chalk commonmark fast-glob semver semver-intersect stream-json workerpool yargs" }, { "exec": "npx projen" diff --git a/.projenrc.ts b/.projenrc.ts index 532c768f..841d95eb 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -102,6 +102,8 @@ const project = new typescript.TypeScriptProject({ '@types/stream-json', '@types/tar', '@types/workerpool', + 'fs-monkey', + 'memfs', 'mock-fs', 'tar', 'ts-node', diff --git a/package.json b/package.json index 37dbfb51..32946fbd 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "devDependencies": { "@actions/core": "^1.10.1", "@actions/github": "^5.1.1", - "@types/commonmark": "^0.27.9", + "@types/commonmark": "^0.27.8", "@types/jest": "^29.5.8", "@types/mock-fs": "^4.13.4", "@types/node": "^16", @@ -51,7 +51,9 @@ "eslint-plugin-import": "^2.29.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-unicorn": "^46.0.1", + "fs-monkey": "^1.0.5", "jest": "^29.7.0", + "memfs": "^4.6.0", "mock-fs": "^5.2.0", "npm-check-updates": "^16", "prettier": "^2.8.8", diff --git a/test/jsii/assemblies.test.ts b/test/jsii/assemblies.test.ts index edefe1ee..62d02fdc 100644 --- a/test/jsii/assemblies.test.ts +++ b/test/jsii/assemblies.test.ts @@ -1,12 +1,14 @@ import { promises as fs } from 'node:fs'; import * as path from 'node:path'; import * as spec from '@jsii/spec'; -import * as mockfs from 'mock-fs'; +import { Volume } from 'memfs'; import { fakeAssembly } from './fake-assembly'; import { allTypeScriptSnippets } from '../../lib/jsii/assemblies'; import { SnippetParameters } from '../../lib/snippet'; import { TestJsiiModule, DUMMY_JSII_CONFIG } from '../testutil'; +// eslint-disable-next-line @typescript-eslint/no-require-imports +const { patchFs } = require('fs-monkey'); jest.setTimeout(30_000); @@ -201,9 +203,11 @@ test('Fixture allows use of import statements', async () => { }); test('Backwards compatibility with literate integ tests', async () => { - mockfs({ - '/package/test/integ.example.lit.ts': '# Some literate source file', - }); + const unpatch = patchFs( + Volume.fromJSON({ + '/package/test/integ.example.lit.ts': '# Some literate source file', + }), + ); try { const snippets = Array.from( @@ -231,7 +235,7 @@ test('Backwards compatibility with literate integ tests', async () => { path.normalize('/package/test'), ); } finally { - mockfs.restore(); + unpatch(); } }); diff --git a/yarn.lock b/yarn.lock index 7e9c006c..7a2b9915 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1042,7 +1042,7 @@ dependencies: "@babel/types" "^7.20.7" -"@types/commonmark@^0.27.9": +"@types/commonmark@^0.27.8": version "0.27.9" resolved "https://registry.yarnpkg.com/@types/commonmark/-/commonmark-0.27.9.tgz#2d2d42e72127c84525fbbc87aaefb5a43e1129d7" integrity sha512-d3+57WgyPCcIc6oshmcPkmP4+JqRRot9eeZLsBsutWtIxwWivpoyc2wEcolOp8MyO3ZWN846mMdoR02kdHSMCw== @@ -1403,6 +1403,11 @@ arg@^4.1.0: resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== +arg@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c" + integrity sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -2626,6 +2631,11 @@ fs-minipass@^3.0.0: dependencies: minipass "^7.0.3" +fs-monkey@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.5.tgz#fe450175f0db0d7ea758102e1d84096acb925788" + integrity sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew== + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -2972,6 +2982,11 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" +hyperdyperid@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" + integrity sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A== + iconv-lite@^0.6.2: version "0.6.3" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" @@ -3760,6 +3775,14 @@ json-buffer@3.0.1: resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== +json-joy@^9.2.0: + version "9.9.1" + resolved "https://registry.yarnpkg.com/json-joy/-/json-joy-9.9.1.tgz#add8f8bdf4f7066894f5ec4817a5a43066a3757f" + integrity sha512-/d7th2nbQRBQ/nqTkBe6KjjvDciSwn9UICmndwk3Ed/Bk9AqkTRm4PnLVfXG4DKbT0rEY0nKnwE7NqZlqKE6kg== + dependencies: + arg "^5.0.2" + hyperdyperid "^1.2.0" + json-parse-even-better-errors@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" @@ -4001,6 +4024,14 @@ mdurl@~1.0.1: resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== +memfs@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-4.6.0.tgz#e812d438f73482a7110420d13d381c730b9a4de5" + integrity sha512-I6mhA1//KEZfKRQT9LujyW6lRbX7RkC24xKododIDO3AGShcaFAMKElv1yFGWX8fD4UaSiwasr3NeQ5TdtHY1A== + dependencies: + json-joy "^9.2.0" + thingies "^1.11.1" + merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" @@ -5412,6 +5443,11 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +thingies@^1.11.1: + version "1.12.0" + resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.12.0.tgz#a815c224482d607aa70f563d3cbb351a338e4710" + integrity sha512-AiGqfYC1jLmJagbzQGuoZRM48JPsr9yB734a7K6wzr34NMhjUPrWSQrkF7ZBybf3yCerCL2Gcr02kMv4NmaZfA== + tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc"