anycloud 0.0.28 → 0.0.30

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 (37) hide show
  1. package/binaries/anycloud-darwin-arm64 +0 -0
  2. package/binaries/anycloud-darwin-x64 +0 -0
  3. package/binaries/anycloud-linux-arm64 +0 -0
  4. package/binaries/anycloud-linux-x64 +0 -0
  5. package/dist/cli/commands/config/edit.js +3 -3
  6. package/dist/cli/commands/config/edit.js.map +1 -1
  7. package/dist/cli/commands/config/new.js +3 -3
  8. package/dist/cli/commands/config/new.js.map +1 -1
  9. package/dist/cli/commands/credentials/edit.js +16 -15
  10. package/dist/cli/commands/credentials/edit.js.map +1 -1
  11. package/dist/cli/commands/credentials/new.js +8 -7
  12. package/dist/cli/commands/credentials/new.js.map +1 -1
  13. package/dist/cli/commands/list.js +12 -14
  14. package/dist/cli/commands/list.js.map +1 -1
  15. package/dist/cli/commands/logs.js +39 -0
  16. package/dist/cli/commands/logs.js.map +1 -0
  17. package/dist/cli/commands/ssh.js +23 -158
  18. package/dist/cli/commands/ssh.js.map +1 -1
  19. package/dist/cli/commands/status.js +21 -23
  20. package/dist/cli/commands/status.js.map +1 -1
  21. package/dist/cli/commands/terminate.js +16 -16
  22. package/dist/cli/commands/terminate.js.map +1 -1
  23. package/dist/cli/index.js +2 -0
  24. package/dist/cli/index.js.map +1 -1
  25. package/dist/cli/services/config.js +3 -34
  26. package/dist/cli/services/config.js.map +1 -1
  27. package/dist/cli/services/non-interactive.js +4 -3
  28. package/dist/cli/services/non-interactive.js.map +1 -1
  29. package/dist/cli/services/ssh.js +197 -0
  30. package/dist/cli/services/ssh.js.map +1 -0
  31. package/dist/shared/cloud-config.js +159 -0
  32. package/dist/shared/cloud-config.js.map +1 -0
  33. package/dist/shared/types.js +33 -106
  34. package/dist/shared/types.js.map +1 -1
  35. package/dist/shared/utils.js +72 -2
  36. package/dist/shared/utils.js.map +1 -1
  37. package/package.json +2 -1
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Escape a string for safe use as a shell argument.
3
+ * Wraps in single quotes and escapes any single quotes within.
4
+ * This is the safest approach as single quotes prevent all shell interpretation.
5
+ */
6
+ export function shellEscape(arg) {
7
+ // Replace single quotes with: end quote, escaped single quote, start quote
8
+ // e.g., "it's" becomes 'it'\''s'
9
+ return "'" + arg.replace(/'/g, "'\\''") + "'";
10
+ }
1
11
  /** Format milliseconds as human-readable string */
2
12
  export function formatMs(ms) {
3
13
  const minutes = ms / 60000;
@@ -5,7 +15,67 @@ export function formatMs(ms) {
5
15
  }
6
16
  /** Helper to add a timeout to a promise */
7
17
  export async function withTimeout(promise, timeoutMs, operationName) {
8
- const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error(`${operationName} timed out after ${formatMs(timeoutMs)}`)), timeoutMs));
9
- return Promise.race([promise, timeout]);
18
+ let timeoutId;
19
+ const timeout = new Promise((_, reject) => {
20
+ timeoutId = setTimeout(() => reject(new Error(`${operationName} timed out after ${formatMs(timeoutMs)}`)), timeoutMs);
21
+ });
22
+ try {
23
+ return await Promise.race([promise, timeout]);
24
+ }
25
+ finally {
26
+ clearTimeout(timeoutId);
27
+ }
28
+ }
29
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
30
+ /**
31
+ * Retry an operation until it succeeds or max attempts reached.
32
+ * Retries all errors - transient ones get fixed, permanent ones fail after max attempts.
33
+ */
34
+ export async function withRetry(operation, name, options = {}) {
35
+ const { maxAttempts = 3, waitMs = 5000, onRetry } = options;
36
+ let lastError;
37
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
38
+ try {
39
+ return await operation();
40
+ }
41
+ catch (error) {
42
+ lastError = error;
43
+ if (attempt < maxAttempts) {
44
+ onRetry?.(attempt, maxAttempts, error);
45
+ await sleep(waitMs);
46
+ }
47
+ }
48
+ }
49
+ throw lastError;
50
+ }
51
+ /**
52
+ * Poll until all items pass the check function.
53
+ * @throws Error if timeout is reached before all items pass
54
+ */
55
+ export async function pollUntilReady(options) {
56
+ const { items, getKey, check, intervalMs = 10000, timeoutMs, timeoutLabel, } = options;
57
+ const pending = new Set(items.map(getKey));
58
+ const poll = async () => {
59
+ while (pending.size > 0) {
60
+ const results = await Promise.all(items
61
+ .filter((item) => pending.has(getKey(item)))
62
+ .map(async (item) => {
63
+ try {
64
+ return { key: getKey(item), ready: await check(item) };
65
+ }
66
+ catch {
67
+ return { key: getKey(item), ready: false };
68
+ }
69
+ }));
70
+ for (const { key, ready } of results) {
71
+ if (ready)
72
+ pending.delete(key);
73
+ }
74
+ if (pending.size > 0) {
75
+ await sleep(intervalMs);
76
+ }
77
+ }
78
+ };
79
+ await withTimeout(poll(), timeoutMs, timeoutLabel);
10
80
  }
11
81
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,OAAO,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3B,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,UAAU,CAAC;AAC3D,CAAC;AAED,2CAA2C;AAC3C,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAmB,EACnB,SAAiB,EACjB,aAAqB;IAErB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAC/C,UAAU,CACR,GAAG,EAAE,CACH,MAAM,CACJ,IAAI,KAAK,CAAC,GAAG,aAAa,oBAAoB,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CACrE,EACH,SAAS,CACV,CACF,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../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EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzD,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;gBAC7C,CAAC;YACH,CAAC,CAAC,CACL,CAAC;YAEF,KAAK,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC;gBACrC,IAAI,KAAK;oBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;YAED,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,WAAW,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACrD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anycloud",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "Deploy containerized jobs and servers to any cloud provider",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -28,6 +28,7 @@
28
28
  "deploy:staging": "yarn migrate:staging && yarn deploy:check:staging && wrangler deploy --env staging",
29
29
  "deploy:check:prod": "export $(cat .dev.vars.prod | xargs) && DEPLOY_ENV=production npx tsx scripts/pre-deploy-check.ts",
30
30
  "deploy:prod": "yarn migrate:prod && yarn deploy:check:prod && wrangler deploy --env production",
31
+ "logs:prod": "export $(cat .dev.vars.prod | xargs) && DEPLOY_ENV=production npx tsx scripts/get-deployment-logs.ts",
31
32
  "cli": "CONDUCTOR_URL=https://conductor.laplazahealth.org node ./dist/cli/index.js",
32
33
  "cli:prod": "node ./dist/cli/index.js",
33
34
  "start:conductor": "node ./dist/conductor/server.js",