zeabur 0.0.1-alpha.3 → 0.2.9
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/index.js +33 -0
- package/package.json +3 -52
- package/zeabur_darwin_amd64_v1/zeabur +0 -0
- package/zeabur_darwin_arm64/zeabur +0 -0
- package/zeabur_linux_amd64_v1/zeabur +0 -0
- package/zeabur_linux_arm64/zeabur +0 -0
- package/zeabur_windows_amd64_v1/zeabur.exe +0 -0
- package/zeabur_windows_arm64/zeabur.exe +0 -0
- package/LICENSE.md +0 -9
- package/README.md +0 -19
- package/dist/zeabur.cjs +0 -17
- package/dist/zeabur.d.ts +0 -18
- package/dist/zeabur.iife.js +0 -17
- package/dist/zeabur.mjs +0 -150
package/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const {join} = require("path");
|
|
6
|
+
|
|
7
|
+
let arch = os.arch();
|
|
8
|
+
if(arch === 'x64') {
|
|
9
|
+
arch = 'amd64_v1';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const availableArch = ['amd64_v1', 'arm64'];
|
|
13
|
+
|
|
14
|
+
if(!availableArch.includes(arch)) {
|
|
15
|
+
console.error(`Unsupported architecture: ${arch}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let platform = os.platform();
|
|
20
|
+
if(platform === 'win32') {
|
|
21
|
+
platform = 'windows';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const availablePlatform = ['windows', 'linux', 'darwin'];
|
|
25
|
+
if(!availablePlatform.includes(platform)) {
|
|
26
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const args = process.argv.slice(2);
|
|
31
|
+
|
|
32
|
+
const pathToBinary = join(__dirname,`./zeabur_${platform}_${arch}/zeabur${platform === 'windows' ? '.exe' : ''}`);
|
|
33
|
+
execSync(`${pathToBinary} ${args.join(' ')}`, {stdio: 'inherit'});
|
package/package.json
CHANGED
|
@@ -1,56 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zeabur",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"module": "./dist/zeabur.mjs",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"require": "./dist/zeabur.cjs",
|
|
10
|
-
"import": "./dist/zeabur.mjs",
|
|
11
|
-
"types": "./dist/zeabur.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/zeabur/zeabur-js.git"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
],
|
|
21
|
-
"author": "MichaelYuhe",
|
|
22
|
-
"license": "MIT",
|
|
23
|
-
"types": "./dist/zeabur.d.ts",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"dev": "vite --host",
|
|
26
|
-
"build": "rimraf dist && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts",
|
|
27
|
-
"lint:scripts": "eslint . --ext .ts",
|
|
28
|
-
"lint:styles": "stylelint ./**/*.{css,scss}",
|
|
29
|
-
"format:scripts": "prettier . --write",
|
|
30
|
-
"format:styles": "stylelint ./**/*.{css,scss} --fix",
|
|
31
|
-
"format": "npm run format:scripts && npm run format:styles",
|
|
32
|
-
"prepare": "husky install && husky set .husky/pre-commit 'npx lint-staged' && git add .husky/pre-commit",
|
|
33
|
-
"uninstall-husky": "npm uninstall husky --no-save && git config --unset core.hooksPath && npx rimraf .husky"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/jsdom": "^21.1.1",
|
|
37
|
-
"@types/node": "^20.4.9",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
39
|
-
"@typescript-eslint/parser": "^6.3.0",
|
|
40
|
-
"dts-bundle-generator": "^8.0.1",
|
|
41
|
-
"eslint": "^8.46.0",
|
|
42
|
-
"eslint-config-prettier": "^9.0.0",
|
|
43
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
44
|
-
"husky": "^8.0.3",
|
|
45
|
-
"lint-staged": "^13.2.3",
|
|
46
|
-
"prettier": "^3.0.1",
|
|
47
|
-
"rimraf": "^5.0.1",
|
|
48
|
-
"stylelint": "^14.16.1",
|
|
49
|
-
"stylelint-config-prettier": "^9.0.5",
|
|
50
|
-
"stylelint-config-recommended": "^9.0.0",
|
|
51
|
-
"stylelint-prettier": "^3.0.0",
|
|
52
|
-
"ts-node": "^10.9.1",
|
|
53
|
-
"typescript": "^5.1.6",
|
|
54
|
-
"vite": "^4.4.9"
|
|
3
|
+
"version": "0.2.9",
|
|
4
|
+
"bin": {
|
|
5
|
+
"zeabur": "index.js"
|
|
55
6
|
}
|
|
56
7
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/LICENSE.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 MichaelYuhe
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# `Zeabur-js`
|
|
2
|
-
|
|
3
|
-
Official JavaScript client for Zeabur.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
First, install the package:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install zeabur
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Then, you're able to import the library and initialize it with your API key:
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
16
|
-
import { createClient } from "zeabur";
|
|
17
|
-
|
|
18
|
-
const zeabur = createClient("your key here");
|
|
19
|
-
```
|
package/dist/zeabur.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var y=(a,e,t)=>e in a?p(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>(y(a,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(){let a="";const e="abcdefghijklmnopqrstuvwxyz",t=e.length;for(let r=0;r<6;r++)a+=e.charAt(Math.floor(Math.random()*t));return a}const c="https://gateway.zeabur.com/graphql";class m{constructor(e){h(this,"apiKey");this.apiKey=e}async createProject(e){try{const t=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({query:`mutation CreateProject($region: String!) {
|
|
2
|
-
createProject(region: $region) {
|
|
3
|
-
_id
|
|
4
|
-
}
|
|
5
|
-
}`,variables:{region:e}})}),{data:r}=await t.json();return r.createProject._id}catch(t){throw console.error(t),t}}async createService(e,t){try{const r=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({query:`mutation CreateService($projectID: ObjectID!, $template: ServiceTemplate!, $name: String!) {
|
|
6
|
-
createService(projectID: $projectID, template: $template, name: $name) {
|
|
7
|
-
_id
|
|
8
|
-
}
|
|
9
|
-
}`,variables:{projectID:e,template:"GIT",name:t}})}),{data:o}=await r.json();return o.createService._id}catch(r){throw console.error(r),r}}async getEnvironment(e){try{const t=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({query:`query GetEnvironment($projectID: ObjectID!) {
|
|
10
|
-
environments(projectID: $projectID) {
|
|
11
|
-
_id
|
|
12
|
-
}
|
|
13
|
-
}`,variables:{projectID:e}})}),{data:r}=await t.json();return r.environments[0]._id}catch(t){throw console.error(t),t}}async createDomain(e,t,r,o){try{const n=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({query:`mutation CreateDomain($serviceID: ObjectID!, $environmentID: ObjectID!, $domain: String!, $isGenerated: Boolean!) {
|
|
14
|
-
addDomain(serviceID: $serviceID, environmentID: $environmentID, domain: $domain, isGenerated: $isGenerated) {
|
|
15
|
-
domain
|
|
16
|
-
}
|
|
17
|
-
}`,variables:{serviceID:e,environmentID:t,domain:o??`${r+l()}`,isGenerated:!0}})}),{data:i}=await n.json();return i.addDomain.domain}catch(n){throw console.error(n),n}}async deploy(e,t,r,o){try{if(!e)throw new Error("Code is required");const n=await this.createProject(t),i=await this.getEnvironment(n),d=await this.createService(n,r),s=new FormData;return s.append("environment",i),s.append("code",e,"code.zip"),await fetch(`https://gateway.zeabur.com/projects/${n}/services/${d}/deploy`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:s}),await this.createDomain(d,i,r,o)}catch(n){throw console.error(n),n}}}const u=a=>new m(a);exports.ZeaburClient=m;exports.createClient=u;
|
package/dist/zeabur.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v8.0.1
|
|
2
|
-
|
|
3
|
-
declare enum Region {
|
|
4
|
-
sfo1 = "sfo1",
|
|
5
|
-
hkg1 = "hkg1"
|
|
6
|
-
}
|
|
7
|
-
export declare class ZeaburClient {
|
|
8
|
-
private apiKey;
|
|
9
|
-
constructor(apiKey: string);
|
|
10
|
-
private createProject;
|
|
11
|
-
private createService;
|
|
12
|
-
private getEnvironment;
|
|
13
|
-
private createDomain;
|
|
14
|
-
deploy(code: Blob, projectRegion: keyof typeof Region, serviceName: string, domainName?: string): Promise<string>;
|
|
15
|
-
}
|
|
16
|
-
export declare const createClient: (apiKey: string) => ZeaburClient;
|
|
17
|
-
|
|
18
|
-
export {};
|
package/dist/zeabur.iife.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var zeabur=function(n){"use strict";var u=Object.defineProperty;var j=(n,i,o)=>i in n?u(n,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[i]=o;var p=(n,i,o)=>(j(n,typeof i!="symbol"?i+"":i,o),o);function i(){let c="";const r="abcdefghijklmnopqrstuvwxyz",e=r.length;for(let t=0;t<6;t++)c+=r.charAt(Math.floor(Math.random()*e));return c}const o="https://gateway.zeabur.com/graphql";class m{constructor(r){p(this,"apiKey");this.apiKey=r}async createProject(r){try{const e=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({query:`mutation CreateProject($region: String!) {
|
|
2
|
-
createProject(region: $region) {
|
|
3
|
-
_id
|
|
4
|
-
}
|
|
5
|
-
}`,variables:{region:r}})}),{data:t}=await e.json();return t.createProject._id}catch(e){throw console.error(e),e}}async createService(r,e){try{const t=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({query:`mutation CreateService($projectID: ObjectID!, $template: ServiceTemplate!, $name: String!) {
|
|
6
|
-
createService(projectID: $projectID, template: $template, name: $name) {
|
|
7
|
-
_id
|
|
8
|
-
}
|
|
9
|
-
}`,variables:{projectID:r,template:"GIT",name:e}})}),{data:s}=await t.json();return s.createService._id}catch(t){throw console.error(t),t}}async getEnvironment(r){try{const e=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({query:`query GetEnvironment($projectID: ObjectID!) {
|
|
10
|
-
environments(projectID: $projectID) {
|
|
11
|
-
_id
|
|
12
|
-
}
|
|
13
|
-
}`,variables:{projectID:r}})}),{data:t}=await e.json();return t.environments[0]._id}catch(e){throw console.error(e),e}}async createDomain(r,e,t,s){try{const a=await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({query:`mutation CreateDomain($serviceID: ObjectID!, $environmentID: ObjectID!, $domain: String!, $isGenerated: Boolean!) {
|
|
14
|
-
addDomain(serviceID: $serviceID, environmentID: $environmentID, domain: $domain, isGenerated: $isGenerated) {
|
|
15
|
-
domain
|
|
16
|
-
}
|
|
17
|
-
}`,variables:{serviceID:r,environmentID:e,domain:s??`${t+i()}`,isGenerated:!0}})}),{data:d}=await a.json();return d.addDomain.domain}catch(a){throw console.error(a),a}}async deploy(r,e,t,s){try{if(!r)throw new Error("Code is required");const a=await this.createProject(e),d=await this.getEnvironment(a),y=await this.createService(a,t),h=new FormData;return h.append("environment",d),h.append("code",r,"code.zip"),await fetch(`https://gateway.zeabur.com/projects/${a}/services/${y}/deploy`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:h}),await this.createDomain(y,d,t,s)}catch(a){throw console.error(a),a}}}const l=c=>new m(c);return n.ZeaburClient=m,n.createClient=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n}({});
|
package/dist/zeabur.mjs
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
var m = Object.defineProperty;
|
|
2
|
-
var p = (a, e, t) => e in a ? m(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
-
var d = (a, e, t) => (p(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
function y() {
|
|
5
|
-
let a = "";
|
|
6
|
-
const e = "abcdefghijklmnopqrstuvwxyz", t = e.length;
|
|
7
|
-
for (let r = 0; r < 6; r++)
|
|
8
|
-
a += e.charAt(Math.floor(Math.random() * t));
|
|
9
|
-
return a;
|
|
10
|
-
}
|
|
11
|
-
const c = "https://gateway.zeabur.com/graphql";
|
|
12
|
-
class l {
|
|
13
|
-
constructor(e) {
|
|
14
|
-
d(this, "apiKey");
|
|
15
|
-
this.apiKey = e;
|
|
16
|
-
}
|
|
17
|
-
// Create a Project
|
|
18
|
-
async createProject(e) {
|
|
19
|
-
try {
|
|
20
|
-
const t = await fetch(c, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: {
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
25
|
-
},
|
|
26
|
-
body: JSON.stringify({
|
|
27
|
-
query: `mutation CreateProject($region: String!) {
|
|
28
|
-
createProject(region: $region) {
|
|
29
|
-
_id
|
|
30
|
-
}
|
|
31
|
-
}`,
|
|
32
|
-
variables: { region: e }
|
|
33
|
-
})
|
|
34
|
-
}), { data: r } = await t.json();
|
|
35
|
-
return r.createProject._id;
|
|
36
|
-
} catch (t) {
|
|
37
|
-
throw console.error(t), t;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// Create a Service
|
|
41
|
-
async createService(e, t) {
|
|
42
|
-
try {
|
|
43
|
-
const r = await fetch(c, {
|
|
44
|
-
method: "POST",
|
|
45
|
-
headers: {
|
|
46
|
-
"Content-Type": "application/json",
|
|
47
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
48
|
-
},
|
|
49
|
-
body: JSON.stringify({
|
|
50
|
-
query: `mutation CreateService($projectID: ObjectID!, $template: ServiceTemplate!, $name: String!) {
|
|
51
|
-
createService(projectID: $projectID, template: $template, name: $name) {
|
|
52
|
-
_id
|
|
53
|
-
}
|
|
54
|
-
}`,
|
|
55
|
-
variables: {
|
|
56
|
-
projectID: e,
|
|
57
|
-
template: "GIT",
|
|
58
|
-
name: t
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}), { data: n } = await r.json();
|
|
62
|
-
return n.createService._id;
|
|
63
|
-
} catch (r) {
|
|
64
|
-
throw console.error(r), r;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
// Get Environment ID
|
|
68
|
-
async getEnvironment(e) {
|
|
69
|
-
try {
|
|
70
|
-
const t = await fetch(c, {
|
|
71
|
-
method: "POST",
|
|
72
|
-
headers: {
|
|
73
|
-
"Content-Type": "application/json",
|
|
74
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
75
|
-
},
|
|
76
|
-
body: JSON.stringify({
|
|
77
|
-
query: `query GetEnvironment($projectID: ObjectID!) {
|
|
78
|
-
environments(projectID: $projectID) {
|
|
79
|
-
_id
|
|
80
|
-
}
|
|
81
|
-
}`,
|
|
82
|
-
variables: {
|
|
83
|
-
projectID: e
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
}), { data: r } = await t.json();
|
|
87
|
-
return r.environments[0]._id;
|
|
88
|
-
} catch (t) {
|
|
89
|
-
throw console.error(t), t;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// Create a Domain
|
|
93
|
-
async createDomain(e, t, r, n) {
|
|
94
|
-
try {
|
|
95
|
-
const o = await fetch(c, {
|
|
96
|
-
method: "POST",
|
|
97
|
-
headers: {
|
|
98
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
99
|
-
"Content-Type": "application/json"
|
|
100
|
-
},
|
|
101
|
-
body: JSON.stringify({
|
|
102
|
-
query: `mutation CreateDomain($serviceID: ObjectID!, $environmentID: ObjectID!, $domain: String!, $isGenerated: Boolean!) {
|
|
103
|
-
addDomain(serviceID: $serviceID, environmentID: $environmentID, domain: $domain, isGenerated: $isGenerated) {
|
|
104
|
-
domain
|
|
105
|
-
}
|
|
106
|
-
}`,
|
|
107
|
-
variables: {
|
|
108
|
-
serviceID: e,
|
|
109
|
-
environmentID: t,
|
|
110
|
-
domain: n ?? `${r + y()}`,
|
|
111
|
-
isGenerated: !0
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
}), { data: i } = await o.json();
|
|
115
|
-
return i.addDomain.domain;
|
|
116
|
-
} catch (o) {
|
|
117
|
-
throw console.error(o), o;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// Deploy Codes to Zeabur and Get a Domain
|
|
121
|
-
async deploy(e, t, r, n) {
|
|
122
|
-
try {
|
|
123
|
-
if (!e)
|
|
124
|
-
throw new Error("Code is required");
|
|
125
|
-
const o = await this.createProject(t), i = await this.getEnvironment(o), h = await this.createService(o, r), s = new FormData();
|
|
126
|
-
return s.append("environment", i), s.append("code", e, "code.zip"), await fetch(
|
|
127
|
-
`https://gateway.zeabur.com/projects/${o}/services/${h}/deploy`,
|
|
128
|
-
{
|
|
129
|
-
method: "POST",
|
|
130
|
-
headers: {
|
|
131
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
132
|
-
},
|
|
133
|
-
body: s
|
|
134
|
-
}
|
|
135
|
-
), await this.createDomain(
|
|
136
|
-
h,
|
|
137
|
-
i,
|
|
138
|
-
r,
|
|
139
|
-
n
|
|
140
|
-
);
|
|
141
|
-
} catch (o) {
|
|
142
|
-
throw console.error(o), o;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const D = (a) => new l(a);
|
|
147
|
-
export {
|
|
148
|
-
l as ZeaburClient,
|
|
149
|
-
D as createClient
|
|
150
|
-
};
|