netlify-cli 8.15.2 → 8.15.3

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "8.15.2",
3
+ "version": "8.15.3",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "netlify-cli",
9
- "version": "8.15.2",
9
+ "version": "8.15.3",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "8.15.2",
4
+ "version": "8.15.3",
5
5
  "author": "Netlify Inc.",
6
6
  "contributors": [
7
7
  "Mathias Biilmann <matt@netlify.com> (https://twitter.com/biilmann)",
@@ -3,7 +3,6 @@ const fs = require('fs')
3
3
  const path = require('path')
4
4
  const process = require('process')
5
5
 
6
- const CronParser = require('cron-parser')
7
6
  const inquirer = require('inquirer')
8
7
  const fetch = require('node-fetch')
9
8
 
@@ -131,13 +130,6 @@ const getFunctionToTrigger = function (options, argumentName) {
131
130
  return argumentName
132
131
  }
133
132
 
134
- const getNextRun = function (schedule) {
135
- const cron = CronParser.parseExpression(schedule, {
136
- tz: 'Etc/UTC',
137
- })
138
- return cron.next().toDate()
139
- }
140
-
141
133
  /**
142
134
  * The functions:invoke command
143
135
  * @param {string} nameArgument
@@ -164,10 +156,8 @@ const functionsInvoke = async (nameArgument, options, command) => {
164
156
  let body = {}
165
157
 
166
158
  if (functionObj.schedule) {
167
- body.next_run = getNextRun(functionObj.schedule)
168
159
  headers = {
169
160
  'user-agent': CLOCKWORK_USERAGENT,
170
- 'X-NF-Event': 'schedule',
171
161
  }
172
162
  } else if (eventTriggeredFunctions.has(functionToTrigger)) {
173
163
  /** handle event triggered fns */
@@ -1,4 +1,6 @@
1
1
  // @ts-check
2
+ const CronParser = require('cron-parser')
3
+
2
4
  const { error: errorExit } = require('../../utils/command-helpers')
3
5
 
4
6
  const BACKGROUND_SUFFIX = '-background'
@@ -6,6 +8,13 @@ const BACKGROUND_SUFFIX = '-background'
6
8
  // Returns a new set with all elements of `setA` that don't exist in `setB`.
7
9
  const difference = (setA, setB) => new Set([...setA].filter((item) => !setB.has(item)))
8
10
 
11
+ const getNextRun = function (schedule) {
12
+ const cron = CronParser.parseExpression(schedule, {
13
+ tz: 'Etc/UTC',
14
+ })
15
+ return cron.next().toDate()
16
+ }
17
+
9
18
  class NetlifyFunction {
10
19
  constructor({
11
20
  config,
@@ -51,6 +60,14 @@ class NetlifyFunction {
51
60
  return Boolean(this.schedule)
52
61
  }
53
62
 
63
+ async getNextRun() {
64
+ if (!(await this.isScheduled())) {
65
+ return null
66
+ }
67
+
68
+ return getNextRun(this.schedule)
69
+ }
70
+
54
71
  // The `build` method transforms source files into invocable functions. Its
55
72
  // return value is an object with:
56
73
  //
@@ -1,7 +1,14 @@
1
1
  // @ts-check
2
2
  const jwtDecode = require('jwt-decode')
3
3
 
4
- const { NETLIFYDEVERR, NETLIFYDEVLOG, error: errorExit, getInternalFunctionsDir, log } = require('../../utils')
4
+ const {
5
+ CLOCKWORK_USERAGENT,
6
+ NETLIFYDEVERR,
7
+ NETLIFYDEVLOG,
8
+ error: errorExit,
9
+ getInternalFunctionsDir,
10
+ log,
11
+ } = require('../../utils')
5
12
 
6
13
  const { handleBackgroundFunction, handleBackgroundFunctionResult } = require('./background')
7
14
  const { createFormSubmissionHandler } = require('./form-submissions-handler')
@@ -107,7 +114,21 @@ const createHandler = function ({ functionsRegistry }) {
107
114
 
108
115
  handleBackgroundFunctionResult(functionName, error)
109
116
  } else if (await func.isScheduled()) {
110
- const { error, result } = await func.invoke(event, clientContext)
117
+ const { error, result } = await func.invoke(
118
+ {
119
+ ...event,
120
+ body: JSON.stringify({
121
+ next_run: await func.getNextRun(),
122
+ }),
123
+ isBase64Encoded: false,
124
+ headers: {
125
+ ...event.headers,
126
+ 'user-agent': CLOCKWORK_USERAGENT,
127
+ 'X-NF-Event': 'schedule',
128
+ },
129
+ },
130
+ clientContext,
131
+ )
111
132
 
112
133
  handleScheduledFunction({
113
134
  error,