Comparing version 0.2.0 to 0.3.0
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 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
9528
7
138
3
5
+ Addedminimist@^1.2.0
+ Addedrimraf@^3.0.0
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)