@zerct/zerct 0.1.0 → 0.1.2

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 (3) hide show
  1. package/README.md +4 -4
  2. package/bin/zerct.js +38 -22
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -9,13 +9,13 @@ npx @zerct/zerct deploy
9
9
  Target unscoped command, pending npm approval:
10
10
 
11
11
  ```sh
12
- npx zerct init
13
- npx zerct doctor
14
- npx zerct deploy
12
+ npx @zerct/zerct init
13
+ npx @zerct/zerct doctor
14
+ npx @zerct/zerct deploy
15
15
  ```
16
16
 
17
17
  Zerct expects `Cargo.toml`, `Cargo.lock`, and `zerct.toml`. The app must listen
18
18
  on `0.0.0.0:$PORT` and expose the configured health endpoint.
19
19
 
20
- Use `ZERCT_TOKEN` or `npx zerct login --token <token>` for authenticated
20
+ Use `ZERCT_TOKEN` or `npx @zerct/zerct login --token <token>` for authenticated
21
21
  commands.
package/bin/zerct.js CHANGED
@@ -4,11 +4,38 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSy
4
4
  import { homedir } from 'node:os'
5
5
  import path from 'node:path'
6
6
 
7
- const VERSION = '0.1.0'
7
+ const VERSION = '0.1.2'
8
8
  const DEFAULT_API_URL = 'https://api.zerct.com'
9
9
  const ARCHIVE_LIMIT_BYTES = 48 * 1024 * 1024
10
10
  const SESSION_DIR = '.zerct'
11
11
  const SESSION_FILE = 'session-token'
12
+ const ARCHIVE_EXCLUDES = [
13
+ '.git',
14
+ 'target',
15
+ 'node_modules',
16
+ '.zerct',
17
+ '.env',
18
+ '.env.*',
19
+ '.npmrc',
20
+ '.pypirc',
21
+ '.netrc',
22
+ '.ssh',
23
+ '.aws',
24
+ '.azure',
25
+ '.kube',
26
+ '.config/gcloud',
27
+ '*.pem',
28
+ '*.key',
29
+ '*.p12',
30
+ '*.pfx',
31
+ 'id_rsa',
32
+ 'id_ed25519',
33
+ '*.sqlite',
34
+ '*.sqlite3',
35
+ '*.db',
36
+ '*.log',
37
+ '.DS_Store'
38
+ ]
12
39
 
