New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vscode-dts

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-dts - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

.prettierrc.json

204

index.js
#!/usr/bin/env node
const https = require('https')
const fs = require('fs')
const path = require('path')
const os = require('os')
const prompts = require('prompts')
const PROPOSED_DTS_URL = 'https://raw.githubusercontent.com/microsoft/vscode/master/src/vs/vscode.proposed.d.ts'
const realArgs = process.argv.slice(2)
if (realArgs.length === 0 || realArgs[0] === '-h' || realArgs[0] === '--help') {
console.log(printHelp())
} else if (realArgs[0] === 'dev') {
const outPath = path.resolve(process.cwd(), './vscode.proposed.d.ts')
console.log(`Downloading vscode.proposed.d.ts to ${outPath}`)
download(PROPOSED_DTS_URL, outPath).then(() => {
console.log('Please set "enableProposedApi": true in package.json.')
console.log('Read more about proposed API at: https://code.visualstudio.com/api/advanced-topics/using-proposed-api')
})
} else if (realArgs[0]) {
const url = `https://raw.githubusercontent.com/microsoft/vscode/${realArgs[0]}/src/vs/vscode.d.ts`
const outPath = path.resolve(process.cwd(), './vscode.d.ts')
console.log(`Downloading vscode.d.ts to ${outPath} from ${url}`)
download(url, outPath).then(() => {
removeNodeModulesTypes()
})
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
var https_1 = __importDefault(require("https"));
var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path"));
var os_1 = __importDefault(require("os"));
var prompts_1 = __importDefault(require("prompts"));
var minimist_1 = __importDefault(require("minimist"));
var rimraf_1 = __importDefault(require("rimraf"));
var argv = minimist_1["default"](process.argv.slice(2));
if (argv._.length === 0 || argv['h'] || argv['help']) {
console.log(getHelpMessage());
}
function printHelp() {
return [
'vscode-dts: CLI utility for downloading vscode.d.ts and vscode.proposed.d.ts',
'',
'Usage:',
' - npx vscode-dts dev Download vscode.proposed.d.ts',
' - npx vscode-dts <git-tag> Download vscode.d.ts from git tag of microsoft/vscode',
' - npx vscode-dts <git-branch> Download vscode.d.ts from git branch of microsoft/vscode',
' - npx vscode-dts Print Help',
' - npx vscode-dts -h Print Help',
' - npx vscode-dts --help Print Help'
].join(os.EOL)
else if (argv._[0] === 'dev') {
handleDev(argv._[1]);
}
else if (argv._[0]) {
handleDefaultDownload(argv._[0], argv['f']);
}
function handleDev(gitTagOrBranch) {
var url = gitTagOrBranch
? "https://raw.githubusercontent.com/microsoft/vscode/" + gitTagOrBranch + "/src/vs/vscode.proposed.d.ts"
: 'https://raw.githubusercontent.com/microsoft/vscode/master/src/vs/vscode.proposed.d.ts';
var outPath = path_1["default"].resolve(process.cwd(), './vscode.proposed.d.ts');
console.log("Downloading vscode.proposed.d.ts to " + outPath);
download(url, outPath).then(function () {
console.log("Please set " + toRedString("\"enableProposedApi\": true") + " in package.json.");
console.log('Read more about proposed API at: https://code.visualstudio.com/api/advanced-topics/using-proposed-api');
});
}
function handleDefaultDownload(gitTagOrBranch, force) {
var url = "https://raw.githubusercontent.com/microsoft/vscode/" + gitTagOrBranch + "/src/vs/vscode.d.ts";
var outPath = path_1["default"].resolve(process.cwd(), './vscode.d.ts');
console.log("Downloading vscode.d.ts to " + outPath + " from " + url);
download(url, outPath).then(function () {
if (force) {
forceRemoveNodeModulesTypes();
}
else {
removeNodeModulesTypes();
}
});
}
function getHelpMessage() {
return [
'vscode-dts: CLI utility for downloading vscode.d.ts and vscode.proposed.d.ts',
'',
'Usage:',
' - npx vscode-dts dev Download vscode.proposed.d.ts',
' - npx vscode-dts dev <git-tag | git-branch> Download vscode.proposed.d.ts from git tag/branch of microsoft/vscode',
' - npx vscode-dts <git-tag | git-branch> Download vscode.d.ts from git tag/branch of microsoft/vscode',
' - npx vscode-dts <git-tag | git-branch> -f Download vscode.d.ts and remove comflicing types in node_modules/@types/vscode',
' - npx vscode-dts Print Help',
' - npx vscode-dts -h Print Help',
' - npx vscode-dts --help Print Help'
].join(os_1["default"].EOL);
}
function download(url, outPath) {
return new Promise((resolve, reject) => {
https.get(url, res => {
if (res.statusCode !== 200) {
reject(`Failed to get ${url}`)
return
}
const outStream = fs.createWriteStream(outPath)
outStream.on('close', () => {
resolve()
})
res.pipe(outStream)
})
})
return new Promise(function (resolve, reject) {
https_1["default"].get(url, function (res) {
if (res.statusCode !== 200) {
reject("Failed to get " + url);
return;
}
var outStream = fs_1["default"].createWriteStream(outPath);
outStream.on('close', function () {
resolve();
});
res.pipe(outStream);
});
});
}
function forceRemoveNodeModulesTypes() {
if (fs_1["default"].existsSync('node_modules/vscode/vscode.d.ts')) {
fs_1["default"].unlinkSync('node_modules/vscode/vscode.d.ts');
console.log('Removed node_modules/vscode/vscode.d.ts');
}
else if (fs_1["default"].existsSync('node_modules/@types/vscode/index.d.ts')) {
rimraf_1["default"]('node_modules/@types/vscode', function (err) {
if (err) {
console.error('Failed to remove node_modules/@types/vscode');
console.error(err);
}
else {
console.log('Removed node_modules/@types/vscode');
}
});
}
}
function removeNodeModulesTypes() {
if (fs.existsSync('node_modules/vscode/vscode.d.ts')) {
prompts({
type: 'confirm',
name: 'value',
message: 'Remove conflicting vscode typing at node_modules/vscode/vscode.d.ts?'
}).then(res => {
if(res.value) {
fs.unlinkSync('node_modules/vscode/vscode.d.ts')
console.log('Removed node_modules/vscode/vscode.d.ts')
}
})
} else if (fs.existsSync('node_modules/@types/vscode/index.d.ts')) {
prompts({
type: 'confirm',
name: 'value',
message: 'Remove conflicting vscode typing at node_modules/@types/vscode/index.d.ts?'
}).then(res => {
if(res.value) {
fs.unlinkSync('node_modules/@types/vscode/index.d.ts')
console.log('Removed node_modules/@types/vscode/index.d.ts')
}
})
}
}
if (fs_1["default"].existsSync('node_modules/vscode/vscode.d.ts')) {
prompts_1["default"]({
type: 'confirm',
name: 'value',
message: 'Remove conflicting vscode typing at node_modules/vscode/vscode.d.ts?'
}).then(function (res) {
if (res.value) {
fs_1["default"].unlinkSync('node_modules/vscode/vscode.d.ts');
console.log('Removed node_modules/vscode/vscode.d.ts');
}
});
}
else if (fs_1["default"].existsSync('node_modules/@types/vscode/index.d.ts')) {
prompts_1["default"]({
type: 'confirm',
name: 'value',
message: 'Remove conflicting vscode typing at node_modules/@types/vscode?'
}).then(function (res) {
if (res.value) {
rimraf_1["default"]('node_modules/@types/vscode', function (err) {
if (err) {
console.error('Failed to remove node_modules/@types/vscode');
console.error(err);
}
else {
console.log('Removed node_modules/@types/vscode');
}
});
}
});
}
}
function toRedString(s) {
return "\u001B[31m" + s + "\u001B[0m";
}
{
"name": "vscode-dts",
"version": "0.2.0",
"description": "CLI utility for downloading vscode.d.ts and vscode.proposed.d.ts",
"bin": "index.js",
"author": {
"name": "Microsoft Corporation"
},
"license": "MIT",
"devDependencies": {
"@types/node": "^12.0.2"
},
"dependencies": {
"prompts": "^2.1.0"
}
"name": "vscode-dts",
"version": "0.3.0",
"description": "CLI utility for downloading vscode.d.ts and vscode.proposed.d.ts",
"author": {
"name": "Microsoft Corporation"
},
"bin": "index.js",
"scripts": {
"compile": "tsc -p .",
"watch": "tsc -w -p .",
"prepublishOnly": "tsc -p ."
},
"license": "MIT",
"dependencies": {
"minimist": "^1.2.0",
"prompts": "^2.1.0",
"rimraf": "^3.0.0"
},
"devDependencies": {
"@types/minimist": "^1.2.0",
"@types/node": "^12.0.2",
"@types/prompts": "^2.0.1",
"@types/rimraf": "^2.0.2",
"typescript": "^3.6.2"
}
}

@@ -12,9 +12,9 @@ # vscode-dts

Usage:
- npx vscode-dts dev Download vscode.proposed.d.ts
- npx vscode-dts <git-tag> Download vscode.d.ts from git tag of microsoft/vscode
- npx vscode-dts <git-branch> Download vscode.d.ts from git branch of microsoft/vscode
- npx vscode-dts Print Help
- npx vscode-dts -h Print Help
- npx vscode-dts --help Print Help
~ >
- npx vscode-dts dev Download vscode.proposed.d.ts
- npx vscode-dts dev <git-tag | git-branch> Download vscode.proposed.d.ts from git tag/branch of microsoft/vscode
- npx vscode-dts <git-tag | git-branch> Download vscode.d.ts from git tag/branch of microsoft/vscode
- npx vscode-dts <git-tag | git-branch> -f Download vscode.d.ts and remove comflicing types in node_modules/@types/vscode
- npx vscode-dts Print Help
- npx vscode-dts -h Print Help
- npx vscode-dts --help Print Help
```

@@ -21,0 +21,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc