@certik/skynet 0.9.0 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1
4
+
5
+ - Support using `--schedule` argument to override default schedule when deploying
6
+
3
7
  ## 0.9.0
4
8
 
5
9
  - Added `web3` library with call support
package/deploy.js CHANGED
@@ -9,10 +9,15 @@ const { getEnvOrThrow } = require("./env");
9
9
  const { getBinaryName, detectSkynetDirectory } = require("./cli");
10
10
 
11
11
  const INTERVAL_ALIASES = {
12
+ secondly: "*/1 * * * * * *",
12
13
  "@secondly": "*/1 * * * * * *",
14
+ minutely: "0 * * * * * *",
13
15
  "@minutely": "0 * * * * * *",
16
+ hourly: "0 0 * * * * *",
14
17
  "@hourly": "0 0 * * * * *",
18
+ daily: "0 0 0 * * * *",
15
19
  "@daily": "0 0 0 * * * *",
20
+ weekly: "0 0 0 * * 0 *",
16
21
  "@weekly": "0 0 0 * * 0 *",
17
22
  };
18
23
 
@@ -295,7 +300,17 @@ function createModeDeploy({
295
300
  validateCpu,
296
301
  validateMem,
297
302
  }) {
298
- async function deployMode({ mode, from, to, stop, production, dryRun, verbose, ...selectorFlags }) {
303
+ async function deployMode({
304
+ mode,
305
+ from,
306
+ to,
307
+ stop,
308
+ production,
309
+ dryRun,
310
+ verbose,
311
+ schedule: cmdSchedule,
312
+ ...selectorFlags
313
+ }) {
299
314
  if (mode === "delta") {
300
315
  // delta mode will ignore from/to flags
301
316
  from = 0;
@@ -336,9 +351,17 @@ function createModeDeploy({
336
351
  // by default use delta cpu/mem settings
337
352
  const { cpu, mem } = modeResouces[mode] || modeResouces.delta;
338
353
 
339
- const deltaCron = typeof deltaSchedule === "function" ? deltaSchedule(jobName) : deltaSchedule;
354
+ let deltaCron = typeof deltaSchedule === "function" ? deltaSchedule(jobName) : deltaSchedule;
340
355
 
341
- const validateCron = typeof validateSchedule === "function" ? validateSchedule(jobName) : validateSchedule;
356
+ if (deltaSchedule && cmdSchedule) {
357
+ deltaCron = cmdSchedule;
358
+ }
359
+
360
+ let validateCron = typeof validateSchedule === "function" ? validateSchedule(jobName) : validateSchedule;
361
+
362
+ if (validateSchedule && cmdSchedule) {
363
+ validateCron = cmdSchedule;
364
+ }
342
365
 
343
366
  const modeIntervals = {
344
367
  delta: INTERVAL_ALIASES[deltaCron] || deltaCron,
@@ -404,7 +427,8 @@ ${getSelectorDesc(selector)}
404
427
  --from min id to build
405
428
  --to max id to build
406
429
  --stop stop job instead of running the job
407
- --production deploy to production environment
430
+ --production deploy to production, default is development
431
+ --schedule override default schedule, support aliases: secondly, minutely, hourly, daily, weekly
408
432
  --verbose Output debug messages
409
433
  --dry-run print nomad job file but do not really execute it
410
434
 
@@ -432,6 +456,9 @@ ${getSelectorDesc(selector)}
432
456
  type: "number",
433
457
  default: 0,
434
458
  },
459
+ schedule: {
460
+ type: "string",
461
+ },
435
462
  verbose: {
436
463
  type: "boolean",
437
464
  default: false,
@@ -476,7 +503,7 @@ function createDeploy({
476
503
  cpu,
477
504
  mem,
478
505
  }) {
479
- async function deployModeless({ production, stop, dryRun, verbose, ...selectorFlags }) {
506
+ async function deployModeless({ production, stop, dryRun, verbose, schedule: cmdSchedule, ...selectorFlags }) {
480
507
  const jobName = getJobName(name, selectorFlags, null);
481
508
 
482
509
  const selectorCmdPart = Object.keys(selectorFlags)
@@ -489,7 +516,12 @@ function createDeploy({
489
516
  args += ` --verbose`;
490
517
  }
491
518
 
492
- const cron = typeof schedule === "function" ? schedule(jobName) : schedule;
519
+ let cron = typeof schedule === "function" ? schedule(jobName) : schedule;
520
+
521
+ if (schedule && cmdSchedule) {
522
+ // cmd schedule has higher priority
523
+ cron = cmdSchedule;
524
+ }
493
525
 
494
526
  const nomadJobDefinition = genConfig({
495
527
  jobName,
@@ -549,6 +581,7 @@ function createDeploy({
549
581
  ${getSelectorDesc(selector)}
550
582
  --stop stop job instead of running the job
551
583
  --production deploy to production, default is development
584
+ --schedule override default schedule, support aliases: secondly, minutely, hourly, daily, weekly
552
585
  --verbose Output debug messages
553
586
  --dry-run print nomad job file but do not really execute it
554
587
  `,
@@ -557,6 +590,9 @@ ${getSelectorDesc(selector)}
557
590
  version: false,
558
591
  flags: {
559
592
  ...getSelectorFlags(selector),
593
+ schedule: {
594
+ type: "string",
595
+ },
560
596
  verbose: {
561
597
  type: "boolean",
562
598
  default: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Skynet Shared JS library",
5
5
  "main": "index.js",
6
6
  "author": "CertiK Engineering",