forked from 0xGG/vscode-pwa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy_extensions.js
executable file
·92 lines (87 loc) · 2.49 KB
/
deploy_extensions.js
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
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env node
const path = require("path");
const fse = require("fs-extra");
const child_process = require("child_process");
const extensionsToBuild = process.argv.slice(2);
const extensions = [
{
name: "vscode-web-fs",
copy: ["dist", "package.json"],
commands: ["yarn", "yarn package"],
},
{
name: "vscode-web-ui",
copy: ["dist", "package.json"],
commands: ["yarn", "yarn package"],
},
{
name: "vscode-isomorphic-git",
copy: ["dist", "package.json"],
commands: ["yarn", "yarn package"],
},
];
const myExtensions = [];
extensions.forEach(({ name, copy, commands }) => {
if (
!extensionsToBuild.length ||
extensionsToBuild.find((extensionName) => extensionName === name)
) {
console.log("\n* Adding extension ", name);
fse.rmdirSync(
path.resolve(
__dirname,
`./node_modules/vscode-web/dist/extensions/${name}/`
),
{ recursive: true }
);
fse.mkdirpSync(
path.resolve(
__dirname,
`./node_modules/vscode-web/dist/extensions/${name}/`
)
);
process.chdir(path.resolve(__dirname, `./extensions/${name}/`));
commands.forEach((command) => {
child_process.execSync(command, { stdio: "inherit" });
});
process.chdir(__dirname);
copy.forEach((file) => {
console.log(
`** Copy ./extensions/${name}/${file} to ./node_modules/vscode-web/dist/extensions/${name}/${file}`
);
fse.copySync(
path.resolve(__dirname, `extensions/${name}/${file}`),
path.resolve(
__dirname,
`./node_modules/vscode-web/dist/extensions/${name}/${file}`
),
{ recursive: true, overwrite: true, errorOnExist: true }
);
});
}
const packageJSON = JSON.parse(
fse.readFileSync(
path.resolve(
__dirname,
`./node_modules/vscode-web/dist/extensions/${name}/package.json`
),
{ encoding: "utf-8" }
)
);
myExtensions.push({
packageJSON,
extensionPath: name,
});
});
console.log("* Creating ./src/myExtensions.ts");
let content = `export const extensions: any = ${JSON.stringify(myExtensions)}`;
fse.writeFileSync("./src/myExtensions.ts", content);
console.log("* Creating ./src/builtinExtensions.ts");
content = fse
.readFileSync(
path.resolve(__dirname, "./node_modules/vscode-web/dist/extensions.js"),
{ encoding: "utf8" }
)
.toString()
.replace("var extensions", "export const extensions: any ");
fse.writeFileSync("./src/builtinExtensions.ts", content);