@tmpxinchen/tmp1 0.0.1 → 1.0.1
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/MANIFEST.json +14 -0
- package/chunk.bin +4 -0
- package/package.json +12 -1
- package/reassemble.sh +57 -0
- package/a.txt +0 -1
- package/hello-xc-pkg-0.0.1.tgz +0 -0
- package/put.js +0 -68
package/MANIFEST.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "@tmpxinchen/tmp1",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"chunkIndex": 1,
|
|
5
|
+
"totalChunks": 44,
|
|
6
|
+
"chunkFile": "chunk.bin",
|
|
7
|
+
"chunkBytes": 94371840,
|
|
8
|
+
"chunkSha256": "4c4b1b86ef51c7aa8515e0c69ebcb74829244d6cb8110827080fee27435b7872",
|
|
9
|
+
"sourceFile": "gitlab-ce-18.11.12.tar",
|
|
10
|
+
"sourceBytes": 4148393984,
|
|
11
|
+
"sourceSha256": "6fa679d1a99a65bbdf157086f4a3943e5f40c48275375c961b6d64eaa627bb8b",
|
|
12
|
+
"createdAt": "2026-10-21T07:15:44.397Z",
|
|
13
|
+
"rejoin": "tar -xf gitlab-ce-18.11.12.tar # after ./reassemble.sh gitlab-ce-18.11.12.tar 1.0.1"
|
|
14
|
+
}
|
package/chunk.bin
ADDED
package/package.json
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@tmpxinchen/tmp1",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "gitlab-ce-18.11.12.tar transfer chunk 1/44",
|
|
5
|
+
"files": [
|
|
6
|
+
"chunk.bin",
|
|
7
|
+
"MANIFEST.json",
|
|
8
|
+
"reassemble.sh"
|
|
9
|
+
],
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"author": "xinchen12"
|
|
12
|
+
}
|
package/reassemble.sh
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Reassemble the split tarball published as npm packages.
|
|
3
|
+
# usage: ./reassemble.sh <out-file> [first-version]
|
|
4
|
+
# example: ./reassemble.sh gitlab-ce-18.11.12.tar 1.0.1
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
PKG="@tmpxinchen/tmp1"
|
|
7
|
+
OUT="${1:?usage: reassemble.sh <out-file> [first-version]}"
|
|
8
|
+
START="${2:-1.0.1}"
|
|
9
|
+
WORK="$(mktemp -d)"
|
|
10
|
+
trap 'rm -rf "$WORK"' EXIT
|
|
11
|
+
|
|
12
|
+
echo "[1/3] listing versions of $PKG ..."
|
|
13
|
+
npm view "$PKG" versions --json > "$WORK/versions.json"
|
|
14
|
+
python3 - "$WORK/versions.json" "$START" > "$WORK/list.txt" <<'PY'
|
|
15
|
+
import json, re, sys
|
|
16
|
+
vs = json.load(open(sys.argv[1]))
|
|
17
|
+
start = sys.argv[2]
|
|
18
|
+
def key(v):
|
|
19
|
+
return tuple(int(x) for x in re.findall(r'\d+', v))
|
|
20
|
+
vs = [v for v in vs if '-' not in v and key(v) >= key(start)]
|
|
21
|
+
for v in sorted(vs, key=key):
|
|
22
|
+
print(v)
|
|
23
|
+
PY
|
|
24
|
+
[[ -s "$WORK/list.txt" ]] || { echo "no versions >= $START found"; exit 1; }
|
|
25
|
+
echo " $(wc -l < "$WORK/list.txt") chunks: $(head -1 "$WORK/list.txt") .. $(tail -1 "$WORK/list.txt")"
|
|
26
|
+
|
|
27
|
+
echo "[2/3] downloading + verifying chunks ..."
|
|
28
|
+
: > "$OUT"
|
|
29
|
+
i=0
|
|
30
|
+
total=$(wc -l < "$WORK/list.txt")
|
|
31
|
+
src_sha=""; src_size=0
|
|
32
|
+
while read -r v; do
|
|
33
|
+
i=$((i+1))
|
|
34
|
+
mkdir -p "$WORK/$v"
|
|
35
|
+
npm pack "$PKG@$v" --silent --pack-destination "$WORK" >/dev/null
|
|
36
|
+
tar -xzf "$WORK/$PKG-$(echo "$v" | sed 's|.*/||')" -C "$WORK/$v" 2>/dev/null || \
|
|
37
|
+
tar -xzf "$WORK"/tmpxinchen-tmp1-"$v".tgz -C "$WORK/$v"
|
|
38
|
+
python3 - "$WORK/$v/package/MANIFEST.json" "$i" "$OUT" <<'PY'
|
|
39
|
+
import hashlib, json, sys
|
|
40
|
+
m = json.load(open(sys.argv[1]))
|
|
41
|
+
idx = int(sys.argv[2]); out = sys.argv[3]
|
|
42
|
+
assert m["chunkIndex"] == idx, f'order mismatch: expected {idx}, got {m["chunkIndex"]}'
|
|
43
|
+
data = open(m["chunkFile"], 'rb').read()
|
|
44
|
+
assert len(data) == m["chunkBytes"], f'chunk {idx} size mismatch'
|
|
45
|
+
assert hashlib.sha256(data).hexdigest() == m["chunkSha256"], f'chunk {idx} sha256 mismatch'
|
|
46
|
+
with open(out, 'ab') as f:
|
|
47
|
+
f.write(data)
|
|
48
|
+
print(f" chunk {idx}/{m['totalChunks']} v{m['version']} ok ({m['chunkBytes']} bytes)")
|
|
49
|
+
PY
|
|
50
|
+
src_sha=$(python3 -c "import json;print(json.load(open('$WORK/$v/package/MANIFEST.json'))['sourceSha256'])")
|
|
51
|
+
src_size=$(python3 -c "import json;print(json.load(open('$WORK/$v/package/MANIFEST.json'))['sourceBytes'])")
|
|
52
|
+
done < "$WORK/list.txt"
|
|
53
|
+
|
|
54
|
+
echo "[3/3] verifying reassembled file ..."
|
|
55
|
+
[[ "$(wc -c < "$OUT")" -eq "$src_size" ]] || { echo "size mismatch"; exit 1; }
|
|
56
|
+
echo "$src_sha $OUT" | sha256sum -c -
|
|
57
|
+
echo "done: $OUT"
|
package/a.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hi
|
package/hello-xc-pkg-0.0.1.tgz
DELETED
|
Binary file
|
package/put.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Diagnose npm publish: send a real publish payload and print the registry's raw response.
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const https = require('https');
|
|
5
|
-
const crypto = require('crypto');
|
|
6
|
-
const { execFileSync } = require('child_process');
|
|
7
|
-
|
|
8
|
-
const dir = process.argv[2];
|
|
9
|
-
const name = process.argv[3];
|
|
10
|
-
const version = process.argv[4];
|
|
11
|
-
const token = fs.readFileSync(path.join(process.env.HOME, 'npm-pubish/.npmrc'), 'utf8').match(/npm_\w+/)[0];
|
|
12
|
-
|
|
13
|
-
const pkgPath = path.join(dir, 'package.json');
|
|
14
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
15
|
-
pkg.name = name; pkg.version = version;
|
|
16
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg));
|
|
17
|
-
|
|
18
|
-
const tgzName = execFileSync('npm', ['pack', '--silent', '--pack-destination', dir], { cwd: dir }).toString().trim().split('\n').pop();
|
|
19
|
-
const tgz = fs.readFileSync(path.join(dir, tgzName));
|
|
20
|
-
const shasum = crypto.createHash('sha1').update(tgz).digest('hex');
|
|
21
|
-
const integrity = 'sha512-' + crypto.createHash('sha512').update(tgz).digest('base64');
|
|
22
|
-
const shortName = name.replace(/^@[^/]+\//, '');
|
|
23
|
-
|
|
24
|
-
const tarballUrl = `https://registry.npmjs.org/${name}/-/${shortName}-${version}.tgz`;
|
|
25
|
-
const body = {
|
|
26
|
-
_id: name,
|
|
27
|
-
name,
|
|
28
|
-
description: pkg.description || '',
|
|
29
|
-
'dist-tags': { latest: version },
|
|
30
|
-
versions: {
|
|
31
|
-
[version]: {
|
|
32
|
-
...pkg,
|
|
33
|
-
_id: `${name}@${version}`,
|
|
34
|
-
dist: { tarball: tarballUrl, shasum, integrity },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
access: 'public',
|
|
38
|
-
_attachments: {
|
|
39
|
-
[`${shortName}-${version}.tgz`]: {
|
|
40
|
-
content_type: 'application/octet-stream',
|
|
41
|
-
data: tgz.toString('base64'),
|
|
42
|
-
length: tgz.length,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const payload = JSON.stringify(body);
|
|
48
|
-
const url = new URL(`https://registry.npmjs.org/${encodeURIComponent(name)}`);
|
|
49
|
-
const req = https.request({
|
|
50
|
-
method: 'PUT',
|
|
51
|
-
hostname: url.hostname,
|
|
52
|
-
path: url.pathname,
|
|
53
|
-
headers: {
|
|
54
|
-
authorization: `Bearer ${token}`,
|
|
55
|
-
'content-type': 'application/json',
|
|
56
|
-
'content-length': Buffer.byteLength(payload),
|
|
57
|
-
'npm-command': 'publish',
|
|
58
|
-
},
|
|
59
|
-
}, (res) => {
|
|
60
|
-
let d = '';
|
|
61
|
-
res.on('data', (c) => (d += c));
|
|
62
|
-
res.on('end', () => {
|
|
63
|
-
console.log(`HTTP ${res.statusCode}`);
|
|
64
|
-
console.log(d.slice(0, 800));
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
req.on('error', (e) => console.error('ERR', e.message));
|
|
68
|
-
req.end(payload);
|