Merge pull request #19565 from backstage/rugvip/1820

Switch to Node.js v18 + v20
This commit is contained in:
Patrik Oldsberg
2023-09-20 15:02:14 +02:00
committed by GitHub
45 changed files with 154 additions and 106 deletions
+1 -1
View File
@@ -138,7 +138,7 @@
"aws-sdk-client-mock": "^2.0.0",
"better-sqlite3": "^8.0.0",
"http-errors": "^2.0.0",
"mock-fs": "^5.1.0",
"mock-fs": "^5.2.0",
"msw": "^1.0.0",
"mysql2": "^2.2.5",
"recursive-readdir": "^2.2.2",
@@ -78,7 +78,9 @@ describe('ReadUrlResponseFactory', () => {
let readable: NodeJS.ReadableStream;
beforeEach(() => {
readable = new Stream({ encoding: 'utf-8' }) as NodeJS.ReadableStream;
readable = new Stream({
encoding: 'utf-8',
}) as unknown as NodeJS.ReadableStream;
readable.readable = true;
// Write data asynchronously, as soon as possible.
@@ -72,11 +72,11 @@ describe('ReadableArrayResponse', () => {
const res = new ReadableArrayResponse(arr, '/tmp', 'etag');
const dir = await res.dir();
expect(fs.readFileSync(resolvePath(dir, 'file1.yaml'), 'utf8').trim()).toBe(
'site_name: Test',
);
expect(fs.readFileSync(resolvePath(dir, 'file2.yaml'), 'utf8').trim()).toBe(
'site_name: Test2',
);
await expect(
fs.readFile(resolvePath(dir, 'file1.yaml'), 'utf8'),
).resolves.toBe('site_name: Test\n');
await expect(
fs.readFile(resolvePath(dir, 'file2.yaml'), 'utf8'),
).resolves.toBe('site_name: Test2\n');
});
});
@@ -18,16 +18,24 @@ import {
coreServices,
createServiceFactory,
} from '@backstage/backend-plugin-api';
import { mockServices } from '@backstage/backend-test-utils';
import { createBackend } from './CreateBackend';
describe('createBackend', () => {
it('should not throw when overriding a default service implementation', async () => {
const backend = createBackend();
backend.add(mockServices.rootConfig.factory());
backend.add(
createServiceFactory({
service: coreServices.rootConfig,
deps: {},
factory(): never {
throw new Error('NOPE');
},
}),
);
await expect(backend.start()).resolves.toBe(undefined);
// We expect the service factory error to be thrown, rather than any earlier validation
await expect(backend.start()).rejects.toThrow('NOPE');
});
it('should throw on duplicate service implementations', async () => {
@@ -277,7 +277,7 @@ describe('backend-plugin-manager', () => {
{
message: `an error occured while loading dynamic backend plugin 'backend-dynamic-plugin-test' from '${location}'`,
meta: {
message: 'Unexpected identifier',
message: expect.stringContaining('Unexpected identifier'),
name: 'SyntaxError',
},
},
@@ -588,7 +588,7 @@ Please add '${path.resolve(
)}'`,
meta: {
name: 'SyntaxError',
message: 'Unexpected token i in JSON at position 0',
message: expect.stringContaining('Unexpected token'),
},
},
],
@@ -622,7 +622,7 @@ Please add '${path.resolve(
)}'`,
meta: {
name: 'SyntaxError',
message: 'Unexpected token i in JSON at position 0',
message: expect.stringContaining('Unexpected token'),
},
},
],
+1 -1
View File
@@ -33,7 +33,7 @@
},
"devDependencies": {
"@backstage/cli": "workspace:^",
"@types/node": "^16.0.0"
"@types/node": "^18.17.8"
},
"files": [
"dist"
+2 -2
View File
@@ -158,7 +158,7 @@
"@types/inquirer": "^8.1.3",
"@types/minimatch": "^5.0.0",
"@types/mock-fs": "^4.13.0",
"@types/node": "^16.11.26",
"@types/node": "^18.17.8",
"@types/npm-packlist": "^3.0.0",
"@types/recursive-readdir": "^2.2.0",
"@types/rollup-plugin-peer-deps-external": "^2.2.0",
@@ -168,7 +168,7 @@
"@types/terser-webpack-plugin": "^5.0.4",
"@types/yarnpkg__lockfile": "^1.1.4",
"del": "^7.0.0",
"mock-fs": "^5.1.0",
"mock-fs": "^5.2.0",
"msw": "^1.0.0",
"nodemon": "^3.0.1",
"ts-node": "^10.0.0",
+1 -1
View File
@@ -42,7 +42,7 @@
"devDependencies": {
"@backstage/cli": "workspace:^",
"@types/jscodeshift": "^0.11.0",
"@types/node": "^16.11.26",
"@types/node": "^18.17.8",
"ts-node": "^10.0.0"
},
"nodemonConfig": {
+1 -1
View File
@@ -57,7 +57,7 @@
"@types/json-schema-merge-allof": "^0.6.0",
"@types/mock-fs": "^4.10.0",
"@types/yup": "^0.29.13",
"mock-fs": "^5.1.0",
"mock-fs": "^5.2.0",
"msw": "^1.0.0",
"zen-observable": "^0.10.0"
},
@@ -70,7 +70,7 @@ describe('defaultConfigLoaderSync', () => {
anyEnv.APP_CONFIG = [{ data: { my: 'config' }, context: 'a' }];
expect(() => defaultConfigLoaderSync('}')).toThrow(
'Failed to load runtime configuration, SyntaxError: Unexpected token } in JSON at position 0',
'Failed to load runtime configuration, SyntaxError: Unexpected token',
);
});
+2 -2
View File
@@ -46,9 +46,9 @@
"@types/command-exists": "^1.2.0",
"@types/fs-extra": "^9.0.1",
"@types/inquirer": "^8.1.3",
"@types/node": "^16.11.26",
"@types/node": "^18.17.8",
"@types/recursive-readdir": "^2.2.0",
"mock-fs": "^5.1.1",
"mock-fs": "^5.2.0",
"nodemon": "^3.0.1",
"ts-node": "^10.0.0"
},
+6 -6
View File
@@ -304,13 +304,13 @@ describe('tasks', () => {
},
);
// catalog was populated with `context.name`
expect(
fs.readFileSync('templatedApp/catalog-info.yaml', 'utf-8'),
).toContain('name: SuperCoolBackstageInstance');
await expect(
fs.readFile('templatedApp/catalog-info.yaml', 'utf-8'),
).resolves.toContain('name: SuperCoolBackstageInstance');
// backend dependencies include `sqlite3` from `context.SQLite`
expect(
fs.readFileSync('templatedApp/packages/backend/package.json', 'utf-8'),
).toContain('sqlite3"');
await expect(
fs.readFile('templatedApp/packages/backend/package.json', 'utf-8'),
).resolves.toContain('sqlite3"');
});
});
@@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"engines": {
"node": "16 || 18"
"node": "18 || 20"
},
"scripts": {
"dev": "concurrently \"yarn start\" \"yarn start-backend\"",
+1 -1
View File
@@ -43,7 +43,7 @@
"devDependencies": {
"@backstage/cli": "workspace:^",
"@types/fs-extra": "^9.0.1",
"@types/node": "^16.11.26",
"@types/node": "^18.17.8",
"@types/puppeteer": "^5.4.4",
"nodemon": "^3.0.1",
"ts-node": "^10.0.0"
+6
View File
@@ -181,6 +181,12 @@ async function buildDistWorkspace(workspaceName: string, rootDir: string) {
print('Pinning yarn version in workspace');
await pinYarnVersion(workspaceDir);
const yarnPatchesPath = paths.resolveOwnRoot('.yarn/patches');
if (await fs.pathExists(yarnPatchesPath)) {
print('Copying yarn patches');
await fs.copy(yarnPatchesPath, resolvePath(workspaceDir, '.yarn/patches'));
}
print('Installing workspace dependencies');
await runPlain(['yarn', 'workspaces', 'focus', '--all', '--production'], {
cwd: workspaceDir,
+2 -2
View File
@@ -64,8 +64,8 @@
"@backstage/types": "workspace:^",
"@types/is-glob": "^4.0.2",
"@types/mock-fs": "^4.13.0",
"@types/node": "^16.11.26",
"mock-fs": "^5.1.0"
"@types/node": "^18.17.8",
"mock-fs": "^5.2.0"
},
"peerDependencies": {
"@microsoft/api-extractor-model": "*",
+1 -1
View File
@@ -41,7 +41,7 @@
"@types/commander": "^2.12.2",
"@types/fs-extra": "^9.0.6",
"@types/http-proxy": "^1.17.4",
"@types/node": "^16.11.26",
"@types/node": "^18.17.8",
"@types/serve-handler": "^6.1.0",
"@types/webpack-env": "^1.15.3",
"cypress": "^10.0.0",