Cleanup, remove unused dependencies (#154)
* places: simplify and remove dependency on "expand-template" * Remove dependency on "unique-temp-dir" * Remove unused dependencies
This commit is contained in:
parent
532fb10d91
commit
b47c260d38
@ -1,14 +1,17 @@
|
||||
import os from 'os';
|
||||
import crypto from 'crypto';
|
||||
import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { spawnSync } from 'child_process';
|
||||
import uniqueTempDir from 'unique-temp-dir';
|
||||
|
||||
import { hostArch, hostPlatform } from './system';
|
||||
import { log } from './log';
|
||||
import patchesJson from '../patches/patches.json';
|
||||
|
||||
const buildPath = path.resolve(process.env.PKG_BUILD_PATH || uniqueTempDir());
|
||||
const buildPath = path.resolve(
|
||||
process.env.PKG_BUILD_PATH ||
|
||||
path.join(os.tmpdir(), `pkg.${crypto.randomBytes(12).toString('hex')}`)
|
||||
);
|
||||
const nodePath = path.join(buildPath, 'node');
|
||||
const patchesPath = path.resolve(__dirname, '../patches');
|
||||
const nodeRepo = 'https://github.com/nodejs/node';
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
import { major, minor } from 'semver';
|
||||
import expandTemplate from 'expand-template';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import placesJson from '../places.json';
|
||||
|
||||
const expand = expandTemplate();
|
||||
|
||||
const { PKG_CACHE_PATH } = process.env;
|
||||
const IGNORE_TAG = Boolean(process.env.PKG_IGNORE_TAG);
|
||||
@ -29,18 +25,18 @@ interface LocalPlaceOptions extends PlaceOptions {
|
||||
from: string;
|
||||
}
|
||||
|
||||
export function localPlace(opts: LocalPlaceOptions) {
|
||||
const p = placesJson.localPlace;
|
||||
const { version } = opts;
|
||||
const atHome = IGNORE_TAG
|
||||
? path.join(cachePath, p)
|
||||
: path.join(cachePath, tagFromVersion(version), p);
|
||||
export function localPlace({
|
||||
from,
|
||||
version,
|
||||
nodeVersion,
|
||||
platform,
|
||||
arch,
|
||||
}: LocalPlaceOptions) {
|
||||
const binDir = IGNORE_TAG
|
||||
? path.join(cachePath)
|
||||
: path.join(cachePath, tagFromVersion(version));
|
||||
|
||||
return expand(path.resolve(atHome), opts);
|
||||
}
|
||||
|
||||
interface RemotePlaceOptions extends PlaceOptions {
|
||||
tag?: string;
|
||||
return path.resolve(binDir, `${from}-${nodeVersion}-${platform}-${arch}`);
|
||||
}
|
||||
|
||||
export interface Remote {
|
||||
@ -48,10 +44,14 @@ export interface Remote {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function remotePlace(opts: RemotePlaceOptions): Remote {
|
||||
const p = placesJson.remotePlace;
|
||||
const { version } = opts;
|
||||
const tag = tagFromVersion(version);
|
||||
Object.assign(opts, { tag });
|
||||
return { tag, name: expand(p, opts) };
|
||||
export function remotePlace({
|
||||
version,
|
||||
nodeVersion,
|
||||
platform,
|
||||
arch,
|
||||
}: PlaceOptions): Remote {
|
||||
return {
|
||||
tag: tagFromVersion(version),
|
||||
name: `node-${nodeVersion}-${platform}-${arch}`,
|
||||
};
|
||||
}
|
||||
|
||||
36
package.json
36
package.json
@ -10,58 +10,24 @@
|
||||
},
|
||||
"files": [
|
||||
"lib-es5/*.js",
|
||||
"patches/*",
|
||||
"places.json"
|
||||
"patches/*"
|
||||
],
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"@babel/plugin-transform-async-to-generator",
|
||||
"@babel/plugin-transform-runtime"
|
||||
],
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "4"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"axios": "^0.21.1",
|
||||
"byline": "^5.0.0",
|
||||
"chalk": "^4.1.0",
|
||||
"expand-template": "^2.0.3",
|
||||
"fs-extra": "^9.1.0",
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"progress": "^2.0.3",
|
||||
"semver": "^7.3.5",
|
||||
"unique-temp-dir": "^1.0.0",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.13.10",
|
||||
"@babel/core": "^7.13.10",
|
||||
"@babel/eslint-parser": "^7.13.10",
|
||||
"@babel/plugin-transform-async-to-generator": "^7.13.0",
|
||||
"@babel/plugin-transform-runtime": "^7.13.10",
|
||||
"@babel/preset-env": "^7.13.12",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@octokit/core": "^3.3.1",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^5.0.0",
|
||||
"@types/byline": "^4.2.32",
|
||||
"@types/fs-extra": "^9.0.9",
|
||||
"@types/isomorphic-fetch": "^0.0.35",
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/progress": "^2.0.3",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@types/yargs": "^16.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.19.0",
|
||||
"@typescript-eslint/parser": "^4.19.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"localPlace": "{from}-{nodeVersion}-{platform}-{arch}",
|
||||
"remotePlace": "node-{nodeVersion}-{platform}-{arch}"
|
||||
}
|
||||
@ -14,5 +14,5 @@
|
||||
"outDir": ".",
|
||||
"composite": true
|
||||
},
|
||||
"files": ["package.json", "places.json", "patches/patches.json"]
|
||||
"files": ["package.json", "patches/patches.json"]
|
||||
}
|
||||
|
||||
9
typings/expand-template.d.ts
vendored
9
typings/expand-template.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
declare module 'expand-template' {
|
||||
function expandTemplate(): (
|
||||
template: string,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
variables: object
|
||||
) => string;
|
||||
|
||||
export default expandTemplate;
|
||||
}
|
||||
13
typings/unique-temp-dir.d.ts
vendored
13
typings/unique-temp-dir.d.ts
vendored
@ -1,13 +0,0 @@
|
||||
declare module 'unique-temp-dir' {
|
||||
interface UniqueTempDirOptions {
|
||||
create?: boolean;
|
||||
length?: number;
|
||||
thunk?: boolean;
|
||||
}
|
||||
|
||||
function uniqueTempDir(
|
||||
options?: UniqueTempDirOptions
|
||||
): string;
|
||||
|
||||
export default uniqueTempDir;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user