d3ployer 0.0.7 → 0.0.8
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/README.md +12 -1
- package/dist/def.d.ts +4 -0
- package/dist/defaultTasks.js +39 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,6 +125,16 @@ Set to `false` to disable the built-in PM2 task. When enabled (default), the `pm
|
|
|
125
125
|
|
|
126
126
|
Set to `false` to disable the built-in Docker Compose task. When enabled (default), the `docker:setup` task auto-detects compose files and runs `docker compose up -d --build`.
|
|
127
127
|
|
|
128
|
+
### `logs`
|
|
129
|
+
|
|
130
|
+
Configure post-deploy log streaming. The `stream:logs` task will stream PM2 or Docker Compose logs for the configured duration. Set to `false` to disable.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
logs: {
|
|
134
|
+
time: 5, // seconds to stream logs (default: 3)
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
128
138
|
### `tasks`
|
|
129
139
|
|
|
130
140
|
Custom task functions receive a `TaskContext` and `Placeholders`:
|
|
@@ -204,10 +214,11 @@ scenarios: {
|
|
|
204
214
|
| `docker:setup` | Run docker compose up (auto-detects compose files) |
|
|
205
215
|
| `clear:target` | Remove the entire deploy path (with confirmation prompt) |
|
|
206
216
|
| `print:deployment` | Print deployment info (date, files, disk usage) |
|
|
217
|
+
| `stream:logs` | Stream PM2/Docker Compose logs for a few seconds |
|
|
207
218
|
|
|
208
219
|
### Default `deploy` scenario
|
|
209
220
|
|
|
210
|
-
The built-in `deploy` scenario runs: `upload` → `symlinks` → `dep:install` → `pm2:setup` → `docker:setup` → `print:deployment`
|
|
221
|
+
The built-in `deploy` scenario runs: `upload` → `symlinks` → `dep:install` → `pm2:setup` → `docker:setup` → `print:deployment` → `stream:logs`
|
|
211
222
|
|
|
212
223
|
Tasks with skip conditions will be automatically skipped when not applicable (e.g. `pm2:setup` skips if no PM2 config file exists).
|
|
213
224
|
|
package/dist/def.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export interface SymlinkConfig {
|
|
|
27
27
|
path: string;
|
|
28
28
|
target: string;
|
|
29
29
|
}
|
|
30
|
+
export interface LogsConfig {
|
|
31
|
+
time?: number;
|
|
32
|
+
}
|
|
30
33
|
export interface Placeholders {
|
|
31
34
|
serverName: string;
|
|
32
35
|
deployPath: string;
|
|
@@ -84,6 +87,7 @@ export interface DeployerConfig {
|
|
|
84
87
|
packageManager?: PackageManagerConfig | false;
|
|
85
88
|
pm2?: boolean;
|
|
86
89
|
dockerCompose?: boolean;
|
|
90
|
+
logs?: LogsConfig | false;
|
|
87
91
|
tasks?: Record<string, TaskDef>;
|
|
88
92
|
scenarios?: Record<string, ScenarioDef>;
|
|
89
93
|
}
|
package/dist/defaultTasks.js
CHANGED
|
@@ -177,6 +177,39 @@ const printDeploymentTask = async (ctx, ph) => {
|
|
|
177
177
|
console.log(chalk.cyan('Directory size'));
|
|
178
178
|
await ctx.run('du -hd 1 .');
|
|
179
179
|
};
|
|
180
|
+
const streamLogsSkip = async (ctx) => {
|
|
181
|
+
if (ctx.config.logs === false) {
|
|
182
|
+
return 'Logs streaming disabled';
|
|
183
|
+
}
|
|
184
|
+
const hasPm2 = ctx.config.pm2 !== false && await ctx.test('test -f pm2.config.*');
|
|
185
|
+
const hasDocker = ctx.config.dockerCompose !== false
|
|
186
|
+
&& await ctx.test('test -f docker-compose.yml -o -f docker-compose.yaml -o -f compose.yml -o -f compose.yaml');
|
|
187
|
+
if (!hasPm2 && !hasDocker) {
|
|
188
|
+
return 'No PM2 or Docker Compose detected';
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
};
|
|
192
|
+
const streamLogsTask = async (ctx) => {
|
|
193
|
+
const logsConfig = {
|
|
194
|
+
time: 3,
|
|
195
|
+
...ctx.config.logs,
|
|
196
|
+
};
|
|
197
|
+
const time = logsConfig.time;
|
|
198
|
+
const hasPm2 = ctx.config.pm2 !== false && await ctx.test('test -f pm2.config.*');
|
|
199
|
+
const hasDocker = ctx.config.dockerCompose !== false
|
|
200
|
+
&& await ctx.test('test -f docker-compose.yml -o -f docker-compose.yaml -o -f compose.yml -o -f compose.yaml');
|
|
201
|
+
if (hasPm2) {
|
|
202
|
+
console.log(chalk.cyan(`Streaming PM2 logs for ${time}s...`));
|
|
203
|
+
await ctx.run(`timeout ${time} pm2 logs || true`, { printOutput: true, ignoreError: true });
|
|
204
|
+
}
|
|
205
|
+
else if (hasDocker) {
|
|
206
|
+
console.log(chalk.cyan(`Streaming Docker Compose logs for ${time}s...`));
|
|
207
|
+
await ctx.run(`timeout ${time} docker compose logs --tail=50 -f || true`, {
|
|
208
|
+
printOutput: true,
|
|
209
|
+
ignoreError: true,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
180
213
|
export const defaultTasks = {
|
|
181
214
|
clearTarget: {
|
|
182
215
|
name: 'Clear target',
|
|
@@ -216,6 +249,11 @@ export const defaultTasks = {
|
|
|
216
249
|
name: 'Print deployment info',
|
|
217
250
|
task: printDeploymentTask,
|
|
218
251
|
},
|
|
252
|
+
streamLogs: {
|
|
253
|
+
name: 'Stream logs',
|
|
254
|
+
skip: streamLogsSkip,
|
|
255
|
+
task: streamLogsTask,
|
|
256
|
+
},
|
|
219
257
|
};
|
|
220
258
|
export const defaultScenarios = {
|
|
221
259
|
deploy: {
|
|
@@ -227,6 +265,7 @@ export const defaultScenarios = {
|
|
|
227
265
|
'pm2:setup',
|
|
228
266
|
'docker:setup',
|
|
229
267
|
'print:deployment',
|
|
268
|
+
'stream:logs',
|
|
230
269
|
],
|
|
231
270
|
},
|
|
232
271
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AuthMethod, DeployerConfig, DeployerConfigInput, FilesConfig, Placeholders, ScenarioDef, ScenarioInput, ServerConfig, ServerConfigInput, SymlinkConfig, TaskContext, TaskDef, TaskFn, TaskInput, TaskSkipFn, } from './def.js';
|
|
1
|
+
export type { AuthMethod, DeployerConfig, DeployerConfigInput, FilesConfig, LogsConfig, Placeholders, ScenarioDef, ScenarioInput, ServerConfig, ServerConfigInput, SymlinkConfig, TaskContext, TaskDef, TaskFn, TaskInput, TaskSkipFn, } from './def.js';
|
|
2
2
|
export { defineConfig } from './config.js';
|
|
3
3
|
export { runScenario, runTask } from './runner.js';
|
|
4
4
|
export { loadConfig, findConfigFile } from './configLoader.js';
|