d3ployer 0.0.7 → 0.0.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/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
  }
@@ -177,6 +177,43 @@ 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
199
+ && await ctx.test('test -f pm2.config.*');
200
+ const hasDocker = ctx.config.dockerCompose !== false
201
+ && await ctx.test('test -f docker-compose.yml -o -f docker-compose.yaml -o -f compose.yml -o -f compose.yaml');
202
+ if (hasPm2) {
203
+ const pm2ConfigRaw = await ctx.run('cat pm2.config.*', { printOutput: false });
204
+ const nameMatch = pm2ConfigRaw.stdout.match(/name: ['"](?<name>.+?)['"]/);
205
+ const name = nameMatch.groups?.name ?? 'all';
206
+ console.log(chalk.cyan(`Streaming PM2 logs for ${time}s...`));
207
+ await ctx.run(`timeout ${time} pm2 logs "${name}" || true`, { printOutput: true, ignoreError: true });
208
+ }
209
+ else if (hasDocker) {
210
+ console.log(chalk.cyan(`Streaming Docker Compose logs for ${time}s...`));
211
+ await ctx.run(`timeout ${time} docker compose logs --tail=50 -f || true`, {
212
+ printOutput: true,
213
+ ignoreError: true,
214
+ });
215
+ }
216
+ };
180
217
  export const defaultTasks = {
181
218
  clearTarget: {
182
219
  name: 'Clear target',
@@ -216,6 +253,11 @@ export const defaultTasks = {
216
253
  name: 'Print deployment info',
217
254
  task: printDeploymentTask,
218
255
  },
256
+ streamLogs: {
257
+ name: 'Stream logs',
258
+ skip: streamLogsSkip,
259
+ task: streamLogsTask,
260
+ },
219
261
  };
220
262
  export const defaultScenarios = {
221
263
  deploy: {
@@ -227,6 +269,7 @@ export const defaultScenarios = {
227
269
  'pm2:setup',
228
270
  'docker:setup',
229
271
  'print:deployment',
272
+ 'stream:logs',
230
273
  ],
231
274
  },
232
275
  };
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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d3ployer",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {