Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
node-version: current
# the packages import each other, so link the workspaces
- name: Run npm install
run: npm install -ws --include-workspace-root
run: npm install --workspaces --include-workspace-root
- name: Build the types
run: npm run types
- name: Check the committed types match the source
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-static-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
node-version: latest
- name: Run npm install
run: npm install -ws --include-workspace-root
run: npm install --workspaces --include-workspace-root
- name: Run build:default
run: npm run build:default -w static
- name: Run build:releases
Expand Down
24 changes: 23 additions & 1 deletion core/test/schedule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { match } = require('node:assert');
const { match, rejects } = require('node:assert');
const { describe, it } = require('node:test');
const { fetch: undiciFetch } = require('undici');
const schedule = require('../util/prod/schedule');
Expand Down Expand Up @@ -56,3 +56,25 @@ describe('schedule should work with optionsParser', async () => {
check(data);
});
});

describe('schedule', async () => {
it('should reject naming the URL and status when the response is not ok', async () => {
// Arrange
const url =
'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json';

// Act
const result = schedule({ fetch: notFound, urls: { schedule: url } });

// Assert
await rejects(result, {
message: `Fetching ${url} failed: 404 Not Found`,
});
});
});

// Helpers

async function notFound() {
return new Response('Not Found', { status: 404, statusText: 'Not Found' });
}
23 changes: 22 additions & 1 deletion core/test/versions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { deepStrictEqual, match } = require('node:assert');
const { deepStrictEqual, match, rejects } = require('node:assert');
const { describe, it } = require('node:test');
const { fetch: undiciFetch } = require('undici');
const versions = require('../util/prod/versions');
Expand Down Expand Up @@ -61,3 +61,24 @@ describe('versions should work with optionsParser', async () => {
check(data);
});
});

describe('versions', async () => {
it('should reject naming the URL and status when the response is not ok', async () => {
// Arrange
const url = 'https://nodejs.org/dist/index.json';

// Act
const result = versions({ fetch: notFound, urls: { index: url } });

// Assert
await rejects(result, {
message: `Fetching ${url} failed: 404 Not Found`,
});
});
});

// Helpers

