@orchestr-sh/orchestr 1.9.6 → 1.9.7
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/dist/Console/Commands/DeployCommand.d.ts +16 -0
- package/dist/Console/Commands/DeployCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployCommand.js +153 -0
- package/dist/Console/Commands/DeployCommand.js.map +1 -0
- package/dist/Console/Commands/DeployEnvCommand.d.ts +20 -0
- package/dist/Console/Commands/DeployEnvCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployEnvCommand.js +160 -0
- package/dist/Console/Commands/DeployEnvCommand.js.map +1 -0
- package/dist/Console/Commands/DeployInitCommand.d.ts +19 -0
- package/dist/Console/Commands/DeployInitCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployInitCommand.js +90 -0
- package/dist/Console/Commands/DeployInitCommand.js.map +1 -0
- package/dist/Console/Commands/DeployLoginCommand.d.ts +14 -0
- package/dist/Console/Commands/DeployLoginCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployLoginCommand.js +54 -0
- package/dist/Console/Commands/DeployLoginCommand.js.map +1 -0
- package/dist/Console/Commands/DeployProvisionCommand.d.ts +15 -0
- package/dist/Console/Commands/DeployProvisionCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployProvisionCommand.js +96 -0
- package/dist/Console/Commands/DeployProvisionCommand.js.map +1 -0
- package/dist/Console/Commands/DeployRollbackCommand.d.ts +13 -0
- package/dist/Console/Commands/DeployRollbackCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployRollbackCommand.js +62 -0
- package/dist/Console/Commands/DeployRollbackCommand.js.map +1 -0
- package/dist/Console/Commands/DeployServerCommand.d.ts +18 -0
- package/dist/Console/Commands/DeployServerCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployServerCommand.js +131 -0
- package/dist/Console/Commands/DeployServerCommand.js.map +1 -0
- package/dist/Console/Commands/DeployStatusCommand.d.ts +14 -0
- package/dist/Console/Commands/DeployStatusCommand.d.ts.map +1 -0
- package/dist/Console/Commands/DeployStatusCommand.js +72 -0
- package/dist/Console/Commands/DeployStatusCommand.js.map +1 -0
- package/dist/Console/orchestr.js +17 -0
- package/dist/Console/orchestr.js.map +1 -1
- package/dist/Deploy/CredentialStore.d.ts +31 -0
- package/dist/Deploy/CredentialStore.d.ts.map +1 -0
- package/dist/Deploy/CredentialStore.js +59 -0
- package/dist/Deploy/CredentialStore.js.map +1 -0
- package/dist/Deploy/Deployer.d.ts +32 -0
- package/dist/Deploy/Deployer.d.ts.map +1 -0
- package/dist/Deploy/Deployer.js +88 -0
- package/dist/Deploy/Deployer.js.map +1 -0
- package/dist/Deploy/ProjectConfig.d.ts +26 -0
- package/dist/Deploy/ProjectConfig.d.ts.map +1 -0
- package/dist/Deploy/ProjectConfig.js +47 -0
- package/dist/Deploy/ProjectConfig.js.map +1 -0
- package/dist/Deploy/Provisioner.d.ts +47 -0
- package/dist/Deploy/Provisioner.d.ts.map +1 -0
- package/dist/Deploy/Provisioner.js +119 -0
- package/dist/Deploy/Provisioner.js.map +1 -0
- package/dist/Deploy/SSHConnection.d.ts +38 -0
- package/dist/Deploy/SSHConnection.d.ts.map +1 -0
- package/dist/Deploy/SSHConnection.js +82 -0
- package/dist/Deploy/SSHConnection.js.map +1 -0
- package/dist/Deploy/SymphonyClient.d.ts +158 -0
- package/dist/Deploy/SymphonyClient.d.ts.map +1 -0
- package/dist/Deploy/SymphonyClient.js +117 -0
- package/dist/Deploy/SymphonyClient.js.map +1 -0
- package/dist/Deploy/TarBuilder.d.ts +18 -0
- package/dist/Deploy/TarBuilder.d.ts.map +1 -0
- package/dist/Deploy/TarBuilder.js +52 -0
- package/dist/Deploy/TarBuilder.js.map +1 -0
- package/dist/Deploy/prompt.d.ts +10 -0
- package/dist/Deploy/prompt.d.ts.map +1 -0
- package/dist/Deploy/prompt.js +43 -0
- package/dist/Deploy/prompt.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deployer
|
|
4
|
+
*
|
|
5
|
+
* SSH deployment pipeline — upload tarball, extract, npm ci,
|
|
6
|
+
* symlink shared resources, atomic symlink swap, PM2 reload.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Deployer = void 0;
|
|
10
|
+
const SSHConnection_1 = require("./SSHConnection");
|
|
11
|
+
class Deployer {
|
|
12
|
+
client;
|
|
13
|
+
constructor(client) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Deploy to a single server. Returns log output.
|
|
18
|
+
*/
|
|
19
|
+
async deployToServer(server, options) {
|
|
20
|
+
const { tarPath, timestamp, deploymentUuid, projectSlug, keyPath, migrate } = options;
|
|
21
|
+
const ssh = new SSHConnection_1.SSHConnection({
|
|
22
|
+
host: server.host,
|
|
23
|
+
user: server.ssh_user,
|
|
24
|
+
port: server.port,
|
|
25
|
+
keyPath,
|
|
26
|
+
});
|
|
27
|
+
const deployPath = server.deploy_path;
|
|
28
|
+
const releasePath = `${deployPath}/releases/${timestamp}`;
|
|
29
|
+
const currentPath = `${deployPath}/current`;
|
|
30
|
+
const sharedEnvPath = `${deployPath}/shared/.env`;
|
|
31
|
+
const sharedStoragePath = `${deployPath}/shared/storage`;
|
|
32
|
+
const remoteTar = `${releasePath}/deploy.tar.gz`;
|
|
33
|
+
const log = [];
|
|
34
|
+
const run = (cmd, label) => {
|
|
35
|
+
if (label)
|
|
36
|
+
log.push(`→ ${label}`);
|
|
37
|
+
const out = ssh.exec(cmd, { silent: true });
|
|
38
|
+
if (out.trim())
|
|
39
|
+
log.push(out.trim());
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
// 1. Create release directory
|
|
43
|
+
run(`mkdir -p "${releasePath}"`, 'Creating release directory');
|
|
44
|
+
// 2. Upload tarball
|
|
45
|
+
log.push('→ Uploading build artifact');
|
|
46
|
+
ssh.upload(tarPath, remoteTar);
|
|
47
|
+
// 3. Extract
|
|
48
|
+
run(`tar -xzf "${remoteTar}" -C "${releasePath}" && rm "${remoteTar}"`, 'Extracting');
|
|
49
|
+
// 4. Install production dependencies
|
|
50
|
+
run(`cd "${releasePath}" && npm ci --omit=dev 2>&1`, 'Installing dependencies');
|
|
51
|
+
// 5. Link shared .env (if exists)
|
|
52
|
+
run(`[ -f "${sharedEnvPath}" ] && ln -sf "${sharedEnvPath}" "${releasePath}/.env" || true`, 'Linking .env');
|
|
53
|
+
// 6. Link shared storage (if exists)
|
|
54
|
+
run(`[ -d "${sharedStoragePath}" ] && ln -sf "${sharedStoragePath}" "${releasePath}/storage" || true`, 'Linking storage');
|
|
55
|
+
// 7. Run migrations if requested
|
|
56
|
+
if (migrate) {
|
|
57
|
+
run(`cd "${releasePath}" && npx orchestr migrate 2>&1`, 'Running migrations');
|
|
58
|
+
}
|
|
59
|
+
// 8. Atomic symlink swap
|
|
60
|
+
run(`ln -sfn "${releasePath}" "${currentPath}"`, 'Activating release');
|
|
61
|
+
// 9. Reload PM2 (or start if first deploy)
|
|
62
|
+
// Detect ecosystem config — prefer .cjs (ESM projects), fall back to .js
|
|
63
|
+
run(`cd "${currentPath}" && ECOSYSTEM=$([ -f ecosystem.config.cjs ] && echo ecosystem.config.cjs || echo ecosystem.config.js) && (pm2 reload "$ECOSYSTEM" --update-env 2>&1 || pm2 start "$ECOSYSTEM" 2>&1)`, 'Reloading PM2');
|
|
64
|
+
// 10. Clean old releases (keep last 5)
|
|
65
|
+
run(`ls -dt "${deployPath}/releases"/*/ 2>/dev/null | tail -n +6 | xargs rm -rf 2>/dev/null || true`, 'Cleaning old releases');
|
|
66
|
+
// Update deployment status to active
|
|
67
|
+
await this.client.updateDeployment(projectSlug, deploymentUuid, {
|
|
68
|
+
status: 'active',
|
|
69
|
+
log: log.join('\n'),
|
|
70
|
+
});
|
|
71
|
+
return log.join('\n');
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const errMsg = error.message;
|
|
75
|
+
log.push(`✗ Error: ${errMsg}`);
|
|
76
|
+
// Update deployment status to failed
|
|
77
|
+
await this.client
|
|
78
|
+
.updateDeployment(projectSlug, deploymentUuid, {
|
|
79
|
+
status: 'failed',
|
|
80
|
+
log: log.join('\n'),
|
|
81
|
+
})
|
|
82
|
+
.catch(() => { });
|
|
83
|
+
throw new Error(log.join('\n'));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.Deployer = Deployer;
|
|
88
|
+
//# sourceMappingURL=Deployer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deployer.js","sourceRoot":"","sources":["../../src/Deploy/Deployer.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,mDAAgD;AAqBhD,MAAa,QAAQ;IACU;IAA7B,YAA6B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IAEvD;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,MAAoB,EAAE,OAAsB;QAC/D,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACtF,MAAM,GAAG,GAAG,IAAI,6BAAa,CAAC;YAC5B,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,MAAM,WAAW,GAAG,GAAG,UAAU,aAAa,SAAS,EAAE,CAAC;QAC1D,MAAM,WAAW,GAAG,GAAG,UAAU,UAAU,C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
|
|
7
|
+
project: string;
|
|
8
|
+
api: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ProjectConfig {
|
|
11
|
+
private static readonly FILENAME;
|
|
12
|
+
private static getPath;
|
|
13
|
+
/**
|
|
14
|
+
* Load symphony.json from the current working directory. Returns null if not found.
|
|
15
|
+
*/
|
|
16
|
+
static load(cwd?: string): SymphonyConfig | null;
|
|
17
|
+
/**
|
|
18
|
+
* Save symphony.json to the current working directory.
|
|
19
|
+
*/
|
|
20
|
+
static save(config: SymphonyConfig, cwd?: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Check if symphony.json exists in the current working directory.
|
|
23
|
+
*/
|
|
24
|
+
static exists(cwd?: string): boolean;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ProjectConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectConfig.d.ts","sourceRoot":"","sources":["../../src/Deploy/ProjectConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAEnD,OAAO,CAAC,MAAM,CAAC,OAAO;IAItB;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,GAAE,MAAsB,GAAG,cAAc,GAAG,IAAI;IAe/D;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI;IAKtE;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO;CAGpD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ProjectConfig
|
|
4
|
+
*
|
|
5
|
+
* Manages symphony.json in the project root
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ProjectConfig = void 0;
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
class ProjectConfig {
|
|
12
|
+
static FILENAME = 'symphony.json';
|
|
13
|
+
static getPath(cwd = process.cwd()) {
|
|
14
|
+
return (0, path_1.join)(cwd, this.FILENAME);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load symphony.json from the current working directory. Returns null if not found.
|
|
18
|
+
*/
|
|
19
|
+
static load(cwd = process.cwd()) {
|
|
20
|
+
const path = this.getPath(cwd);
|
|
21
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const raw = (0, fs_1.readFileSync)(path, 'utf-8');
|
|
26
|
+
return JSON.parse(raw);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Save symphony.json to the current working directory.
|
|
34
|
+
*/
|
|
35
|
+
static save(config, cwd = process.cwd()) {
|
|
36
|
+
const path = this.getPath(cwd);
|
|
37
|
+
(0, fs_1.writeFileSync)(path, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if symphony.json exists in the current working directory.
|
|
41
|
+
*/
|
|
42
|
+
static exists(cwd = process.cwd()) {
|
|
43
|
+
return (0, fs_1.existsSync)(this.getPath(cwd));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ProjectConfig = ProjectConfig;
|
|
47
|
+
//# sourceMappingURL=ProjectConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectConfig.js","sourceRoot":"","sources":["../../src/Deploy/ProjectConfig.ts"],"names":[],"mappings":";AAAA;;;;GAIG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provisioner
|
|
3
|
+
*
|
|
4
|
+
* Provisions a fresh Ubuntu server for Orchestr deployments via SSH.
|
|
5
|
+
*
|
|
6
|
+
* Steps:
|
|
7
|
+
* 1. Install Node.js 22 (NodeSource)
|
|
8
|
+
* 2. Install PM2 globally
|
|
9
|
+
* 3. Install + configure Nginx as reverse proxy (port 3000)
|
|
10
|
+
* 4. Certbot SSL (if domain provided)
|
|
11
|
+
* 5. Create orchestr user + directory structure
|
|
12
|
+
* 6. Configure UFW firewall (allow 22, 80, 443)
|
|
13
|
+
*/
|
|
14
|
+
export interface ProvisionOptions {
|
|
15
|
+
host: string;
|
|
16
|
+
port?: number;
|
|
17
|
+
rootUser?: string;
|
|
18
|
+
keyPath?: string;
|
|
19
|
+
domain?: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
deployPath?: string;
|
|
22
|
+
projectName?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ProvisionStep {
|
|
25
|
+
name: string;
|
|
26
|
+
command: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class Provisioner {
|
|
29
|
+
private readonly options;
|
|
30
|
+
private readonly ssh;
|
|
31
|
+
private readonly domain?;
|
|
32
|
+
private readonly certEmail?;
|
|
33
|
+
private readonly deployPath;
|
|
34
|
+
private readonly projectName;
|
|
35
|
+
constructor(options: ProvisionOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Run the full provisioning pipeline.
|
|
38
|
+
* Calls onStep for progress reporting.
|
|
39
|
+
*/
|
|
40
|
+
provision(onStep?: (step: string) => void): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Check that the server is reachable.
|
|
43
|
+
*/
|
|
44
|
+
testConnection(): boolean;
|
|
45
|
+
private buildNginxConfig;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=Provisioner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provisioner.d.ts","sourceRoot":"","sources":["../../src/Deploy/Provisioner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,WAAW;IAOV,OAAO,CAAC,QAAQ,CAAC,OAAO;IANpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAER,OAAO,EAAE,gBAAgB;IAatD;;;OAGG;IACG,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA2E/D;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,OAAO,CAAC,gBAAgB;CAmBzB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Provisioner
|
|
4
|
+
*
|
|
5
|
+
* Provisions a fresh Ubuntu server for Orchestr deployments via SSH.
|
|
6
|
+
*
|
|
7
|
+
* Steps:
|
|
8
|
+
* 1. Install Node.js 22 (NodeSource)
|
|
9
|
+
* 2. Install PM2 globally
|
|
10
|
+
* 3. Install + configure Nginx as reverse proxy (port 3000)
|
|
11
|
+
* 4. Certbot SSL (if domain provided)
|
|
12
|
+
* 5. Create orchestr user + directory structure
|
|
13
|
+
* 6. Configure UFW firewall (allow 22, 80, 443)
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Provisioner = void 0;
|
|
17
|
+
const SSHConnection_1 = require("./SSHConnection");
|
|
18
|
+
class Provisioner {
|
|
19
|
+
options;
|
|
20
|
+
ssh;
|
|
21
|
+
domain;
|
|
22
|
+
certEmail;
|
|
23
|
+
deployPath;
|
|
24
|
+
projectName;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.ssh = new SSHConnection_1.SSHConnection({
|
|
28
|
+
host: options.host,
|
|
29
|
+
user: options.rootUser ?? 'root',
|
|
30
|
+
port: options.port ?? 22,
|
|
31
|
+
keyPath: options.keyPath,
|
|
32
|
+
});
|
|
33
|
+
this.domain = options.domain;
|
|
34
|
+
this.certEmail = options.email;
|
|
35
|
+
this.deployPath = options.deployPath ?? '/home/orchestr';
|
|
36
|
+
this.projectName = options.projectName ?? 'app';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Run the full provisioning pipeline.
|
|
40
|
+
* Calls onStep for progress reporting.
|
|
41
|
+
*/
|
|
42
|
+
async provision(onStep) {
|
|
43
|
+
const run = (label, cmd) => {
|
|
44
|
+
onStep?.(label);
|
|
45
|
+
this.ssh.exec(cmd, { silent: true });
|
|
46
|
+
};
|
|
47
|
+
// 1. Update apt
|
|
48
|
+
run('Updating package list', 'apt-get update -qq');
|
|
49
|
+
// 2. Install Node.js 22 via NodeSource
|
|
50
|
+
run('Installing Node.js 22', [
|
|
51
|
+
'apt-get install -y -qq curl',
|
|
52
|
+
'curl -fsSL https://deb.nodesource.com/setup_22.x | bash -',
|
|
53
|
+
'apt-get install -y -qq nodejs',
|
|
54
|
+
].join(' && '));
|
|
55
|
+
// 3. Install PM2 globally
|
|
56
|
+
run('Installing PM2', 'npm install -g pm2 --quiet && pm2 startup systemd -u orchestr --hp /home/orchestr || true');
|
|
57
|
+
// 4. Install Nginx
|
|
58
|
+
run('Installing Nginx', 'apt-get install -y -qq nginx');
|
|
59
|
+
// 5. Configure Nginx reverse proxy
|
|
60
|
+
const nginxConf = this.buildNginxConfig();
|
|
61
|
+
run('Configuring Nginx', [
|
|
62
|
+
`cat > /etc/nginx/sites-available/${this.projectName} << 'NGINX'\n${nginxConf}\nNGINX`,
|
|
63
|
+
`ln -sf /etc/nginx/sites-available/${this.projectName} /etc/nginx/sites-enabled/${this.projectName}`,
|
|
64
|
+
'rm -f /etc/nginx/sites-enabled/default',
|
|
65
|
+
'nginx -t && systemctl reload nginx',
|
|
66
|
+
].join(' && '));
|
|
67
|
+
// 6. SSL via Certbot (if domain provided)
|
|
68
|
+
if (this.domain && this.certEmail) {
|
|
69
|
+
run('Installing Certbot', 'apt-get install -y -qq certbot python3-certbot-nginx');
|
|
70
|
+
run(`Obtaining SSL certificate for ${this.domain}`, `certbot --nginx -d ${this.domain} --non-interactive --agree-tos --email ${this.certEmail} --redirect`);
|
|
71
|
+
}
|
|
72
|
+
// 7. Create orchestr user
|
|
73
|
+
run('Creating orchestr user', [
|
|
74
|
+
'id -u orchestr &>/dev/null || useradd -m -s /bin/bash orchestr',
|
|
75
|
+
`mkdir -p ${this.deployPath}/${this.projectName}/releases`,
|
|
76
|
+
`mkdir -p ${this.deployPath}/${this.projectName}/shared`,
|
|
77
|
+
`touch ${this.deployPath}/${this.projectName}/shared/.env`,
|
|
78
|
+
`chown -R orchestr:orchestr ${this.deployPath}`,
|
|
79
|
+
].join(' && '));
|
|
80
|
+
// 8. Configure UFW firewall
|
|
81
|
+
run('Configuring UFW firewall', [
|
|
82
|
+
'apt-get install -y -qq ufw',
|
|
83
|
+
'ufw --force reset',
|
|
84
|
+
'ufw allow 22/tcp',
|
|
85
|
+
'ufw allow 80/tcp',
|
|
86
|
+
'ufw allow 443/tcp',
|
|
87
|
+
'ufw --force enable',
|
|
88
|
+
].join(' && '));
|
|
89
|
+
// 9. Enable Nginx on boot
|
|
90
|
+
run('Enabling services on boot', 'systemctl enable nginx');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check that the server is reachable.
|
|
94
|
+
*/
|
|
95
|
+
testConnection() {
|
|
96
|
+
return this.ssh.test();
|
|
97
|
+
}
|
|
98
|
+
buildNginxConfig() {
|
|
99
|
+
const serverName = this.domain ?? '_';
|
|
100
|
+
return `server {
|
|
101
|
+
listen 80;
|
|
102
|
+
server_name ${serverName};
|
|
103
|
+
|
|
104
|
+
location / {
|
|
105
|
+
proxy_pass http://localhost:3000;
|
|
106
|
+
proxy_http_version 1.1;
|
|
107
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
108
|
+
proxy_set_header Connection 'upgrade';
|
|
109
|
+
proxy_set_header Host $host;
|
|
110
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
111
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
112
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
113
|
+
proxy_cache_bypass $http_upgrade;
|
|
114
|
+
}
|
|
115
|
+
}`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.Provisioner = Provisioner;
|
|
119
|
+
//# sourceMappingURL=Provisioner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provisioner.js","sourceRoot":"","sources":["../../src/Deploy/Provisioner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,mDAAgD;AAkBhD,MAAa,WAAW;IAOO;IANZ,GAAG,CAAgB;IACnB,MAAM,CAAU;IAChB,SAAS,CAAU;IACnB,UAAU,CAAS;IACnB,WAAW,CAAS;IAErC,YAA6B,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QACpD,IAAI,CAAC,GAAG,GAAG,IAAI,6BAAa,CAAC;YAC3B,IAAI,EAAE,OAAO,CAAC,IAAI;YA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+
/**
|
|
2
|
+
* SSHConnection
|
|
3
|
+
*
|
|
4
|
+
* Wrapper around system ssh/scp commands via child_process.
|
|
5
|
+
* Zero npm dependencies — uses Node.js built-ins only.
|
|
6
|
+
*/
|
|
7
|
+
export interface SSHConfig {
|
|
8
|
+
host: string;
|
|
9
|
+
user: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
keyPath?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class SSHConnection {
|
|
14
|
+
private readonly host;
|
|
15
|
+
private readonly user;
|
|
16
|
+
private readonly port;
|
|
17
|
+
private readonly keyPath?;
|
|
18
|
+
constructor(config: SSHConfig);
|
|
19
|
+
private get sshArgs();
|
|
20
|
+
private get target();
|
|
21
|
+
/**
|
|
22
|
+
* Run a command on the remote server.
|
|
23
|
+
* Returns stdout as a string.
|
|
24
|
+
*/
|
|
25
|
+
exec(command: string, opts?: {
|
|
26
|
+
silent?: boolean;
|
|
27
|
+
}): string;
|
|
28
|
+
/**
|
|
29
|
+
* Upload a local file to the remote server via scp.
|
|
30
|
+
*/
|
|
31
|
+
upload(localPath: string, remotePath: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Test that the SSH connection is reachable.
|
|
34
|
+
* Returns true if successful, false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
test(): boolean;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=SSHConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSHConnection.d.ts","sourceRoot":"","sources":["../../src/Deploy/SSHConnection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;gBAEtB,MAAM,EAAE,SAAS;IAO7B,OAAO,KAAK,OAAO,GAalB;IAED,OAAO,KAAK,MAAM,GAEjB;IAED;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,MAAM;IAa9D;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAenD;;;OAGG;IACH,IAAI,IAAI,OAAO;CAQhB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SSHConnection
|
|
4
|
+
*
|
|
5
|
+
* Wrapper around system ssh/scp commands via child_process.
|
|
6
|
+
* Zero npm dependencies — uses Node.js built-ins only.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SSHConnection = void 0;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
class SSHConnection {
|
|
12
|
+
host;
|
|
13
|
+
user;
|
|
14
|
+
port;
|
|
15
|
+
keyPath;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.host = config.host;
|
|
18
|
+
this.user = config.user;
|
|
19
|
+
this.port = config.port ?? 22;
|
|
20
|
+
this.keyPath = config.keyPath;
|
|
21
|
+
}
|
|
22
|
+
get sshArgs() {
|
|
23
|
+
const args = [
|
|
24
|
+
'-o StrictHostKeyChecking=accept-new',
|
|
25
|
+
'-o UserKnownHostsFile=/dev/null',
|
|
26
|
+
'-o BatchMode=yes',
|
|
27
|
+
`-p ${this.port}`,
|
|
28
|
+
];
|
|
29
|
+
if (this.keyPath) {
|
|
30
|
+
args.push(`-i "${this.keyPath}"`);
|
|
31
|
+
}
|
|
32
|
+
return args.join(' ');
|
|
33
|
+
}
|
|
34
|
+
get target() {
|
|
35
|
+
return `${this.user}@${this.host}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run a command on the remote server.
|
|
39
|
+
* Returns stdout as a string.
|
|
40
|
+
*/
|
|
41
|
+
exec(command, opts = {}) {
|
|
42
|
+
// Use single quotes so $VAR expansion happens on the remote shell, not locally.
|
|
43
|
+
// Escape any literal single quotes in the command via the '"'"' trick.
|
|
44
|
+
const escaped = command.replace(/'/g, `'"'"'`);
|
|
45
|
+
const cmd = `ssh ${this.sshArgs} ${this.target} '${escaped}'`;
|
|
46
|
+
const options = {
|
|
47
|
+
stdio: opts.silent ? 'pipe' : 'inherit',
|
|
48
|
+
encoding: 'utf-8',
|
|
49
|
+
};
|
|
50
|
+
return (0, child_process_1.execSync)(cmd, options) ?? '';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Upload a local file to the remote server via scp.
|
|
54
|
+
*/
|
|
55
|
+
upload(localPath, remotePath) {
|
|
56
|
+
const scpArgs = [
|
|
57
|
+
'-o StrictHostKeyChecking=accept-new',
|
|
58
|
+
'-o UserKnownHostsFile=/dev/null',
|
|
59
|
+
`-P ${this.port}`,
|
|
60
|
+
];
|
|
61
|
+
if (this.keyPath) {
|
|
62
|
+
scpArgs.push(`-i "${this.keyPath}"`);
|
|
63
|
+
}
|
|
64
|
+
const cmd = `scp ${scpArgs.join(' ')} "${localPath}" ${this.target}:"${remotePath}"`;
|
|
65
|
+
(0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Test that the SSH connection is reachable.
|
|
69
|
+
* Returns true if successful, false otherwise.
|
|
70
|
+
*/
|
|
71
|
+
test() {
|
|
72
|
+
try {
|
|
73
|
+
this.exec('echo ok', { silent: true });
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.SSHConnection = SSHConnection;
|
|
82
|
+
//# sourceMappingURL=SSHConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSHConnection.js","sourceRoot":"","sources":["../../src/Deploy/SSHConnection.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iDAA0D;AAS1D,MAAa,aAAa;IACP,IAAI,CAAS;IACb,IAAI,CAAS;IACb,IAAI,CAAS;IACb,OAAO,CAAU;IAElC,YAAY,MAAiB;QAC3B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,IAAY,OAAO;QACjB,MAAM,IAAI,GAAa;YACrB,qCAAqC;YACrC,iCAAiC;YACjC,kBAAkB;YAClB,MAAM,IAAI,CAAC,IAAI,EAAE;SAClB,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,IAAY,MAAM;QAChB,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,OAAe,EAAE,OAA6B,EAAE;QACnD,gFAAgF;QAChF,uEAAuE;QACvE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,OAA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+
export interface ApiError {
|
|
8
|
+
error: string;
|
|
9
|
+
code?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class SymphonyApiError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly code?: string | undefined;
|
|
14
|
+
constructor(message: string, status: number, code?: string | undefined);
|
|
15
|
+
}
|
|
16
|
+
export declare class SymphonyClient {
|
|
17
|
+
private readonly apiUrl;
|
|
18
|
+
private readonly token?;
|
|
19
|
+
constructor(apiUrl: string, token?: string | undefined);
|
|
20
|
+
private get headers();
|
|
21
|
+
private request;
|
|
22
|
+
register(email: string, password: string, name?: string): Promise<{
|
|
23
|
+
user: {
|
|
24
|
+
id: number;
|
|
25
|
+
email: string;
|
|
26
|
+
name: string | null;
|
|
27
|
+
};
|
|
28
|
+
token: string;
|
|
29
|
+
}>;
|
|
30
|
+
login(email: string, password: string): Promise<{
|
|
31
|
+
user: {
|
|
32
|
+
id: number;
|
|
33
|
+
email: string;
|
|
34
|
+
name: string | null;
|
|
35
|
+
};
|
|
36
|
+
token: string;
|
|
37
|
+
}>;
|
|
38
|
+
listProjects(): Promise<{
|
|
39
|
+
projects: Array<{
|
|
40
|
+
id: number;
|
|
41
|
+
name: string;
|
|
42
|
+
slug: string;
|
|
43
|
+
repository: string | null;
|
|
44
|
+
created_at: string;
|
|
45
|
+
}>;
|
|
46
|
+
}>;
|
|
47
|
+
createProject(name: string, repository?: string): Promise<{
|
|
48
|
+
project: {
|
|
49
|
+
id: number;
|
|
50
|
+
name: string;
|
|
51
|
+
slug: string;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
getProject(slug: string): Promise<{
|
|
55
|
+
project: {
|
|
56
|
+
id: number;
|
|
57
|
+
name: string;
|
|
58
|
+
slug: string;
|
|
59
|
+
repository: string | null;
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
listServers(slug: string): Promise<{
|
|
63
|
+
servers: Array<{
|
|
64
|
+
id: number;
|
|
65
|
+
name: string;
|
|
66
|
+
host: string;
|
|
67
|
+
port: number;
|
|
68
|
+
ssh_user: string;
|
|
69
|
+
deploy_path: string;
|
|
70
|
+
status: string | null;
|
|
71
|
+
last_deployed_at: string | null;
|
|
72
|
+
}>;
|
|
73
|
+
}>;
|
|
74
|
+
addServer(slug: string, params: {
|
|
75
|
+
name: string;
|
|
76
|
+
host: string;
|
|
77
|
+
port?: number;
|
|
78
|
+
ssh_user?: string;
|
|
79
|
+
deploy_path?: string;
|
|
80
|
+
}): Promise<{
|
|
81
|
+
server: {
|
|
82
|
+
id: number;
|
|
83
|
+
name: string;
|
|
84
|
+
host: string;
|
|
85
|
+
port: number;
|
|
86
|
+
ssh_user: string;
|
|
87
|
+
deploy_path: string;
|
|
88
|
+
status: string | null;
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
91
|
+
deleteServer(slug: string, serverId: number): Promise<void>;
|
|
92
|
+
createDeployment(slug: string, params: {
|
|
93
|
+
server_id: number;
|
|
94
|
+
version?: string;
|
|
95
|
+
commit_hash?: string;
|
|
96
|
+
commit_message?: string;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
deployment: {
|
|
99
|
+
id: number;
|
|
100
|
+
uuid: string;
|
|
101
|
+
status: string;
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
104
|
+
listDeployments(slug: string, page?: number, perPage?: number): Promise<{
|
|
105
|
+
deployments: Array<{
|
|
106
|
+
id: number;
|
|
107
|
+
uuid: string;
|
|
108
|
+
version: string | null;
|
|
109
|
+
commit_hash: string | null;
|
|
110
|
+
commit_message: string | null;
|
|
111
|
+
status: string | null;
|
|
112
|
+
started_at: string | null;
|
|
113
|
+
completed_at: string | null;
|
|
114
|
+
created_at: string;
|
|
115
|
+
}>;
|
|
116
|
+
pagination: {
|
|
117
|
+
page: number;
|
|
118
|
+
per_page: number;
|
|
119
|
+
total: number;
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
updateDeployment(slug: string, uuid: string, params: {
|
|
123
|
+
status?: string;
|
|
124
|
+
log?: string;
|
|
125
|
+
completed_at?: string;
|
|
126
|
+
}): Promise<{
|
|
127
|
+
deployment: {
|
|
128
|
+
id: number;
|
|
129
|
+
uuid: string;
|
|
130
|
+
status: string;
|
|
131
|
+
};
|
|
132
|
+
}>;
|
|
133
|
+
getEnvVars(slug: string): Promise<{
|
|
134
|
+
variables: Array<{
|
|
135
|
+
key: string;
|
|
136
|
+
value: string;
|
|
137
|
+
}>;
|
|
138
|
+
}>;
|
|
139
|
+
putEnvVars(slug: string, variables: Array<{
|
|
140
|
+
key: string;
|
|
141
|
+
value: string;
|
|
142
|
+
}>): Promise<{
|
|
143
|
+
variables: Array<{
|
|
144
|
+
key: string;
|
|
145
|
+
}>;
|
|
146
|
+
}>;
|
|
147
|
+
rollback(slug: string): Promise<{
|
|
148
|
+
rolled_back: {
|
|
149
|
+
id: number;
|
|
150
|
+
uuid: string;
|
|
151
|
+
};
|
|
152
|
+
restored: {
|
|
153
|
+
id: number;
|
|
154
|
+
uuid: string;
|
|
155
|
+
};
|
|
156
|
+
}>;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=SymphonyClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SymphonyClient.d.ts","sourceRoot":"","sources":["../../src/Deploy/SymphonyClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,gBAAiB,SAAQ,KAAK;aAGvB,MAAM,EAAE,MAAM;aACd,IAAI,CAAC,EAAE,MAAM;gBAF7B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAKhC;AAED,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;gBADN,MA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