13
40
  const HELP = `Zerct ${VERSION}
14
41
 
@@ -92,7 +119,7 @@ async function main() {
92
119
  await billing(cli)
93
120
  break
94
121
  default:
95
- throw agentError('unknown_command', 'Unknown Zerct command.', 'Run `npx zerct --help` and retry with a supported command.', cli.json)
122
+ throw agentError('unknown_command', 'Unknown Zerct command.', 'Run `npx @zerct/zerct --help` and retry with a supported command.', cli.json)
96
123
  }
97
124
  }
98
125
 
@@ -207,7 +234,7 @@ function doctorProject(projectDir, json) {
207
234
 
208
235
  if (!report.ok) {
209
236
  const firstFailure = report.checks.find((check) => !check.ok)
210
- throw agentError('doctor_failed', 'Zerct doctor failed.', firstFailure?.agent_instruction || 'Fix the failed checks and retry `npx zerct doctor`.', json)
237
+ throw agentError('doctor_failed', 'Zerct doctor failed.', firstFailure?.agent_instruction || 'Fix the failed checks and retry `npx @zerct/zerct doctor`.', json)
211
238
  }
212
239
  }
213
240
 
@@ -267,7 +294,7 @@ async function login(cli) {
267
294
  const response = await apiRequest(cli, 'POST', '/v1/login/device', null, null)
268
295
  openUrl(response.login_url)
269
296
  console.log(`opened ${response.login_url}`)
270
- console.log('After login, retry your deploy. If the CLI cannot finish automatically yet, set ZERCT_TOKEN or run `npx zerct login --token <token>`.')
297
+ console.log('After login, retry your deploy. If the CLI cannot finish automatically yet, set ZERCT_TOKEN or run `npx @zerct/zerct login --token <token>`.')
271
298
  }
272
299
 
273
300
  async function deploy(projectDir, cli) {
@@ -296,7 +323,7 @@ async function deploy(projectDir, cli) {
296
323
  console.log(`queued ${response.build_job.id}`)
297
324
  console.log(`app ${response.app.id}`)
298
325
  console.log(`url ${response.app.url}`)
299
- console.log(`next npx zerct logs --app ${response.app.id}`)
326
+ console.log(`next npx @zerct/zerct logs --app ${response.app.id}`)
300
327
  }
301
328
 
302
329
  async function logs(cli) {
@@ -327,7 +354,7 @@ async function database(cli) {
327
354
 
328
355
  async function envCommand(cli) {
329
356
  if (cli.args[0] !== 'set') {
330
- throw agentError('unknown_command', 'Unknown env command.', 'Use `npx zerct env set --app <app_id> KEY=value`.', cli.json)
357
+ throw agentError('unknown_command', 'Unknown env command.', 'Use `npx @zerct/zerct env set --app <app_id> KEY=value`.', cli.json)
331
358
  }
332
359
 
333
360
  const assignment = cli.args[1] || ''
@@ -366,7 +393,7 @@ async function appGet(cli, kind) {
366
393
 
367
394
  function requireApp(cli) {
368
395
  if (!cli.app) {
369
- throw agentError('missing_app', 'App id is required.', 'Pass `--app <app_id>`. Use the app id printed by `npx zerct deploy`.', cli.json)
396
+ throw agentError('missing_app', 'App id is required.', 'Pass `--app <app_id>`. Use the app id printed by `npx @zerct/zerct deploy`.', cli.json)
370
397
  }
371
398
  return cli.app
372
399
  }
@@ -416,25 +443,14 @@ function parseJson(text) {
416
443
  }
417
444
 
418
445
  function createArchiveBase64(projectDir) {
419
- const tar = spawnSync('tar', [
420
- '--exclude=.git',
421
- '--exclude=target',
422
- '--exclude=node_modules',
423
- '--exclude=.zerct',
424
- '--exclude=.env',
425
- '--exclude=.env.*',
426
- '-czf',
427
- '-',
428
- '-C',
429
- projectDir,
430
- '.'
431
- ], {
446
+ const excludeArgs = ARCHIVE_EXCLUDES.map((pattern) => `--exclude=${pattern}`)
447
+ const tar = spawnSync('tar', [...excludeArgs, '-czf', '-', '-C', projectDir, '.'], {
432
448
  encoding: 'buffer',
433
449
  maxBuffer: ARCHIVE_LIMIT_BYTES + 1024 * 1024
434
450
  })
435
451
 
436
452
  if (tar.error) {
437
- throw agentError('archive_failed', 'Could not create source archive.', 'Install `tar`, remove local build outputs, then retry `npx zerct deploy`.', false)
453
+ throw agentError('archive_failed', 'Could not create source archive.', 'Install `tar`, remove local build outputs, then retry `npx @zerct/zerct deploy`.', false)
438
454
  }
439
455
  if (tar.status !== 0) {
440
456
  throw agentError('archive_failed', 'Could not create source archive.', String(tar.stderr || 'Check project files and retry.'), false)
@@ -473,7 +489,7 @@ function readToken(projectDir, cli) {
473
489
  return readFileSync(homeToken, 'utf8').trim()
474
490
  }
475
491
 
476
- throw agentError('login_required', 'Zerct login is required.', 'Run `npx zerct login`, set `ZERCT_TOKEN`, or run `npx zerct login --token <token>`, then retry.', cli.json)
492
+ throw agentError('login_required', 'Zerct login is required.', 'Run `npx @zerct/zerct login`, set `ZERCT_TOKEN`, or run `npx @zerct/zerct login --token <token>`, then retry.', cli.json)
477
493
  }
478
494
 
479
495
  function writeSessionToken(projectDir, token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerct/zerct",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Deploy Rust backends to Zerct.",
5
5
  "type": "module",
6
6
  "bin": {