403Webshell
Server IP : 188.151.22.197  /  Your IP : 216.73.217.74
Web Server : Apache/2.4.62 (Rocky Linux) OpenSSL/3.5.5
System : Linux wsten.se 5.14.0-687.30.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 13:09:21 UTC 2026 x86_64
User : apache ( 48)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/gitlab/embedded/service/gitlab-rails/scripts/frontend/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/gitlab/embedded/service/gitlab-rails/scripts/frontend/preinstall.mjs
import { join } from 'node:path';
import { readFile, rm } from 'node:fs/promises';

const ROOT_PATH = join(import.meta.dirname, '..', '..');
const NODE_MODULES = join(ROOT_PATH, 'node_modules');
const INTEGRITY_FILE = join(NODE_MODULES, '.yarn-integrity');
const PACKAGE_JSON = join(ROOT_PATH, 'package.json');

function isAliasedDependency(x) {
  return x.includes('@npm:');
}
function serializeAliasedDependencyPatterns(obj) {
  return Object.entries(obj).map(([key, version]) => `${key}@${version}`);
}

async function readJSON(file) {
  return JSON.parse(await readFile(file, { encoding: 'utf-8' }));
}

async function getPrevTopLevelPatterns() {
  try {
    return (await readJSON(INTEGRITY_FILE))?.topLevelPatterns?.filter(isAliasedDependency);
  } catch {
    return [];
  }
}
async function getCurrentTopLevelPatterns() {
  try {
    const { dependencies, devDependencies } = await readJSON(PACKAGE_JSON);

    return serializeAliasedDependencyPatterns(dependencies)
      .concat(serializeAliasedDependencyPatterns(devDependencies))
      .filter(dep => isAliasedDependency(dep));
  } catch {
    return [];
  }
}

function arraysHaveSameItems(a1, a2) {
  return JSON.stringify(a1.sort()) === JSON.stringify(a2.sort());
}

const [prevTopLevelPatterns, currentTopLevelPatterns] = await Promise.all([
  getPrevTopLevelPatterns(),
  getCurrentTopLevelPatterns(),
]);

/**
 * Yarn seems to have problems at times, if one uses an <alias>@npm:<name>
 *  and those packages are being updated. In case one switches branches the
 *  node_modules folder seems to end up being a corrupted somehow
 */
if (!arraysHaveSameItems(prevTopLevelPatterns, currentTopLevelPatterns)) {
  console.error(
    '[WARNING] package.json changed significantly. Removing node_modules to be sure there are no problems.',
  );
  await rm(NODE_MODULES, { recursive: true, force: true });
}

Youez - 2016 - github.com/yon3zu
LinuXploit