d3ployer 0.0.6 → 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 +45 -3
- 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
|
@@ -21,14 +21,14 @@ export function buildRsyncCommand(server, source, dest, files, options = {}) {
|
|
|
21
21
|
// include/exclude
|
|
22
22
|
if (files.exclude) {
|
|
23
23
|
for (const pattern of files.exclude) {
|
|
24
|
-
args.push(`--exclude
|
|
24
|
+
args.push(`--exclude="${pattern}"`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if (files.include) {
|
|
28
28
|
for (const pattern of files.include) {
|
|
29
|
-
args.push(`--include
|
|
29
|
+
args.push(`--include="${pattern}"`);
|
|
30
30
|
}
|
|
31
|
-
args.push('--exclude
|
|
31
|
+
args.push('--exclude="*"');
|
|
32
32
|
}
|
|
33
33
|
args.push(source, dest);
|
|
34
34
|
return args.join(' ');
|
|
@@ -62,6 +62,9 @@ export const downloadSkip = (ctx) => {
|
|
|
62
62
|
};
|
|
63
63
|
export const downloadTask = async (ctx, ph) => {
|
|
64
64
|
const files = ctx.taskConfig;
|
|
65
|
+
if (!files) {
|
|
66
|
+
throw new Exception('No files configuration provided in task config', 1784523741234);
|
|
67
|
+
}
|
|
65
68
|
const localBase = files.basePath?.startsWith('/')
|
|
66
69
|
? files.basePath
|
|
67
70
|
: path.resolve(ctx.config.rootDir, files.basePath ?? '.');
|
|
@@ -174,6 +177,39 @@ const printDeploymentTask = async (ctx, ph) => {
|
|
|
174
177
|
console.log(chalk.cyan('Directory size'));
|
|
175
178
|
await ctx.run('du -hd 1 .');
|
|
176
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
|
+
};
|
|
177
213
|
export const defaultTasks = {
|
|
178
214
|
clearTarget: {
|
|
179
215
|
name: 'Clear target',
|
|
@@ -213,6 +249,11 @@ export const defaultTasks = {
|
|
|
213
249
|
name: 'Print deployment info',
|
|
214
250
|
task: printDeploymentTask,
|
|
215
251
|
},
|
|
252
|
+
streamLogs: {
|
|
253
|
+
name: 'Stream logs',
|
|
254
|
+
skip: streamLogsSkip,
|
|
255
|
+
task: streamLogsTask,
|
|
256
|
+
},
|
|
216
257
|
};
|
|
217
258
|
export const defaultScenarios = {
|
|
218
259
|
deploy: {
|
|
@@ -224,6 +265,7 @@ export const defaultScenarios = {
|
|
|
224
265
|
'pm2:setup',
|
|
225
266
|
'docker:setup',
|
|
226
267
|
'print:deployment',
|
|
268
|
+
'stream:logs',
|
|
227
269
|
],
|
|
228
270
|
},
|
|
229
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';
|