@theia/native-webpack-plugin 1.53.0-next.55 → 1.53.0-next.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -29
- package/lib/native-webpack-plugin.js +10 -10
- package/package.json +2 -2
- package/src/index.ts +18 -18
- package/src/native-webpack-plugin.ts +183 -183
- package/src/package.spec.ts +28 -28
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - NATIVE-WEBPACK-PLUGIN</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
The `@theia/native-webpack-plugin` package contains a webpack plugin that is used to handle native dependencies for bundling Theia based application backends.
|
|
16
|
-
|
|
17
|
-
## Additional Information
|
|
18
|
-
|
|
19
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
20
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
21
|
-
|
|
22
|
-
## License
|
|
23
|
-
|
|
24
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
25
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
26
|
-
|
|
27
|
-
## Trademark
|
|
28
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
29
|
-
https://www.eclipse.org/theia
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - NATIVE-WEBPACK-PLUGIN</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/native-webpack-plugin` package contains a webpack plugin that is used to handle native dependencies for bundling Theia based application backends.
|
|
16
|
+
|
|
17
|
+
## Additional Information
|
|
18
|
+
|
|
19
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
20
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
25
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
26
|
+
|
|
27
|
+
## Trademark
|
|
28
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
29
|
+
https://www.eclipse.org/theia
|
|
@@ -140,22 +140,22 @@ async function buildFile(root, name, content) {
|
|
|
140
140
|
await fs.promises.writeFile(tmpFile, content);
|
|
141
141
|
return tmpFile;
|
|
142
142
|
}
|
|
143
|
-
const ripgrepReplacement = (nativePath = '.') => `
|
|
144
|
-
const path = require('path');
|
|
145
|
-
|
|
146
|
-
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
143
|
+
const ripgrepReplacement = (nativePath = '.') => `
|
|
144
|
+
const path = require('path');
|
|
145
|
+
|
|
146
|
+
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
147
147
|
`;
|
|
148
148
|
const bindingsReplacement = (entries) => {
|
|
149
149
|
const cases = [];
|
|
150
150
|
for (const [module, node] of entries) {
|
|
151
151
|
cases.push(`${' '.repeat(8)}case '${module}': return require('${node}');`);
|
|
152
152
|
}
|
|
153
|
-
return `
|
|
154
|
-
module.exports = function (jsModule) {
|
|
155
|
-
switch (jsModule) {
|
|
156
|
-
${cases.join(os.EOL)}
|
|
157
|
-
}
|
|
158
|
-
throw new Error(\`unhandled module: "\${jsModule}"\`);
|
|
153
|
+
return `
|
|
154
|
+
module.exports = function (jsModule) {
|
|
155
|
+
switch (jsModule) {
|
|
156
|
+
${cases.join(os.EOL)}
|
|
157
|
+
}
|
|
158
|
+
throw new Error(\`unhandled module: "\${jsModule}"\`);
|
|
159
159
|
}`.trim();
|
|
160
160
|
};
|
|
161
161
|
//# sourceMappingURL=native-webpack-plugin.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/native-webpack-plugin",
|
|
3
|
-
"version": "1.53.0-next.
|
|
3
|
+
"version": "1.53.0-next.64+23b351d26",
|
|
4
4
|
"description": "Webpack Plugin for native dependencies of Theia.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"tslib": "^2.6.2",
|
|
33
33
|
"webpack": "^5.76.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "23b351d26346a2b5d6aca3ee81fba59c056132f7"
|
|
36
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { NativeWebpackPlugin } from './native-webpack-plugin';
|
|
18
|
-
export = NativeWebpackPlugin;
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { NativeWebpackPlugin } from './native-webpack-plugin';
|
|
18
|
+
export = NativeWebpackPlugin;
|
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as path from 'path';
|
|
18
|
-
import * as fs from 'fs';
|
|
19
|
-
import * as os from 'os';
|
|
20
|
-
|
|
21
|
-
import type { Compiler } from 'webpack';
|
|
22
|
-
|
|
23
|
-
const REQUIRE_RIPGREP = '@vscode/ripgrep';
|
|
24
|
-
const REQUIRE_VSCODE_WINDOWS_CA_CERTS = '@vscode/windows-ca-certs';
|
|
25
|
-
const REQUIRE_BINDINGS = 'bindings';
|
|
26
|
-
const REQUIRE_KEYMAPPING = './build/Release/keymapping';
|
|
27
|
-
|
|
28
|
-
export interface NativeWebpackPluginOptions {
|
|
29
|
-
out: string;
|
|
30
|
-
trash: boolean;
|
|
31
|
-
ripgrep: boolean;
|
|
32
|
-
pty: boolean;
|
|
33
|
-
replacements?: Record<string, string>;
|
|
34
|
-
nativeBindings?: Record<string, string>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class NativeWebpackPlugin {
|
|
38
|
-
|
|
39
|
-
private bindings = new Map<string, string>();
|
|
40
|
-
private options: NativeWebpackPluginOptions;
|
|
41
|
-
|
|
42
|
-
constructor(options: NativeWebpackPluginOptions) {
|
|
43
|
-
this.options = options;
|
|
44
|
-
for (const [name, value] of Object.entries(options.nativeBindings ?? {})) {
|
|
45
|
-
this.nativeBinding(name, value);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
nativeBinding(dependency: string, nodePath: string): void {
|
|
50
|
-
this.bindings.set(dependency, nodePath);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
apply(compiler: Compiler): void {
|
|
54
|
-
let replacements: Record<string, string> = {};
|
|
55
|
-
compiler.hooks.initialize.tap(NativeWebpackPlugin.name, async () => {
|
|
56
|
-
const directory = path.resolve(compiler.outputPath, 'native-webpack-plugin');
|
|
57
|
-
if (fs.existsSync(directory)) {
|
|
58
|
-
await fs.promises.rm(directory, {
|
|
59
|
-
force: true,
|
|
60
|
-
recursive: true
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
await fs.promises.mkdir(directory, {
|
|
64
|
-
recursive: true
|
|
65
|
-
});
|
|
66
|
-
const bindingsFile = await buildFile(directory, 'bindings.js', bindingsReplacement(Array.from(this.bindings.entries())));
|
|
67
|
-
const ripgrepFile = await buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
68
|
-
const keymappingFile = './build/Release/keymapping.node';
|
|
69
|
-
const windowsCaCertsFile = '@vscode/windows-ca-certs/build/Release/crypt32.node';
|
|
70
|
-
replacements = {
|
|
71
|
-
...(this.options.replacements ?? {}),
|
|
72
|
-
[REQUIRE_RIPGREP]: ripgrepFile,
|
|
73
|
-
[REQUIRE_BINDINGS]: bindingsFile,
|
|
74
|
-
[REQUIRE_KEYMAPPING]: keymappingFile,
|
|
75
|
-
[REQUIRE_VSCODE_WINDOWS_CA_CERTS]: windowsCaCertsFile
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
compiler.hooks.normalModuleFactory.tap(
|
|
79
|
-
NativeWebpackPlugin.name,
|
|
80
|
-
nmf => {
|
|
81
|
-
nmf.hooks.beforeResolve.tap(NativeWebpackPlugin.name, result => {
|
|
82
|
-
for (const [file, replacement] of Object.entries(replacements)) {
|
|
83
|
-
if (result.request === file) {
|
|
84
|
-
result.request = replacement;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
nmf.hooks.afterResolve.tap(NativeWebpackPlugin.name, result => {
|
|
89
|
-
const createData = result.createData;
|
|
90
|
-
for (const [file, replacement] of Object.entries(replacements)) {
|
|
91
|
-
if (createData.resource === file) {
|
|
92
|
-
createData.resource = replacement;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
compiler.hooks.afterEmit.tapPromise(NativeWebpackPlugin.name, async () => {
|
|
99
|
-
if (this.options.trash) {
|
|
100
|
-
await this.copyTrashHelper(compiler);
|
|
101
|
-
}
|
|
102
|
-
if (this.options.ripgrep) {
|
|
103
|
-
await this.copyRipgrep(compiler);
|
|
104
|
-
}
|
|
105
|
-
if (this.options.pty) {
|
|
106
|
-
await this.copyNodePtySpawnHelper(compiler);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
protected async copyRipgrep(compiler: Compiler): Promise<void> {
|
|
112
|
-
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
113
|
-
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}`);
|
|
114
|
-
const targetFile = path.join(compiler.outputPath, this.options.out, `rg${suffix}`);
|
|
115
|
-
await this.copyExecutable(sourceFile, targetFile);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
protected async copyNodePtySpawnHelper(compiler: Compiler): Promise<void> {
|
|
119
|
-
const targetDirectory = path.resolve(compiler.outputPath, '..', 'build', 'Release');
|
|
120
|
-
if (process.platform === 'win32') {
|
|
121
|
-
const agentFile = require.resolve('node-pty/build/Release/winpty-agent.exe');
|
|
122
|
-
const targetAgentFile = path.join(targetDirectory, 'winpty-agent.exe');
|
|
123
|
-
await this.copyExecutable(agentFile, targetAgentFile);
|
|
124
|
-
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
|
|
125
|
-
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
|
|
126
|
-
await this.copyExecutable(dllFile, targetDllFile);
|
|
127
|
-
} else {
|
|
128
|
-
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
|
|
129
|
-
const targetFile = path.join(targetDirectory, 'spawn-helper');
|
|
130
|
-
await this.copyExecutable(sourceFile, targetFile);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
protected async copyTrashHelper(compiler: Compiler): Promise<void> {
|
|
135
|
-
let sourceFile: string | undefined;
|
|
136
|
-
let targetFile: string | undefined;
|
|
137
|
-
if (process.platform === 'win32') {
|
|
138
|
-
sourceFile = require.resolve('trash/lib/windows-trash.exe');
|
|
139
|
-
targetFile = path.join(compiler.outputPath, 'windows-trash.exe');
|
|
140
|
-
} else if (process.platform === 'darwin') {
|
|
141
|
-
sourceFile = require.resolve('trash/lib/macos-trash');
|
|
142
|
-
targetFile = path.join(compiler.outputPath, 'macos-trash');
|
|
143
|
-
}
|
|
144
|
-
if (sourceFile && targetFile) {
|
|
145
|
-
await this.copyExecutable(sourceFile, targetFile);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
protected async copyExecutable(source: string, target: string): Promise<void> {
|
|
150
|
-
const targetDirectory = path.dirname(target);
|
|
151
|
-
await fs.promises.mkdir(targetDirectory, { recursive: true });
|
|
152
|
-
await fs.promises.copyFile(source, target);
|
|
153
|
-
await fs.promises.chmod(target, 0o777);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async function buildFile(root: string, name: string, content: string): Promise<string> {
|
|
158
|
-
const tmpFile = path.join(root, name);
|
|
159
|
-
await fs.promises.writeFile(tmpFile, content);
|
|
160
|
-
return tmpFile;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const ripgrepReplacement = (nativePath: string = '.'): string => `
|
|
164
|
-
const path = require('path');
|
|
165
|
-
|
|
166
|
-
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
167
|
-
`;
|
|
168
|
-
|
|
169
|
-
const bindingsReplacement = (entries: [string, string][]): string => {
|
|
170
|
-
const cases: string[] = [];
|
|
171
|
-
|
|
172
|
-
for (const [module, node] of entries) {
|
|
173
|
-
cases.push(`${' '.repeat(8)}case '${module}': return require('${node}');`);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return `
|
|
177
|
-
module.exports = function (jsModule) {
|
|
178
|
-
switch (jsModule) {
|
|
179
|
-
${cases.join(os.EOL)}
|
|
180
|
-
}
|
|
181
|
-
throw new Error(\`unhandled module: "\${jsModule}"\`);
|
|
182
|
-
}`.trim();
|
|
183
|
-
};
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import * as fs from 'fs';
|
|
19
|
+
import * as os from 'os';
|
|
20
|
+
|
|
21
|
+
import type { Compiler } from 'webpack';
|
|
22
|
+
|
|
23
|
+
const REQUIRE_RIPGREP = '@vscode/ripgrep';
|
|
24
|
+
const REQUIRE_VSCODE_WINDOWS_CA_CERTS = '@vscode/windows-ca-certs';
|
|
25
|
+
const REQUIRE_BINDINGS = 'bindings';
|
|
26
|
+
const REQUIRE_KEYMAPPING = './build/Release/keymapping';
|
|
27
|
+
|
|
28
|
+
export interface NativeWebpackPluginOptions {
|
|
29
|
+
out: string;
|
|
30
|
+
trash: boolean;
|
|
31
|
+
ripgrep: boolean;
|
|
32
|
+
pty: boolean;
|
|
33
|
+
replacements?: Record<string, string>;
|
|
34
|
+
nativeBindings?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class NativeWebpackPlugin {
|
|
38
|
+
|
|
39
|
+
private bindings = new Map<string, string>();
|
|
40
|
+
private options: NativeWebpackPluginOptions;
|
|
41
|
+
|
|
42
|
+
constructor(options: NativeWebpackPluginOptions) {
|
|
43
|
+
this.options = options;
|
|
44
|
+
for (const [name, value] of Object.entries(options.nativeBindings ?? {})) {
|
|
45
|
+
this.nativeBinding(name, value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
nativeBinding(dependency: string, nodePath: string): void {
|
|
50
|
+
this.bindings.set(dependency, nodePath);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
apply(compiler: Compiler): void {
|
|
54
|
+
let replacements: Record<string, string> = {};
|
|
55
|
+
compiler.hooks.initialize.tap(NativeWebpackPlugin.name, async () => {
|
|
56
|
+
const directory = path.resolve(compiler.outputPath, 'native-webpack-plugin');
|
|
57
|
+
if (fs.existsSync(directory)) {
|
|
58
|
+
await fs.promises.rm(directory, {
|
|
59
|
+
force: true,
|
|
60
|
+
recursive: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
await fs.promises.mkdir(directory, {
|
|
64
|
+
recursive: true
|
|
65
|
+
});
|
|
66
|
+
const bindingsFile = await buildFile(directory, 'bindings.js', bindingsReplacement(Array.from(this.bindings.entries())));
|
|
67
|
+
const ripgrepFile = await buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
68
|
+
const keymappingFile = './build/Release/keymapping.node';
|
|
69
|
+
const windowsCaCertsFile = '@vscode/windows-ca-certs/build/Release/crypt32.node';
|
|
70
|
+
replacements = {
|
|
71
|
+
...(this.options.replacements ?? {}),
|
|
72
|
+
[REQUIRE_RIPGREP]: ripgrepFile,
|
|
73
|
+
[REQUIRE_BINDINGS]: bindingsFile,
|
|
74
|
+
[REQUIRE_KEYMAPPING]: keymappingFile,
|
|
75
|
+
[REQUIRE_VSCODE_WINDOWS_CA_CERTS]: windowsCaCertsFile
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
compiler.hooks.normalModuleFactory.tap(
|
|
79
|
+
NativeWebpackPlugin.name,
|
|
80
|
+
nmf => {
|
|
81
|
+
nmf.hooks.beforeResolve.tap(NativeWebpackPlugin.name, result => {
|
|
82
|
+
for (const [file, replacement] of Object.entries(replacements)) {
|
|
83
|
+
if (result.request === file) {
|
|
84
|
+
result.request = replacement;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
nmf.hooks.afterResolve.tap(NativeWebpackPlugin.name, result => {
|
|
89
|
+
const createData = result.createData;
|
|
90
|
+
for (const [file, replacement] of Object.entries(replacements)) {
|
|
91
|
+
if (createData.resource === file) {
|
|
92
|
+
createData.resource = replacement;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
compiler.hooks.afterEmit.tapPromise(NativeWebpackPlugin.name, async () => {
|
|
99
|
+
if (this.options.trash) {
|
|
100
|
+
await this.copyTrashHelper(compiler);
|
|
101
|
+
}
|
|
102
|
+
if (this.options.ripgrep) {
|
|
103
|
+
await this.copyRipgrep(compiler);
|
|
104
|
+
}
|
|
105
|
+
if (this.options.pty) {
|
|
106
|
+
await this.copyNodePtySpawnHelper(compiler);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected async copyRipgrep(compiler: Compiler): Promise<void> {
|
|
112
|
+
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
113
|
+
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}`);
|
|
114
|
+
const targetFile = path.join(compiler.outputPath, this.options.out, `rg${suffix}`);
|
|
115
|
+
await this.copyExecutable(sourceFile, targetFile);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected async copyNodePtySpawnHelper(compiler: Compiler): Promise<void> {
|
|
119
|
+
const targetDirectory = path.resolve(compiler.outputPath, '..', 'build', 'Release');
|
|
120
|
+
if (process.platform === 'win32') {
|
|
121
|
+
const agentFile = require.resolve('node-pty/build/Release/winpty-agent.exe');
|
|
122
|
+
const targetAgentFile = path.join(targetDirectory, 'winpty-agent.exe');
|
|
123
|
+
await this.copyExecutable(agentFile, targetAgentFile);
|
|
124
|
+
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
|
|
125
|
+
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
|
|
126
|
+
await this.copyExecutable(dllFile, targetDllFile);
|
|
127
|
+
} else {
|
|
128
|
+
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
|
|
129
|
+
const targetFile = path.join(targetDirectory, 'spawn-helper');
|
|
130
|
+
await this.copyExecutable(sourceFile, targetFile);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
protected async copyTrashHelper(compiler: Compiler): Promise<void> {
|
|
135
|
+
let sourceFile: string | undefined;
|
|
136
|
+
let targetFile: string | undefined;
|
|
137
|
+
if (process.platform === 'win32') {
|
|
138
|
+
sourceFile = require.resolve('trash/lib/windows-trash.exe');
|
|
139
|
+
targetFile = path.join(compiler.outputPath, 'windows-trash.exe');
|
|
140
|
+
} else if (process.platform === 'darwin') {
|
|
141
|
+
sourceFile = require.resolve('trash/lib/macos-trash');
|
|
142
|
+
targetFile = path.join(compiler.outputPath, 'macos-trash');
|
|
143
|
+
}
|
|
144
|
+
if (sourceFile && targetFile) {
|
|
145
|
+
await this.copyExecutable(sourceFile, targetFile);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
protected async copyExecutable(source: string, target: string): Promise<void> {
|
|
150
|
+
const targetDirectory = path.dirname(target);
|
|
151
|
+
await fs.promises.mkdir(targetDirectory, { recursive: true });
|
|
152
|
+
await fs.promises.copyFile(source, target);
|
|
153
|
+
await fs.promises.chmod(target, 0o777);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function buildFile(root: string, name: string, content: string): Promise<string> {
|
|
158
|
+
const tmpFile = path.join(root, name);
|
|
159
|
+
await fs.promises.writeFile(tmpFile, content);
|
|
160
|
+
return tmpFile;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const ripgrepReplacement = (nativePath: string = '.'): string => `
|
|
164
|
+
const path = require('path');
|
|
165
|
+
|
|
166
|
+
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
const bindingsReplacement = (entries: [string, string][]): string => {
|
|
170
|
+
const cases: string[] = [];
|
|
171
|
+
|
|
172
|
+
for (const [module, node] of entries) {
|
|
173
|
+
cases.push(`${' '.repeat(8)}case '${module}': return require('${node}');`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return `
|
|
177
|
+
module.exports = function (jsModule) {
|
|
178
|
+
switch (jsModule) {
|
|
179
|
+
${cases.join(os.EOL)}
|
|
180
|
+
}
|
|
181
|
+
throw new Error(\`unhandled module: "\${jsModule}"\`);
|
|
182
|
+
}`.trim();
|
|
183
|
+
};
|
package/src/package.spec.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* note: this bogus test file is required so that
|
|
18
|
-
we are able to run mocha unit tests on this
|
|
19
|
-
package, without having any actual unit tests in it.
|
|
20
|
-
This way a coverage report will be generated,
|
|
21
|
-
showing 0% coverage, instead of no report.
|
|
22
|
-
This file can be removed once we have real unit
|
|
23
|
-
tests in place. */
|
|
24
|
-
|
|
25
|
-
describe('request package', () => {
|
|
26
|
-
|
|
27
|
-
it('should support code coverage statistics', () => true);
|
|
28
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* note: this bogus test file is required so that
|
|
18
|
+
we are able to run mocha unit tests on this
|
|
19
|
+
package, without having any actual unit tests in it.
|
|
20
|
+
This way a coverage report will be generated,
|
|
21
|
+
showing 0% coverage, instead of no report.
|
|
22
|
+
This file can be removed once we have real unit
|
|
23
|
+
tests in place. */
|
|
24
|
+
|
|
25
|
+
describe('request package', () => {
|
|
26
|
+
|
|
27
|
+
it('should support code coverage statistics', () => true);
|
|
28
|
+
});
|