Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Cleanup and remove unused dependencies #154

Merged
merged 3 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/build.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
44 changes: 22 additions & 22 deletions lib/places.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -29,29 +25,33 @@ 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);

return expand(path.resolve(atHome), opts);
}

interface RemotePlaceOptions extends PlaceOptions {
tag?: string;
export function localPlace({
from,
version,
nodeVersion,
platform,
arch,
}: LocalPlaceOptions) {
const binDir = IGNORE_TAG
? path.join(cachePath)
: path.join(cachePath, tagFromVersion(version));

return path.resolve(binDir, `${from}-${nodeVersion}-${platform}-${arch}`);
}

export interface Remote {
tag: string;
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 changes: 1 addition & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions places.json

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"outDir": ".",
"composite": true
},
"files": ["package.json", "places.json", "patches/patches.json"]
"files": ["package.json", "patches/patches.json"]
}
9 changes: 0 additions & 9 deletions typings/expand-template.d.ts

This file was deleted.

13 changes: 0 additions & 13 deletions typings/unique-temp-dir.d.ts

This file was deleted.

Loading