@sinch/cli 0.4.8 → 0.4.10

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinch/cli",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Official Sinch CLI - Manage all Sinch products from your terminal",
5
5
  "main": "bin/sinch",
6
6
  "bin": {
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * postinstall.js — runs on `npm install -g @sinch/cli`
5
5
  *
6
- * 1. Downloads the platform binary from GitLab Generic Packages
6
+ * 1. Downloads the platform binary from Cloudflare R2
7
7
  * 2. Writes ~/.sinch/completions.json (command tree for PowerShell)
8
8
  * 3. Installs shell completion into the user's profile (PowerShell, zsh, or bash)
9
9
  *
@@ -14,11 +14,11 @@ const fs = require('fs');
14
14
  const path = require('path');
15
15
  const os = require('os');
16
16
  const https = require('https');
17
- const { execSync, spawn } = require('child_process');
17
+ const { spawn } = require('child_process');
18
18
  const { getPlatformBinaryInfo } = require('../bin/platform-resolver');
19
19
 
20
20
  const SINCH_DIR = path.join(os.homedir(), '.sinch');
21
- const PROJECT_ID = '72974711';
21
+ const R2_PUBLIC_URL = 'https://pub-8e148a1cd144409aa2c332e3d724f317.r2.dev';
22
22
 
23
23
  const COMPLETION_COMMANDS = {
24
24
  functions: ['init', 'list', 'deploy', 'download', 'dev', 'status', 'logs', 'delete', 'docs'],
@@ -187,46 +187,11 @@ function installBashZshCompletion() {
187
187
  }
188
188
  }
189
189
 
190
- function getTokenFromNpmConfig() {
191
- try {
192
- const configPaths = [
193
- process.env.npm_config_userconfig,
194
- process.env.NPM_CONFIG_USERCONFIG,
195
- execSync('npm config get userconfig', { encoding: 'utf8' }).trim(),
196
- execSync('npm config get globalconfig', { encoding: 'utf8' }).trim(),
197
- ].filter(Boolean);
198
-
199
- for (const configPath of configPaths) {
200
- if (!fs.existsSync(configPath)) {
201
- continue;
202
- }
203
-
204
- const content = fs.readFileSync(configPath, 'utf8');
205
- const match = content.match(
206
- new RegExp(`//gitlab\\.com/api/v4/projects/${PROJECT_ID}/packages/npm/:_authToken=(.+)`)
207
- );
208
-
209
- if (match?.[1]?.trim()) {
210
- return match[1].trim();
211
- }
212
- }
213
- } catch {
214
- return '';
215
- }
216
-
217
- return '';
218
- }
219
-
220
- function downloadFile(url, dest, token) {
190
+ function downloadFile(url, dest) {
221
191
  return new Promise((resolve, reject) => {
222
- const headers = {};
223
- if (token) {
224
- headers['PRIVATE-TOKEN'] = token;
225
- }
226
-
227
192
  const get = (requestUrl) => {
228
193
  https
229
- .get(requestUrl, { headers }, (response) => {
194
+ .get(requestUrl, (response) => {
230
195
  if (
231
196
  response.statusCode >= 300 &&
232
197
  response.statusCode < 400 &&
@@ -270,12 +235,10 @@ async function downloadBinary(version) {
270
235
  }
271
236
 
272
237
  fs.mkdirSync(distDir, { recursive: true });
273
- const token =
274
- process.env.SINCH_GITLAB_TOKEN || process.env.GITLAB_TOKEN || getTokenFromNpmConfig();
275
- const url = `https://gitlab.com/api/v4/projects/${PROJECT_ID}/packages/generic/sinch-cli/${version}/${binaryInfo.artifactName}`;
238
+ const url = `${R2_PUBLIC_URL}/v${version}/${binaryInfo.artifactName}`;
276
239
 
277
240
  try {
278
- await downloadFile(url, dest, token);
241
+ await downloadFile(url, dest);
279
242
  if (!dest.endsWith('.exe')) {
280
243
  fs.chmodSync(dest, 0o755);
281
244
  }
@@ -284,9 +247,7 @@ async function downloadBinary(version) {
284
247
  fs.rmSync(dest, { force: true });
285
248
  } catch {}
286
249
  console.error(`Failed to download Sinch CLI binary: ${error.message}`);
287
- console.error(
288
- 'You can download the binary manually from GitLab release assets or the generic package registry.'
289
- );
250
+ console.error(`Source: ${url}`);
290
251
  }
291
252
  }
292
253