Skip to content

Commit 83bedb7

Browse files
committed
Do not download curlconverter to avoid build failed
The checksum of the bundled curlconverter can be verified via the following command: ``` sha256sum \ build/package-generators/curlconverter/curlconverter-4.9.0.tgz \ <(curl -s "$(npm view [email protected] dist.tarball)") ``` The output should be like the following: ``` 5730a24feb6a18ab26728f68b304446740269b0e7eb73e4c3592b323cb3ad354 build/package-generators/curlconverter/curlconverter-4.9.0.tgz 5730a24feb6a18ab26728f68b304446740269b0e7eb73e4c3592b323cb3ad354 /proc/self/fd/11 ```
1 parent 5f78251 commit 83bedb7

File tree

5 files changed

+7770
-33
lines changed

5 files changed

+7770
-33
lines changed

build/package-generators/curlconverter.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,30 @@ const path = require('path')
66

77
const buildDir = execEnv.buildDir
88
const packageJsonPath = path.join(buildDir, 'package.json')
9+
const packageLockPath = path.join(buildDir, 'package-lock.json')
10+
911
const projectDir = process.env.PROJECT_CWD
12+
const tarballPath = path.join(
13+
projectDir,
14+
'build',
15+
'package-generators',
16+
'curlconverter',
17+
'curlconverter-4.9.0.tgz',
18+
)
19+
const packageLockSourcePath = path.join(
20+
projectDir,
21+
'build',
22+
'package-generators',
23+
'curlconverter',
24+
'package-lock.json',
25+
)
26+
const patchPath = path.join(
27+
projectDir,
28+
'build',
29+
'package-generators',
30+
'curlconverter',
31+
'curlconverter.patch',
32+
)
1033

1134
process.on('uncaughtException', err => {
1235
if (err.stdout?.length) {
@@ -19,33 +42,13 @@ process.on('uncaughtException', err => {
1942
throw err
2043
})
2144

22-
// Target version
23-
const version = '4.9.0'
24-
25-
// Get URLs
26-
const tarballUrl = child_process
27-
.execFileSync('npm', ['view', `curlconverter@${version}`, 'dist.tarball'])
28-
.toString()
29-
.trim()
30-
const packageLockUrl = `https://raw.githubusercontent.com/curlconverter/curlconverter/v${version}/package-lock.json`
31-
32-
// Download files
33-
const tarballPath = path.join(execEnv.tempDir, 'tarball.tgz')
34-
const packageLockPath = path.join(buildDir, 'package-lock.json')
35-
child_process.execFileSync('curl', ['-s', tarballUrl, '-o', tarballPath])
36-
child_process.execFileSync('curl', [
37-
'-s',
38-
packageLockUrl,
39-
'-o',
40-
packageLockPath,
41-
])
42-
43-
// Extract tarball
45+
// Prepare source files
4446
child_process.execFileSync(
4547
'tar',
4648
['-xf', tarballPath, '--strip-components=1'],
4749
{ cwd: buildDir },
4850
)
51+
fs.cpSync(packageLockSourcePath, packageLockPath)
4952

5053
// Remove all generators except json
5154
child_process.execFileSync(
@@ -59,16 +62,10 @@ fs.writeFileSync(
5962
)
6063

6164
// Patch packages
62-
child_process.execFileSync(
63-
'patch',
64-
[
65-
'-p',
66-
'1',
67-
'-i',
68-
path.join(projectDir, 'build/package-generators/curlconverter.patch'),
69-
],
70-
{ cwd: buildDir },
71-
)
65+
child_process.execFileSync('patch', ['-p', '1', '-i', patchPath], {
66+
cwd: buildDir,
67+
})
68+
7269
const newPackageJson = child_process
7370
.execFileSync('jq', [
7471
'del(.bin) | del(.browser) | del(.dependencies."@curlconverter/tree-sitter") | del(.scripts.prepare) | .dependencies.nan = "^2.22.0"',
@@ -77,6 +74,7 @@ const newPackageJson = child_process
7774
.toString()
7875
.trim()
7976
fs.writeFileSync(packageJsonPath, newPackageJson)
77+
8078
child_process.execFileSync('rm', [
8179
'-rf',
8280
path.join(buildDir, 'dist/src'),
@@ -89,6 +87,8 @@ child_process.execFileSync('rm', [
8987
child_process.execFileSync('npm', ['install'], {
9088
cwd: buildDir,
9189
})
90+
91+
// Build package
9292
child_process.execFileSync('npm', ['run', 'compile'], { cwd: buildDir })
9393

9494
// Cleanup
Binary file not shown.

0 commit comments

Comments
 (0)