@jspreadsheet/install 1.1.0 → 1.2.0

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.
Files changed (2) hide show
  1. package/index.js +11 -9
  2. package/package.json +2 -4
package/index.js CHANGED
@@ -242,16 +242,19 @@ function getInstallCommand(pkg) {
242
242
 
243
243
  function registerEmail(email) {
244
244
  return new Promise((resolve) => {
245
- const data = JSON.stringify({ email });
245
+ const payload = JSON.stringify({ email });
246
+ const { version } = require('./package.json');
246
247
 
247
248
  const options = {
248
249
  hostname: 'jspreadsheet.com',
249
250
  port: 443,
250
- path: '/me/register',
251
+ path: '/register',
251
252
  method: 'POST',
252
253
  headers: {
253
254
  'Content-Type': 'application/json',
254
- 'Content-Length': Buffer.byteLength(data),
255
+ 'Content-Length': Buffer.byteLength(payload),
256
+ 'User-Agent': `jspreadsheet-install/${version} (node ${process.version})`,
257
+ 'Accept': 'text/plain',
255
258
  },
256
259
  };
257
260
 
@@ -259,17 +262,16 @@ function registerEmail(email) {
259
262
  let body = '';
260
263
  res.on('data', (chunk) => body += chunk);
261
264
  res.on('end', () => {
262
- try {
263
- const result = JSON.parse(body);
264
- resolve(result.license || null);
265
- } catch (e) {
266
- resolve(null);
265
+ if (res.statusCode < 200 || res.statusCode >= 300) {
266
+ return resolve(null);
267
267
  }
268
+ const license = body.trim();
269
+ resolve(license || null);
268
270
  });
269
271
  });
270
272
 
271
273
  req.on('error', () => resolve(null));
272
- req.write(data);
274
+ req.write(payload);
273
275
  req.end();
274
276
  });
275
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jspreadsheet/install",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Interactive installer for Jspreadsheet",
5
5
  "bin": {
6
6
  "@jspreadsheet/install": "index.js",
@@ -16,8 +16,6 @@
16
16
  "author": "Jspreadsheet",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@inquirer/prompts": "^7.10.1",
20
- "@jspreadsheet-ce/react": "^5.0.2",
21
- "@jspreadsheet/vue": "^12.4.2"
19
+ "@inquirer/prompts": "^7.10.1"
22
20
  }
23
21
  }