diff --git a/.changeset/seven-balloons-kick.md b/.changeset/seven-balloons-kick.md new file mode 100644 index 0000000000..669766d32d --- /dev/null +++ b/.changeset/seven-balloons-kick.md @@ -0,0 +1,5 @@ +--- +"create-fuels": patch +--- + +fix: resolve `punycode` deprecation notice diff --git a/package.json b/package.json index fa3798c102..cdd208f34d 100644 --- a/package.json +++ b/package.json @@ -128,6 +128,7 @@ }, "pnpm": { "overrides": { + "whatwg-url": "14.1.0", "cross-fetch": "4.0.0" } } diff --git a/packages/create-fuels/src/cli.ts b/packages/create-fuels/src/cli.ts index 2b9078f83c..73bf34e581 100644 --- a/packages/create-fuels/src/cli.ts +++ b/packages/create-fuels/src/cli.ts @@ -123,10 +123,24 @@ export const runScaffoldCli = async ({ const packageJsonPath = join(projectPath, 'package.json'); const packageJsonContents = readFileSync(packageJsonPath, 'utf-8'); const fuelsVersion = getPackageVersion(args); - const newPackageJsonContents = packageJsonContents + let newPackageJsonContents = packageJsonContents .replace(`pnpm run prebuild`, packageManager.run('prebuild')) .replace(`"fuels": "${versions.FUELS}"`, `"fuels": "${fuelsVersion}"`); + // TODO: remove once upgraded to `graphql-request@v7` + // https://github.com/FuelLabs/fuels-ts/issues/3546 + if (packageManager.name === 'pnpm') { + let newPackageJsonObject = JSON.parse(newPackageJsonContents); + newPackageJsonObject = { + ...newPackageJsonObject, + overrides: undefined, + pnpm: { + overrides: newPackageJsonObject.overrides, + }, + }; + newPackageJsonContents = JSON.stringify(newPackageJsonObject, null, 2); + } + writeFileSync(packageJsonPath, newPackageJsonContents); // Rewrite the README.md file diff --git a/packages/create-fuels/test/cli.test.ts b/packages/create-fuels/test/cli.test.ts index ad6447ceec..4745d39846 100644 --- a/packages/create-fuels/test/cli.test.ts +++ b/packages/create-fuels/test/cli.test.ts @@ -79,8 +79,7 @@ describe('CLI', { timeout: 15_000 }, () => { args, }); - const fuelToolchainPath = join(paths.projectRoot, 'fuel-toolchain.toml'); - const fuelToolchain = readFileSync(fuelToolchainPath, 'utf-8'); + const fuelToolchain = readFileSync(paths.fuelToolchainPath, 'utf-8'); const parsedFuelToolchain = toml.parse(fuelToolchain); const { toolchain, components } = parsedFuelToolchain; @@ -107,8 +106,7 @@ describe('CLI', { timeout: 15_000 }, () => { args, }); - const packageJsonPath = join(paths.projectRoot, 'package.json'); - const packageJson = readFileSync(packageJsonPath, 'utf-8'); + const packageJson = readFileSync(paths.packageJsonPath, 'utf-8'); expect(packageJson).toContain('bun run prebuild'); const readmePath = join(paths.projectRoot, 'README.md'); @@ -164,4 +162,57 @@ describe('CLI', { timeout: 15_000 }, () => { expect(log).toHaveBeenCalledWith(` - ${template}`); } }); + + test('should have a package.json with overrides', async () => { + const args = generateArgv({ + projectName: paths.projectRoot, + template: paths.templateName, + }); + + vi.spyOn(doesTemplateExistMod, 'doesTemplateExist').mockReturnValueOnce(true); + + await runScaffoldCli({ + program: setupProgram(), + args, + }); + + const packageJson = readFileSync(paths.packageJsonPath, 'utf-8'); + const packageJsonObject = JSON.parse(packageJson); + + expect(packageJsonObject).toEqual( + expect.objectContaining({ + overrides: expect.any(Object), + }) + ); + }); + + test('should rewrite overrides for pnpm', async () => { + process.env.npm_config_user_agent = 'pnpm'; + + const args = generateArgv({ + projectName: paths.projectRoot, + template: paths.templateName, + }); + + vi.spyOn(doesTemplateExistMod, 'doesTemplateExist').mockReturnValueOnce(true); + + await runScaffoldCli({ + program: setupProgram(), + args, + }); + + const packageJson = readFileSync(paths.packageJsonPath, 'utf-8'); + const packageJsonObject = JSON.parse(packageJson); + + expect(packageJsonObject.overrides).toBeUndefined(); + expect(packageJsonObject).toEqual( + expect.objectContaining({ + pnpm: { + overrides: expect.any(Object), + }, + }) + ); + + delete process.env.npm_config_user_agent; + }); }); diff --git a/packages/create-fuels/test/integration.test.ts b/packages/create-fuels/test/integration.test.ts index ff4c65c6f8..bd151f91b2 100644 --- a/packages/create-fuels/test/integration.test.ts +++ b/packages/create-fuels/test/integration.test.ts @@ -68,7 +68,7 @@ describe('`create fuels` package integrity', () => { expect(createFuelsError).toBeUndefined(); const actualTemplateFiles = await getAllFiles(paths.projectRoot); expect(actualTemplateFiles.sort()).toEqual(expectedTemplateFiles.sort()); - const packageJson = readFileSync(paths.projectPackageJson, 'utf-8'); + const packageJson = readFileSync(paths.packageJsonPath, 'utf-8'); expect(packageJson).toEqual(expect.stringMatching(expectedPackageJsonInstall)); }, { timeout: 30000 } diff --git a/packages/create-fuels/test/utils/bootstrapProject.ts b/packages/create-fuels/test/utils/bootstrapProject.ts index b13f15fdbb..28205fae35 100644 --- a/packages/create-fuels/test/utils/bootstrapProject.ts +++ b/packages/create-fuels/test/utils/bootstrapProject.ts @@ -6,7 +6,8 @@ import { rewriteTemplateFiles } from '../../src/lib/rewriteTemplateFiles'; export type ProjectPaths = { // Project paths projectRoot: string; - projectPackageJson: string; + packageJsonPath: string; + fuelToolchainPath: string; // Template paths templateName: string; @@ -28,7 +29,8 @@ export const bootstrapProject = (testFilepath: string, template: string = 'vite' // Project paths const projectName = `__temp__project_${testFilename}_${new Date().getTime()}`; const projectRoot = join(testDir, projectName); - const projectPackageJson = join(projectRoot, 'package.json'); + const packageJsonPath = join(projectRoot, 'package.json'); + const fuelToolchainPath = join(projectRoot, 'fuel-toolchain.toml'); // Template paths const templateName = `__temp__template_${template}_${testFilename}_${new Date().getTime()}`; @@ -38,7 +40,8 @@ export const bootstrapProject = (testFilepath: string, template: string = 'vite' return { // Project paths projectRoot, - projectPackageJson, + packageJsonPath, + fuelToolchainPath, // Template paths templateName, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f53eba3c4c..b712c8768a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: + whatwg-url: 14.1.0 cross-fetch: 4.0.0 importers: @@ -6470,6 +6471,9 @@ packages: ajv@8.12.0: resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} + ajv@8.14.0: + resolution: {integrity: sha512-oYs1UUtO97ZO2lJ4bwnWeQW8/zvOIQLGKcvPTsWmvc2SYgBb+upuNS5NxoLaMU4h8Ju3Nbj6Cq8mD2LQoqVKFA==} + algoliasearch@4.22.1: resolution: {integrity: sha512-jwydKFQJKIx9kIZ8Jm44SdpigFwRGPESaxZBaHSV0XWN2yBJAOT4mT7ppvlrpA4UGzz92pqFnVKr/kaZXrcreg==} @@ -12655,8 +12659,8 @@ packages: punycode@1.4.1: resolution: {integrity: sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==} - punycode@2.3.0: - resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} pupa@2.1.1: @@ -14206,15 +14210,9 @@ packages: resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==} engines: {node: '>=6'} - tr46@0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - - tr46@1.0.1: - resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==} - - tr46@2.1.0: - resolution: {integrity: sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==} - engines: {node: '>=8'} + tr46@5.0.0: + resolution: {integrity: sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==} + engines: {node: '>=18'} transform-ast@2.4.4: resolution: {integrity: sha512-AxjeZAcIOUO2lev2GDe3/xZ1Q0cVGjIMk5IsriTy8zbWlsEnjeB025AhkhBJHoy997mXpLd4R+kRbvnnQVuQHQ==} @@ -15012,12 +15010,6 @@ packages: webfontloader@1.6.28: resolution: {integrity: sha512-Egb0oFEga6f+nSgasH3E0M405Pzn6y3/9tOVanv/DLfa1YBIgcv90L18YyWnvXkRbIM17v5Kv6IT2N6g1x5tvQ==} - webidl-conversions@3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - - webidl-conversions@4.0.2: - resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} - webidl-conversions@5.0.0: resolution: {integrity: sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==} engines: {node: '>=8'} @@ -15026,6 +15018,10 @@ packages: resolution: {integrity: sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==} engines: {node: '>=10.4'} + webidl-conversions@7.0.0: + resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} + engines: {node: '>=12'} + webpack-dev-middleware@5.3.3: resolution: {integrity: sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==} engines: {node: '>= 12.13.0'} @@ -15103,15 +15099,9 @@ packages: resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} engines: {node: '>=18'} - whatwg-url@5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - - whatwg-url@7.1.0: - resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} - - whatwg-url@8.7.0: - resolution: {integrity: sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==} - engines: {node: '>=10'} + whatwg-url@14.1.0: + resolution: {integrity: sha512-jlf/foYIKywAt3x/XWKZ/3rz8OSJPiWktjmk891alJUEjiVxKX9LEO92qH3hv4aJ0mN3MWPvGMCy8jQi95xK4w==} + engines: {node: '>=18'} which-boxed-primitive@1.0.2: resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} @@ -15429,7 +15419,7 @@ snapshots: 0x@5.7.0: dependencies: - ajv: 8.12.0 + ajv: 8.14.0 browserify: 17.0.0 concat-stream: 2.0.0 d3-fg: 6.14.0 @@ -15578,9 +15568,9 @@ snapshots: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 - '@apideck/better-ajv-errors@0.3.6(ajv@8.12.0)': + '@apideck/better-ajv-errors@0.3.6(ajv@8.14.0)': dependencies: - ajv: 8.12.0 + ajv: 8.14.0 json-schema: 0.4.0 jsonpointer: 5.0.1 leven: 3.1.0 @@ -22676,17 +22666,17 @@ snapshots: clean-stack: 2.2.0 indent-string: 4.0.0 - ajv-formats@2.1.1(ajv@8.12.0): + ajv-formats@2.1.1(ajv@8.14.0): optionalDependencies: - ajv: 8.12.0 + ajv: 8.14.0 ajv-keywords@3.5.2(ajv@6.12.6): dependencies: ajv: 6.12.6 - ajv-keywords@5.1.0(ajv@8.12.0): + ajv-keywords@5.1.0(ajv@8.14.0): dependencies: - ajv: 8.12.0 + ajv: 8.14.0 fast-deep-equal: 3.1.3 ajv@6.12.6: @@ -22703,6 +22693,13 @@ snapshots: require-from-string: 2.0.2 uri-js: 4.4.1 + ajv@8.14.0: + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + algoliasearch@4.22.1: dependencies: '@algolia/cache-browser-local-storage': 4.22.1 @@ -24107,8 +24104,8 @@ snapshots: conf@10.2.0: dependencies: - ajv: 8.12.0 - ajv-formats: 2.1.1(ajv@8.12.0) + ajv: 8.14.0 + ajv-formats: 2.1.1(ajv@8.14.0) atomically: 1.7.0 debounce-fn: 4.0.0 dot-prop: 6.0.1 @@ -24602,7 +24599,7 @@ snapshots: dependencies: abab: 2.0.6 whatwg-mimetype: 2.3.0 - whatwg-url: 8.7.0 + whatwg-url: 14.1.0 data-view-buffer@1.0.1: dependencies: @@ -28214,7 +28211,7 @@ snapshots: webidl-conversions: 6.1.0 whatwg-encoding: 1.0.5 whatwg-mimetype: 2.3.0 - whatwg-url: 8.7.0 + whatwg-url: 14.1.0 ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10) xml-name-validator: 3.0.0 transitivePeerDependencies: @@ -28248,7 +28245,7 @@ snapshots: webidl-conversions: 6.1.0 whatwg-encoding: 1.0.5 whatwg-mimetype: 2.3.0 - whatwg-url: 8.7.0 + whatwg-url: 14.1.0 ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.4) xml-name-validator: 3.0.0 transitivePeerDependencies: @@ -29384,11 +29381,11 @@ snapshots: node-fetch@2.6.13: dependencies: - whatwg-url: 5.0.0 + whatwg-url: 14.1.0 node-fetch@2.7.0: dependencies: - whatwg-url: 5.0.0 + whatwg-url: 14.1.0 node-fetch@3.3.2: dependencies: @@ -30659,7 +30656,7 @@ snapshots: punycode@1.4.1: {} - punycode@2.3.0: {} + punycode@2.3.1: {} pupa@2.1.1: dependencies: @@ -31515,9 +31512,9 @@ snapshots: schema-utils@4.2.0: dependencies: '@types/json-schema': 7.0.12 - ajv: 8.12.0 - ajv-formats: 2.1.1(ajv@8.12.0) - ajv-keywords: 5.1.0(ajv@8.12.0) + ajv: 8.14.0 + ajv-formats: 2.1.1(ajv@8.14.0) + ajv-keywords: 5.1.0(ajv@8.14.0) scope-analyzer@2.1.2: dependencies: @@ -31874,7 +31871,7 @@ snapshots: source-map@0.8.0-beta.0: dependencies: - whatwg-url: 7.1.0 + whatwg-url: 14.1.0 sourcemap-codec@1.4.8: {} @@ -32611,24 +32608,18 @@ snapshots: tough-cookie@2.5.0: dependencies: psl: 1.9.0 - punycode: 2.3.0 + punycode: 2.3.1 tough-cookie@4.1.4: dependencies: psl: 1.9.0 - punycode: 2.3.0 + punycode: 2.3.1 universalify: 0.2.0 url-parse: 1.5.10 - tr46@0.0.3: {} - - tr46@1.0.1: - dependencies: - punycode: 2.3.0 - - tr46@2.1.0: + tr46@5.0.0: dependencies: - punycode: 2.3.0 + punycode: 2.3.1 transform-ast@2.4.4: dependencies: @@ -33100,7 +33091,7 @@ snapshots: uri-js@4.4.1: dependencies: - punycode: 2.3.0 + punycode: 2.3.1 url-parse-lax@3.0.0: dependencies: @@ -33633,14 +33624,12 @@ snapshots: webfontloader@1.6.28: {} - webidl-conversions@3.0.1: {} - - webidl-conversions@4.0.2: {} - webidl-conversions@5.0.0: {} webidl-conversions@6.1.0: {} + webidl-conversions@7.0.0: {} + webpack-dev-middleware@5.3.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): dependencies: colorette: 2.0.20 @@ -33765,22 +33754,10 @@ snapshots: whatwg-mimetype@4.0.0: {} - whatwg-url@5.0.0: + whatwg-url@14.1.0: dependencies: - tr46: 0.0.3 - webidl-conversions: 3.0.1 - - whatwg-url@7.1.0: - dependencies: - lodash.sortby: 4.7.0 - tr46: 1.0.1 - webidl-conversions: 4.0.2 - - whatwg-url@8.7.0: - dependencies: - lodash: 4.17.21 - tr46: 2.1.0 - webidl-conversions: 6.1.0 + tr46: 5.0.0 + webidl-conversions: 7.0.0 which-boxed-primitive@1.0.2: dependencies: @@ -33863,7 +33840,7 @@ snapshots: workbox-build@6.6.0(@types/babel__core@7.20.5): dependencies: - '@apideck/better-ajv-errors': 0.3.6(ajv@8.12.0) + '@apideck/better-ajv-errors': 0.3.6(ajv@8.14.0) '@babel/core': 7.25.8 '@babel/preset-env': 7.22.5(@babel/core@7.25.8) '@babel/runtime': 7.25.7 @@ -33871,7 +33848,7 @@ snapshots: '@rollup/plugin-node-resolve': 11.2.1(rollup@2.79.2) '@rollup/plugin-replace': 2.4.2(rollup@2.79.2) '@surma/rollup-plugin-off-main-thread': 2.2.3 - ajv: 8.12.0 + ajv: 8.14.0 common-tags: 1.8.2 fast-json-stable-stringify: 2.1.0 fs-extra: 9.1.0 diff --git a/templates/nextjs/package.json b/templates/nextjs/package.json index ecfcf9208a..b7f18b1308 100644 --- a/templates/nextjs/package.json +++ b/templates/nextjs/package.json @@ -39,5 +39,8 @@ "tailwindcss": "3.4.14", "typescript": "5.6.3", "vitest": "2.0.5" + }, + "overrides": { + "whatwg-url": "14.1.0" } } diff --git a/templates/vite/package.json b/templates/vite/package.json index b0aa258327..ad8c67df71 100644 --- a/templates/vite/package.json +++ b/templates/vite/package.json @@ -43,5 +43,8 @@ "typescript-eslint": "8.8.0", "vite": "5.4.9", "vitest": "2.0.5" + }, + "overrides": { + "whatwg-url": "14.1.0" } }