-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathprepareAdditionalExtensions.js
More file actions
79 lines (68 loc) · 2.5 KB
/
prepareAdditionalExtensions.js
File metadata and controls
79 lines (68 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// @ts-check
const { chdir, execSync, existsSync, log, rimraf } = require("./util");
const { argv } = require("./argv");
const { writeFileSync } = require("fs");
const additionalExtensions = [
{
name: "solidity-extension",
repo: "https://github.com/contractshark/vscode-solidity-extension.git",
branchOrTag: "v1.6.0",
getPackageJSON: () =>
// @ts-ignore
require("../additional-extensions/solidity-extension/package.json"),
},
{
name: "vyper-syntax",
repo: "https://github.com/tintinweb/vscode-vyper.git",
branchOrTag: "v0.0.15",
getPackageJSON: () =>
// @ts-ignore
require("../additional-extensions/vyper-syntax/package.json"),
},
];
function prepareAdditionalExtensions() {
log.info("============ Cloning additional built-in extensions...");
chdir(__dirname, "../additional-extensions");
for (const ext of additionalExtensions) {
if (argv.force) rimraf(`./${ext.name}`);
if (existsSync(ext.name)) {
log.info(
`./additional-extensions/${ext.name} directory already exists — cloning skipped`
);
} else {
execSync(
`git clone --depth 1 --branch ${ext.branchOrTag} ${ext.repo} ${ext.name}`,
{ stdio: "inherit" }
);
/** @type {import("child_process").ExecSyncOptions} */
const options = { stdio: "inherit", cwd: `./${ext.name}` };
const packageJSON = ext.getPackageJSON();
if ("package-web" in packageJSON.scripts) {
log.info(`Installing dependencies for ${ext.name}...`);
execSync(["yarn", argv.verbose && "--verbose"], options);
log.info(`Compiling ${ext.name}...`);
execSync(["yarn package-web", argv.verbose && "--verbose"], options);
} else {
log.info(`Installing production dependencies for ${ext.name}...`);
if (ext.name === 'solidity-extension') {
execSync(["npm install", argv.verbose && "--verbose"], options);
} else {
execSync(["yarn --production", argv.verbose && "--verbose"], options);
}
}
// create empty metadata file if doesnt exist so vscode doesnt complain
if (!existsSync(`./${ext.name}/package.nls.json`)) {
writeFileSync(
`./${ext.name}/package.nls.json`,
JSON.stringify({
displayName: "Deth",
description: "deth",
}),
"utf8"
);
}
}
}
}
module.exports = { prepareAdditionalExtensions, additionalExtensions };
if (require.main === module) prepareAdditionalExtensions();