Skip to content

Commit e464632

Browse files
committed
review
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
1 parent 4ae39c1 commit e464632

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

e2e-tests/util.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ function populateDirectoryCache(directory: Directory): Array<Promise<unknown>> {
3535
files: Object.keys(directory.files).map(name => {
3636
const file = directory.files[name];
3737

38-
// TODO check for indx file
38+
if (!hasIndexHtmlFile && name.match(/index.htm(?:l)$/)) {
39+
hasIndexHtmlFile = true;
40+
}
3941

4042
return {
4143
name,
@@ -48,7 +50,7 @@ function populateDirectoryCache(directory: Directory): Array<Promise<unknown>> {
4850
};
4951
cachedDirectory.hasIndexHtmlFile = hasIndexHtmlFile;
5052

51-
const promises: Array<Promise<unknown>> = [
53+
const promises: Array<Promise<void>> = [
5254
env.DIRECTORY_CACHE.put(
5355
`${directory.name}/`,
5456
JSON.stringify(cachedDirectory)

scripts/constants.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export const STAGING_BUCKET = process.env.STAGING_BUCKET ?? 'dist-staging';
2020
export const RELEASE_DIR = 'nodejs/release/';
2121
export const DOCS_DIR = 'nodejs/docs/';
2222

23+
export const NODE_LATEST_FILE_NAME = 'node-latest.tar.gz';
24+
2325
export const DEV_BUCKET_PATH = join(import.meta.dirname, '..', 'dev-bucket');
2426
export const CACHED_DIRECTORIES_PATH = join(
2527
import.meta.dirname,

scripts/utils/addSymlinksToDirectoryCache.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { basename, dirname } from 'node:path';
33
import { S3Client } from '@aws-sdk/client-s3';
44
import {
55
DOCS_DIR,
6+
NODE_LATEST_FILE_NAME,
67
PROD_BUCKET,
78
RELEASE_DIR,
89
STATIC_FILE_SYMLINKS_PATH,
@@ -24,7 +25,7 @@ export async function addLatestTarSymlinkToCache(
2425
latestVersionMap,
2526
latestVersion
2627
) {
27-
const nodeLatestPath = `${RELEASE_DIR}${latestVersionMap['node-latest.tar.gz'].replaceAll('latest', latestVersion)}`;
28+
const nodeLatestPath = `${RELEASE_DIR}${latestVersionMap[NODE_LATEST_FILE_NAME].replaceAll('latest', latestVersion)}`;
2829

2930
// Stat the file that `node-latest.tar.gz` points to so we can have accurate
3031
// size & last modified info for the directory listing. Also acts as a safety
@@ -37,7 +38,7 @@ export async function addLatestTarSymlinkToCache(
3738
}
3839

3940
releaseDirectory.files.push({
40-
name: 'node-latest.tar.gz',
41+
name: NODE_LATEST_FILE_NAME,
4142
lastModified: nodeLatest.lastModified,
4243
size: nodeLatest.size,
4344
});
@@ -54,7 +55,8 @@ export function addLatestDirectorySymlinksToCache(
5455
) {
5556
releaseDirectory.subdirectories.push(
5657
...Object.keys(latestVersionMap)
57-
.filter(version => version !== 'node-latest.tar.gz')
58+
// We only want directories, remove the only file in the map
59+
.filter(version => version !== NODE_LATEST_FILE_NAME)
5860
.map(version => `${version}/`)
5961
);
6062
releaseDirectory.subdirectories.sort();
@@ -116,14 +118,20 @@ export async function addStaticFileSymlinksToCache(
116118
// TODO: remove when KV is considered stable
117119
const directoriesIncludedInFileCache = new Set([RELEASE_DIR, DOCS_DIR]);
118120

121+
const fileSymlinksFile = await readFile(STATIC_FILE_SYMLINKS_PATH, 'utf8');
122+
119123
/**
120124
* @type {Record<string, string>}
121125
*/
122-
const fileSymlinks = JSON.parse(
123-
await readFile(STATIC_FILE_SYMLINKS_PATH, 'utf8')
124-
);
125-
126-
// This isn't static, delete it for now
126+
const fileSymlinks = JSON.parse(fileSymlinksFile);
127+
128+
// This file is an exception for two reasons:
129+
// 1. It's dynamic and points to the latest Node version
130+
// 2. It's handled specially and is technically in the root directory,
131+
// which we should never be listing thus don't need to add it to the
132+
// directory cache.
133+
// So, let's remove it then add it back once we're done handling the rest of
134+
// the static file symlinks.
127135
fileSymlinks['node-config-schema.json'] = undefined;
128136

129137
// Add the symlinks to the directory cache

0 commit comments

Comments
 (0)