From dd9614239349be488ae89a5e8bae8c09f7d1013a Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Fri, 13 Dec 2024 14:04:08 -0500 Subject: [PATCH 1/2] test: rewrite test to work around Windows bug (#5945) We're not quite sure what's going on but the async import with `?one` fails on Windows with node 22.12.0. --- packages/functions-utils/tests/main.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/functions-utils/tests/main.test.ts b/packages/functions-utils/tests/main.test.ts index e5f2c579b1..4ad80e2396 100644 --- a/packages/functions-utils/tests/main.test.ts +++ b/packages/functions-utils/tests/main.test.ts @@ -1,6 +1,6 @@ -import { rm } from 'fs/promises' +import { readFile, rm } from 'fs/promises' import { normalize } from 'path' -import { fileURLToPath, pathToFileURL } from 'url' +import { fileURLToPath } from 'url' import cpy from 'cpy' import { pathExists } from 'path-exists' @@ -77,21 +77,22 @@ test('Should copy a source file even if dist directory already exists', async () test('Should overwrite dist file if it already exists', async () => { const dist = await getDist() const fixtureDir = `${FIXTURES_DIR}/file` + const testModule = `${dist}/test.mjs` await cpy(`${fixtureDir}/test.mjs`, fixtureDir, { rename: 'test.mjs.backup' }) try { await add(`${fixtureDir}/test.mjs`, dist) - const { func1 } = await import(`${pathToFileURL(`${dist}/test.mjs`).href}?one`) + const file1 = await readFile(testModule, 'utf8') await cpy(`${fixtureDir}/test_2.mjs`, fixtureDir, { rename: 'test.mjs' }) await add(`${fixtureDir}/test.mjs`, dist) - const { func2 } = await import(`${pathToFileURL(`${dist}/test.mjs`).href}?two`) + const file2 = await readFile(testModule, 'utf8') - expect(func1()).toBe('one') - expect(func2()).toBe('two') + expect(file1).toContain('one') + expect(file2).toContain('two') } finally { await cpy(`${fixtureDir}/test.mjs.backup`, fixtureDir, { rename: 'test.mjs' }) await rm(`${fixtureDir}/test.mjs.backup`, { force: true }) From 131a644bfde5205f730f3369b778d8914c7c0382 Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Fri, 13 Dec 2024 14:32:48 -0500 Subject: [PATCH 2/2] feat: rename unscoped NPM packages (#5943) --- package-lock.json | 24 ++++++++++++------------ packages/config/docs/main.md | 9 ++++----- packages/config/package.json | 4 ++-- packages/config/src/headers.js | 2 +- packages/config/src/redirects.ts | 2 +- packages/headers-parser/package.json | 2 +- packages/redirect-parser/package.json | 2 +- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0f6dd25ab8..68b65f0aa1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6646,6 +6646,10 @@ "resolved": "packages/git-utils", "link": true }, + "node_modules/@netlify/headers-parser": { + "resolved": "packages/headers-parser", + "link": true + }, "node_modules/@netlify/nock-udp": { "resolved": "packages/nock-udp", "link": true @@ -6684,6 +6688,10 @@ "node": "^14.14.0 || >=16.0.0" } }, + "node_modules/@netlify/redirect-parser": { + "resolved": "packages/redirect-parser", + "link": true + }, "node_modules/@netlify/run-utils": { "resolved": "packages/run-utils", "link": true @@ -20038,14 +20046,6 @@ "resolved": "packages/js-client", "link": true }, - "node_modules/netlify-headers-parser": { - "resolved": "packages/headers-parser", - "link": true - }, - "node_modules/netlify-redirect-parser": { - "resolved": "packages/redirect-parser", - "link": true - }, "node_modules/nise": { "version": "5.1.5", "dev": true, @@ -26662,6 +26662,8 @@ "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", + "@netlify/headers-parser": "^7.2.0", + "@netlify/redirect-parser": "^14.4.0", "chalk": "^5.0.0", "cron-parser": "^4.1.0", "deepmerge": "^4.2.2", @@ -26676,8 +26678,6 @@ "js-yaml": "^4.0.0", "map-obj": "^5.0.0", "netlify": "^13.2.0", - "netlify-headers-parser": "^7.2.0", - "netlify-redirect-parser": "^14.4.0", "node-fetch": "^3.3.1", "omit.js": "^2.0.2", "p-locate": "^6.0.0", @@ -27261,7 +27261,7 @@ } }, "packages/headers-parser": { - "name": "netlify-headers-parser", + "name": "@netlify/headers-parser", "version": "7.2.0", "license": "MIT", "dependencies": { @@ -27383,7 +27383,7 @@ } }, "packages/redirect-parser": { - "name": "netlify-redirect-parser", + "name": "@netlify/redirect-parser", "version": "14.4.0", "license": "MIT", "dependencies": { diff --git a/packages/config/docs/main.md b/packages/config/docs/main.md index 569023242a..ee11121699 100644 --- a/packages/config/docs/main.md +++ b/packages/config/docs/main.md @@ -95,8 +95,8 @@ Most Netlify CLI commands rely on configuration properties. The base command loa [using `@netlify/config` programmatically](https://github.com/netlify/cli/blob/f87d9e6e1749bedaabaace3dae98ca1ed6d84fd6/src/commands/base-command.js#L474). An `inlineConfig` flag was added to `@netlify/config` so Netlify CLI can override specific configuration properties -based on its own CLI flags, but this is not used yet (see https://github.com/netlify/cli/issues/1265, -https://github.com/netlify/cli/issues/960, https://github.com/netlify/cli/issues/961). +based on its own CLI flags, but this is not used yet (see , +, ). We try to [emulate the same environment variables](https://github.com/netlify/build/blob/558fe8869f47ecc84d05bd4d26d32df00f47a3b9/packages/config/src/env/main.js#L13) @@ -150,11 +150,10 @@ Redirects configuration is more complicated: - It can be specified either in `netlify.toml` or in a separate `_redirects` file located in the publish directory and with its own Netlify-specific file format -Therefore, that logic is abstracted to -[its own module `netlify-redirect-parser`](https://github.com/netlify/netlify-redirect-parser). +Therefore, that logic is abstracted to [its own module `@netlify/redirect-parser`](../../redirect-parser). Headers are handled very similarly to redirects, for consistency. They use a separate `_headers` file -[and `netlify-headers-parser` module](https://github.com/netlify/netlify-headers-parser). +[and `@netlify/headers-parser` module](../../headers-parser). ## Context-specific configuration diff --git a/packages/config/package.json b/packages/config/package.json index 93f8cbc5be..d89a1bc32e 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -73,8 +73,8 @@ "js-yaml": "^4.0.0", "map-obj": "^5.0.0", "netlify": "^13.2.0", - "netlify-headers-parser": "^7.2.0", - "netlify-redirect-parser": "^14.4.0", + "@netlify/headers-parser": "^7.2.0", + "@netlify/redirect-parser": "^14.4.0", "node-fetch": "^3.3.1", "omit.js": "^2.0.2", "p-locate": "^6.0.0", diff --git a/packages/config/src/headers.js b/packages/config/src/headers.js index cc35eb5181..c9ff8c0bbd 100644 --- a/packages/config/src/headers.js +++ b/packages/config/src/headers.js @@ -1,6 +1,6 @@ import { resolve } from 'path' -import { parseAllHeaders } from 'netlify-headers-parser' +import { parseAllHeaders } from '@netlify/headers-parser' import { warnHeadersParsing, warnHeadersCaseSensitivity } from './log/messages.js' diff --git a/packages/config/src/redirects.ts b/packages/config/src/redirects.ts index dbb1466fc5..e7a3c1c8db 100644 --- a/packages/config/src/redirects.ts +++ b/packages/config/src/redirects.ts @@ -1,6 +1,6 @@ import { resolve } from 'path' -import { parseAllRedirects } from 'netlify-redirect-parser' +import { parseAllRedirects } from '@netlify/redirect-parser' import { warnRedirectsParsing } from './log/messages.js' diff --git a/packages/headers-parser/package.json b/packages/headers-parser/package.json index 0fdb4cbff3..f57ca3e861 100644 --- a/packages/headers-parser/package.json +++ b/packages/headers-parser/package.json @@ -1,5 +1,5 @@ { - "name": "netlify-headers-parser", + "name": "@netlify/headers-parser", "version": "7.2.0", "description": "Parses Netlify headers into a JavaScript object representation", "type": "module", diff --git a/packages/redirect-parser/package.json b/packages/redirect-parser/package.json index f5d2b63f27..1f4e2d30d4 100644 --- a/packages/redirect-parser/package.json +++ b/packages/redirect-parser/package.json @@ -1,5 +1,5 @@ { - "name": "netlify-redirect-parser", + "name": "@netlify/redirect-parser", "version": "14.4.0", "description": "Parses netlify redirects into a js object representation", "type": "module",