async function notFound() {
return new Response('Not Found', { status: 404, statusText: 'Not Found' });
}
5 changes: 5 additions & 0 deletions core/util/prod/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ async function schedule(options) {

// fetch the url, get the json from the fetched URL that we're going to use
const raw = await fetch(url);

if (!raw.ok) {
throw new Error(`Fetching ${url} failed: ${raw.status} ${raw.statusText}`);
}

const schedule = await raw.json();

return schedule;
Expand Down
5 changes: 5 additions & 0 deletions core/util/prod/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ async function versions(options) {

// fetch the url, get the json from the fetched URL that we're going to use
const raw = await fetch(url);

if (!raw.ok) {
throw new Error(`Fetching ${url} failed: ${raw.status} ${raw.statusText}`);
}

const versions = await raw.json();

return versions;
Expand Down
10 changes: 6 additions & 4 deletions docs/pages/ranges.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ The releases in `versions`, and `newest`, `oldest`, `newestLts`, and
- Type: {Object}
- `versions` {string[]} The releases of `lts/latest`, then those of
`lts/maintenance`.
- `oldestLts` {string} The `oldestLts` of `lts/maintenance`.
- `oldestSecurity` {string} The `oldestSecurity` of `lts/maintenance`.
- `newestLts` {string} The `newestLts` of `lts/latest`.
- `newestSecurity` {string} The `newestSecurity` of `lts/latest`.
- `oldestLts` {string} The first LTS release of the oldest line, which is
in `lts/maintenance` unless that's empty.
- `oldestSecurity` {string} The oldest security release of the oldest line.
- `newestLts` {string} The newest LTS release of the newest line, which is
in `lts/latest` unless that's empty.
- `newestSecurity` {string} The newest security release of the newest line.
- `newest` {string} The newest release.
- `oldest` {string} The oldest release.

Expand Down
5 changes: 5 additions & 0 deletions fetchindex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ async function versions(options) {

// fetch the url, get the json from the fetched URL that we're going to use
const raw = await fetch(url);

if (!raw.ok) {
throw new Error(`Fetching ${url} failed: ${raw.status} ${raw.statusText}`);
}

const versions = await raw.json();

return versions;
Expand Down
23 changes: 22 additions & 1 deletion fetchindex/test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { deepStrictEqual, match } = require('node:assert');
const { deepStrictEqual, match, rejects } = require('node:assert');
const { describe, it } = require('node:test');
const { fetch: undiciFetch } = require('undici');
const fetchindex = require('../index');
Expand Down Expand Up @@ -61,3 +61,24 @@ describe('versions should work with optionsParser', async () => {
check(data);
});
});

describe('fetchindex', async () => {
it('should reject naming the URL and status when the response is not ok', async () => {
// Arrange
const url = 'https://nodejs.org/dist/index.json';

// Act
const result = fetchindex({ fetch: notFound, urls: { index: url } });

// Assert
await rejects(result, {
message: `Fetching ${url} failed: 404 Not Found`,
});
});
});

// Helpers

async function notFound() {
return new Response('Not Found', { status: 404, statusText: 'Not Found' });
}
25 changes: 8 additions & 17 deletions parsefiles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,9 @@ function parseFilename(file, version) {
info.files[0] = `node-v${version}.pkg`;
} else if (info.files[0].includes('osx-')) {
// macOS filenames, but with architectures. Different than the above.
const basemacOSString = `node-v${version}-darwin-`;

if (info.files[0].includes('arm64')) {
info.files[0] = basemacOSString.concat('arm64.tar.gz');
}

if (info.files[0].includes('x64')) {
info.files[0] = basemacOSString.concat('x64.tar.gz');
}
info.files[0] = `node-v${version}-${info.files[0]
.replace('osx-', 'darwin-')
.replace('-tar', '.tar.gz')}`;
} else if (info.files[0].includes('-7z')) {
// windows filenames
info.files[0] = `node-v${version}-${info.files[0].replace('-7z', '.7z')}`;
Expand All @@ -59,14 +53,11 @@ function parseFilename(file, version) {
.replace('-msi', '.msi')
.replace('win-', '')}`;
} else if (info.files[0].includes('-exe')) {
info.files[0] = 'win-x64/node.exe';
info.files.push('win-x64/node.lib');
info.files.push('win-x64/node_pdb.7z');
info.files.push('win-x64/node_pdb.zip');
info.files.push('win-x86/node.exe');
info.files.push('win-x86/node.lib');
info.files.push('win-x86/node_pdb.7z');
info.files.push('win-x86/node_pdb.zip');
// windows executables, in a directory named after the architecture
const directory = info.files[0].replace('-exe', '');
info.files = ['node.exe', 'node.lib', 'node_pdb.7z', 'node_pdb.zip'].map(
(name) => `${directory}/${name}`,
);
} else if (info.files[0] === 'src') {
// source filenames.
info.files[0] = `node-v${version}.tar.gz`;
Expand Down
10 changes: 1 addition & 9 deletions parsefiles/test/data/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@
"win-x64/node.exe",
"win-x64/node.lib",
"win-x64/node_pdb.7z",
"win-x64/node_pdb.zip",
"win-x86/node.exe",
"win-x86/node.lib",
"win-x86/node_pdb.7z",
"win-x86/node_pdb.zip"
"win-x64/node_pdb.zip"
],
"type": "windows",
"architecture": "x64"
Expand All @@ -117,10 +113,6 @@
{
"id": "win-x86-exe",
"files": [
"win-x64/node.exe",
"win-x64/node.lib",
"win-x64/node_pdb.7z",
"win-x64/node_pdb.zip",
"win-x86/node.exe",
"win-x86/node.lib",
"win-x86/node_pdb.7z",
Expand Down
49 changes: 49 additions & 0 deletions parsefiles/test/parseFilename.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const assert = require('node:assert');
const { describe, it } = require('node:test');

const parseFilename = require('../index');

describe('parseFilename', () => {
it('should only list the win-x86 directory for win-x86-exe', () => {
// Arrange
const id = 'win-x86-exe';

// Act
const result = parseFilename(id, '4.0.0');

// Assert
assert.deepStrictEqual(result.files, [
'win-x86/node.exe',
'win-x86/node.lib',
'win-x86/node_pdb.7z',
'win-x86/node_pdb.zip',
]);
});

it('should only list the win-x64 directory for win-x64-exe', () => {
// Arrange
const id = 'win-x64-exe';

// Act
const result = parseFilename(id, '4.0.0');

// Assert
assert.deepStrictEqual(result.files, [
'win-x64/node.exe',
'win-x64/node.lib',
'win-x64/node_pdb.7z',
'win-x64/node_pdb.zip',
]);
});

it('should name the darwin-x86 tarball for osx-x86-tar', () => {
// Arrange
const id = 'osx-x86-tar';

// Act
const result = parseFilename(id, '4.0.0');

// Assert
assert.deepStrictEqual(result.files, ['node-v4.0.0-darwin-x86.tar.gz']);
});
});
Loading
Loading