Unverified Commit 93dc7332 authored by dotlambda's avatar dotlambda Committed by GitHub
Browse files

typescript: 5.9.2 -> 5.9.3 after using GitHub source again (#447976)

parents 488b887c c2cf235b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
Disable dprint on dstBundler

dprint fails on sandbox, because it requires internet access to install its
plugins.

--- a/scripts/dtsBundler.mjs
+++ b/scripts/dtsBundler.mjs
@@ -430,5 +430,5 @@
     return result.replace(/\r\n/g, "\n");
 }
 
-fs.writeFileSync(output, dprint(publicContents));
-fs.writeFileSync(internalOutput, dprint(internalContents));
+fs.writeFileSync(output, publicContents);
+fs.writeFileSync(internalOutput, internalContents);
+0 −20
Original line number Diff line number Diff line
{
  "name": "typescript",
  "version": "5.9.2",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "typescript",
      "version": "5.9.2",
      "license": "Apache-2.0",
      "bin": {
        "tsc": "bin/tsc",
        "tsserver": "bin/tsserver"
      },
      "engines": {
        "node": ">=14.17"
      }
    }
  }
}
+17 −53
Original line number Diff line number Diff line
{
  lib,
  buildNpmPackage,
  fetchurl,
  fetchFromGitHub,
  versionCheckHook,
  writeShellApplication,
  nodejs,
  gnutar,
  jq,
  moreutils,
  nix-update,
  prefetch-npm-deps,
  nix-update-script,
}:

buildNpmPackage (finalAttrs: {
  pname = "typescript";
  version = "5.9.2";
  version = "5.9.3";

  # Prefer npmjs over the GitHub repository for source code.
  # The TypeScript project typically publishes stable, versioned code to npmjs,
  # whereas GitHub tags may sometimes include development versions.
  # For example:
  #   - https://github.com/microsoft/TypeScript/pull/61218#issuecomment-2911264050
  #   - https://github.com/microsoft/TypeScript/pull/60150#issuecomment-2648791588, 5.8.3 includes this 5.9 breaking change
  src = fetchurl {
    url = "https://registry.npmjs.org/typescript/-/typescript-${finalAttrs.version}.tgz";
    hash = "sha256-Z6O8gugiuPRfZTqA/DqXMNIyFNNsg7qF3X9avr7oIGI=";
  src = fetchFromGitHub {
    owner = "microsoft";
    repo = "TypeScript";
    tag = "v${finalAttrs.version}";
    hash = "sha256-OVsvlHtYZhoCtTxdZO6mhVPpIICWEt1Q92Jqrf95jyM=";
  };

  # The upstream GitHub repository's package-lock.json differs from the package.json in the npmjs tarball.
  # For example, package-lock.json for v5.8.3 defines TypeScript as version 5.9.0. Therefore, we should use our own package-lock.json file.
  # These files are typically large due to devDependencies. Removing the devDependencies section is better, especially considering issue #327064.
  #
  # We've removed devDependencies from package-lock.json via updateScript to minimize its size.
  # Now, we must also modify package.json to reflect this change.
  # As TypeScript will then have no dependencies, place an empty node_modules directory.
  postPatch = ''
    ${lib.getExe jq} 'del(.devDependencies)' package.json | ${moreutils}/bin/sponge package.json
    ln -s '${./package-lock.json}' package-lock.json
    mkdir -p node_modules
  '';

  npmDepsHash = "sha256-dyN94wmEA/jtiJCsEs/MoDSd6AFsaq2r25a/FeuqQ5k=";
  forceEmptyCache = true;
  patches = [
    ./disable-dprint-dstBundler.patch
  ];

  dontNpmBuild = true;
  npmDepsHash = "sha256-4ft5168ru+aGPvZAxASQ4wkjtfNG2e0sNhJTedbiKQA=";

  nativeInstallCheckInputs = [
    versionCheckHook
@@ -53,23 +31,11 @@ buildNpmPackage (finalAttrs: {
  versionCheckProgramArg = "--version";

  passthru = {
    updateScript = lib.getExe (writeShellApplication {
      name = "${finalAttrs.pname}-updater";
      runtimeInputs = [
        nodejs
        gnutar
        jq
        nix-update
        prefetch-npm-deps
    updateScript = nix-update-script {
      extraArgs = [
        "--version-regex=^v([\\d.]+)$"
      ];
      runtimeEnv = {
        PNAME = finalAttrs.pname;
        PKG_DIR = builtins.toString ./.;
        FORCE_EMPTY_CACHE = "true";
        OLD_NPM_DEPS_HASH = finalAttrs.npmDepsHash;
    };
      text = builtins.readFile ./update.bash;
    });
  };

  meta = {
@@ -77,9 +43,7 @@ buildNpmPackage (finalAttrs: {
    homepage = "https://www.typescriptlang.org/";
    changelog = "https://github.com/microsoft/TypeScript/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      kachick
    ];
    maintainers = [ ];
    mainProgram = "tsc";
  };
})
+0 −23
Original line number Diff line number Diff line
pkg_file="$PKG_DIR/package.nix"

cd "$PKG_DIR"

# Update lockfile
rm ./package-lock.json
version="$(npm view typescript version)"
npm pack typescript
tar xvf "typescript-${version}.tgz"
# Minimize size of package-lock.json
jq 'del(.devDependencies)' package/package.json > package.json
npm install --package-lock-only
rm -rf ./package ./package.json ./"typescript-${version}.tgz"
NEW_NPM_DEPS_HASH=$(prefetch-npm-deps ./package-lock.json)
cd -

# Update version and src hash
nix-update "$PNAME" --version "$version"

# Update npmDepsHash
pkg_body="$(<"$pkg_file")"
pkg_body="${pkg_body//"$OLD_NPM_DEPS_HASH"/"$NEW_NPM_DEPS_HASH"}"
echo "$pkg_body" >"$pkg_file"