Skip to content

Commit

Permalink
build: upgrade typescript-babel toolchain to nodenext
Browse files Browse the repository at this point in the history
This should hopefully fix issues some TypeScript@5 users may have
faced due to NTARH's outdated type export strategies.

Closes: #908
  • Loading branch information
Xunnamius committed Nov 3, 2023
1 parent a9d136b commit e457064
Show file tree
Hide file tree
Showing 10 changed files with 10,465 additions and 11,079 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ const rules = {
// ? I'll decide when I want switch cases for fallthrough or not, thanks
'unicorn/prefer-switch': 'off',
// ? No, thanks
'unicorn/prefer-set-has': 'off'
'unicorn/prefer-set-has': 'off',
// ? Nah
'unicorn/prefer-top-level-await': 'off'
};

module.exports = {
Expand Down
37 changes: 20 additions & 17 deletions external-scripts/is-next-compat.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// ! WARNING: don't run this in the real repo dir, but in a duplicate temp dir !
import { name as pkgName, version as pkgVersion } from 'package';
import { Octokit } from '@octokit/rest';
import { MongoClient } from 'mongodb';
import { satisfies as satisfiesRange, validRange } from 'semver';
import findPackageJson from 'find-package-json';
import debugFactory from 'debug';
import execa from 'execa';
import findPackageJson from 'find-package-json';
import { MongoClient } from 'mongodb';
import { name as pkgName, version as pkgVersion } from 'package.json';
import { satisfies as satisfiesRange, validRange } from 'semver';

import type { ExecaError } from 'execa';

Expand Down Expand Up @@ -71,9 +71,9 @@ const setCompatFlagTo = async (version: string) => {
} else debug('skipped updating database (no MONGODB_URI)');
}
}
} catch (e: unknown) {
} catch (error) {
debug('additionally, an attempt to update the database failed');
throw e;
throw error;
}
};

Expand Down Expand Up @@ -101,9 +101,9 @@ const getLastTestedVersion = async () => {

await client.close();
} else debug('skipped database last tested version access (no MONGODB_URI)');
} catch (e) {
} catch (error) {
debug('database access failed');
throw e;
throw error;
}

debug('last tested version was ' + (version ? `"${version}"` : '(not tested)'));
Expand All @@ -116,14 +116,15 @@ const execaWithDebug = (async (...args: Parameters<typeof execa>) => {
debug.extend('stdout')(res.stdout);
debug.extend('stderr')(res.stderr);
return res;
} catch (e) {
const err = 'npm test failed! The latest Next.js is incompatible with this package!';
debug(err);
} catch (error) {
const error_ =
'npm test failed! The latest Next.js is incompatible with this package!';
debug(error_);

debug.extend('stdout')((e as ExecaError).stdout);
debug.extend('stderr')((e as ExecaError).stderr);
debug.extend('stdout')((error as ExecaError).stdout);
debug.extend('stderr')((error as ExecaError).stderr);

throw new Error(err);
throw new Error(error_);
}
}) as unknown as typeof execa;

Expand Down Expand Up @@ -190,9 +191,11 @@ const invoked = async () => {
await setCompatFlagTo(latestReleaseVersion);

debug('execution complete');

process.exitCode = 0;
};

export default invoked().catch((e: Error | string) => {
debug.extend('error')(typeof e == 'string' ? e : e.message);
process.exit(2);
export default invoked().catch((error: Error | string) => {
debug.extend('error')(typeof error == 'string' ? error : error.message);
process.exitCode = 2;
});

0 comments on commit e457064

Please sign in to comment.