chore: 清理残余文件
This commit is contained in:
8
node_modules/node-pty/scripts/gen-compile-commands.js
generated
vendored
Normal file
8
node_modules/node-pty/scripts/gen-compile-commands.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Microsoft Corporation (MIT License).
|
||||
*/
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
console.log(`\x1b[32m> Generating compile_commands.json...\x1b[0m`);
|
||||
execSync('npx --offline node-gyp configure -- -f compile_commands_json');
|
||||
54
node_modules/node-pty/scripts/increment-version.js
generated
vendored
Normal file
54
node_modules/node-pty/scripts/increment-version.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2019, Microsoft Corporation (MIT License).
|
||||
*/
|
||||
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const packageJson = require('../package.json');
|
||||
|
||||
// Determine if this is a stable or beta release
|
||||
const publishedVersions = getPublishedVersions();
|
||||
const isStableRelease = !publishedVersions.includes(packageJson.version);
|
||||
|
||||
// Get the next version
|
||||
const nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
|
||||
console.log(`Setting version to ${nextVersion}`);
|
||||
|
||||
// Set the version in package.json
|
||||
const packageJsonFile = path.resolve(__dirname, '..', 'package.json');
|
||||
packageJson.version = nextVersion;
|
||||
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
|
||||
|
||||
function getNextBetaVersion() {
|
||||
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
|
||||
console.error('The package.json version must be of the form x.y.z');
|
||||
process.exit(1);
|
||||
}
|
||||
const tag = 'beta';
|
||||
const stableVersion = packageJson.version.split('.');
|
||||
const nextStableVersion = `${stableVersion[0]}.${parseInt(stableVersion[1]) + 1}.0`;
|
||||
const publishedVersions = getPublishedVersions(nextStableVersion, tag);
|
||||
if (publishedVersions.length === 0) {
|
||||
return `${nextStableVersion}-${tag}1`;
|
||||
}
|
||||
const latestPublishedVersion = publishedVersions.sort((a, b) => {
|
||||
const aVersion = parseInt(a.substr(a.search(/[0-9]+$/)));
|
||||
const bVersion = parseInt(b.substr(b.search(/[0-9]+$/)));
|
||||
return aVersion > bVersion ? -1 : 1;
|
||||
})[0];
|
||||
const latestTagVersion = parseInt(latestPublishedVersion.substr(latestPublishedVersion.search(/[0-9]+$/)), 10);
|
||||
return `${nextStableVersion}-${tag}${latestTagVersion + 1}`;
|
||||
}
|
||||
|
||||
function getPublishedVersions(version, tag) {
|
||||
const isWin32 = process.platform === 'win32';
|
||||
const versionsProcess = isWin32 ?
|
||||
cp.spawnSync('npm.cmd', ['view', packageJson.name, 'versions', '--json'], { shell: true }) :
|
||||
cp.spawnSync('npm', ['view', packageJson.name, 'versions', '--json']);
|
||||
const versionsJson = JSON.parse(versionsProcess.stdout);
|
||||
if (tag) {
|
||||
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
|
||||
}
|
||||
return versionsJson;
|
||||
}
|
||||
80
node_modules/node-pty/scripts/post-install.js
generated
vendored
Normal file
80
node_modules/node-pty/scripts/post-install.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
//@ts-check
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const RELEASE_DIR = path.join(__dirname, '../build/Release');
|
||||
const BUILD_FILES = [
|
||||
path.join(RELEASE_DIR, 'conpty.node'),
|
||||
path.join(RELEASE_DIR, 'conpty.pdb'),
|
||||
path.join(RELEASE_DIR, 'conpty_console_list.node'),
|
||||
path.join(RELEASE_DIR, 'conpty_console_list.pdb'),
|
||||
path.join(RELEASE_DIR, 'pty.node'),
|
||||
path.join(RELEASE_DIR, 'pty.pdb'),
|
||||
path.join(RELEASE_DIR, 'spawn-helper'),
|
||||
path.join(RELEASE_DIR, 'winpty-agent.exe'),
|
||||
path.join(RELEASE_DIR, 'winpty-agent.pdb'),
|
||||
path.join(RELEASE_DIR, 'winpty.dll'),
|
||||
path.join(RELEASE_DIR, 'winpty.pdb')
|
||||
];
|
||||
const CONPTY_DIR = path.join(__dirname, '../third_party/conpty');
|
||||
const CONPTY_SUPPORTED_ARCH = ['x64', 'arm64'];
|
||||
|
||||
console.log('\x1b[32m> Cleaning release folder...\x1b[0m');
|
||||
|
||||
/** @param {string} folder */
|
||||
function cleanFolderRecursive(folder) {
|
||||
var files = [];
|
||||
if (fs.existsSync(folder)) {
|
||||
files = fs.readdirSync(folder);
|
||||
files.forEach(function(file,index) {
|
||||
var curPath = path.join(folder, file);
|
||||
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
cleanFolderRecursive(curPath);
|
||||
fs.rmdirSync(curPath);
|
||||
} else if (BUILD_FILES.indexOf(curPath) < 0){ // delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
cleanFolderRecursive(RELEASE_DIR);
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`\x1b[32m> Moving conpty.dll...\x1b[0m`);
|
||||
if (os.platform() !== 'win32') {
|
||||
console.log(' SKIPPED (not Windows)');
|
||||
} else {
|
||||
let windowsArch;
|
||||
if (process.env.npm_config_arch) {
|
||||
windowsArch = process.env.npm_config_arch;
|
||||
console.log(` Using $npm_config_arch: ${windowsArch}`);
|
||||
} else {
|
||||
windowsArch = os.arch();
|
||||
console.log(` Using os.arch(): ${windowsArch}`);
|
||||
}
|
||||
|
||||
if (!CONPTY_SUPPORTED_ARCH.includes(windowsArch)) {
|
||||
console.log(` SKIPPED (unsupported architecture ${windowsArch})`);
|
||||
} else {
|
||||
const versionFolder = fs.readdirSync(CONPTY_DIR)[0];
|
||||
console.log(` Found version ${versionFolder}`);
|
||||
const sourceFolder = path.join(CONPTY_DIR, versionFolder, `win10-${windowsArch}`);
|
||||
const destFolder = path.join(RELEASE_DIR, 'conpty');
|
||||
fs.mkdirSync(destFolder, { recursive: true });
|
||||
for (const file of ['conpty.dll', 'OpenConsole.exe']) {
|
||||
const sourceFile = path.join(sourceFolder, file);
|
||||
const destFile = path.join(destFolder, file);
|
||||
console.log(` Copying ${sourceFile} -> ${destFile}`);
|
||||
fs.copyFileSync(sourceFile, destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
34
node_modules/node-pty/scripts/prebuild.js
generated
vendored
Normal file
34
node_modules/node-pty/scripts/prebuild.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
//@ts-check
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* This script checks for the prebuilt binaries for the current platform and
|
||||
* architecture. It exits with 0 if prebuilds are found and 1 if not.
|
||||
*
|
||||
* If npm_config_build_from_source is set then it removes the prebuilds for the
|
||||
* current platform so they are not loaded at runtime.
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/prebuild.js
|
||||
*/
|
||||
|
||||
const PREBUILDS_ROOT = path.join(__dirname, '..', 'prebuilds');
|
||||
const PREBUILD_DIR = path.join(__dirname, '..', 'prebuilds', `${process.platform}-${process.arch}`);
|
||||
|
||||
// Do not use prebuilds when npm_config_build_from_source is set
|
||||
if (process.env.npm_config_build_from_source === 'true') {
|
||||
console.log('\x1b[33m> Removing prebuilds and rebuilding because npm_config_build_from_source is set\x1b[0m');
|
||||
fs.rmSync(PREBUILDS_ROOT, { recursive: true, force: true });
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Check whether the correct prebuilt files exist
|
||||
console.log('\x1b[32m> Checking prebuilds...\x1b[0m');
|
||||
if (!fs.existsSync(PREBUILD_DIR)) {
|
||||
console.log(`\x1b[33m> Rebuilding because directory ${PREBUILD_DIR} does not exist\x1b[0m`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
Reference in New Issue
Block a user