@tmpxinchen/tmp1 0.0.0-stage → 0.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/a.txt ADDED
@@ -0,0 +1 @@
1
+ hi
Binary file
package/package.json CHANGED
@@ -1,6 +1 @@
1
- {
2
- "name": "@tmpxinchen/tmp1",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {"name":"@tmpxinchen/tmp1","version":"0.0.1","description":"","license":"ISC"}
package/put.js ADDED
@@ -0,0 +1,68 @@
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);
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.