@netlify/functions-utils 4.2.8 → 4.2.10-rc

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.
Files changed (2) hide show
  1. package/package.json +7 -6
  2. package/src/main.js +0 -64
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@netlify/functions-utils",
3
- "version": "4.2.8",
3
+ "version": "4.2.10-rc",
4
4
  "description": "Utility for adding Functions files in Netlify Build",
5
5
  "type": "module",
6
- "exports": "./src/main.js",
7
- "main": "./src/main.js",
6
+ "exports": "./lib/main.js",
7
+ "main": "./lib/main.js",
8
8
  "files": [
9
- "src/**/*.js"
9
+ "lib/**/*.js"
10
10
  ],
11
11
  "author": "Netlify Inc.",
12
12
  "scripts": {
13
- "prepublishOnly": "cd ../../ && npm run prepublishOnly"
13
+ "prepublishOnly": "cd ../../ && npm run prepublishOnly",
14
+ "build": "cp -a src lib/"
14
15
  },
15
16
  "keywords": [
16
17
  "nodejs",
@@ -45,7 +46,7 @@
45
46
  },
46
47
  "license": "MIT",
47
48
  "dependencies": {
48
- "@netlify/zip-it-and-ship-it": "^7.1.1",
49
+ "@netlify/zip-it-and-ship-it": "^7.1.2",
49
50
  "cpy": "^8.1.0",
50
51
  "path-exists": "^5.0.0"
51
52
  },
package/src/main.js DELETED
@@ -1,64 +0,0 @@
1
- import { promises as fs } from 'fs'
2
- import { basename, dirname } from 'path'
3
-
4
- import { listFunctions, listFunctionsFiles } from '@netlify/zip-it-and-ship-it'
5
- import cpy from 'cpy'
6
- import { pathExists } from 'path-exists'
7
-
8
- // Add a Netlify Function file to the `functions` directory so it is processed
9
- // by `@netlify/plugin-functions-core`
10
- export const add = async function (src, dist, { fail = defaultFail } = {}) {
11
- if (src === undefined) {
12
- return fail('No function source directory was specified')
13
- }
14
-
15
- if (!(await pathExists(src))) {
16
- return fail(`No function file or directory found at "${src}"`)
17
- }
18
-
19
- if (dist === undefined) {
20
- return fail('No function directory was specified')
21
- }
22
-
23
- const srcBasename = basename(src)
24
- const srcGlob = await getSrcGlob(src, srcBasename)
25
- await cpy(srcGlob, dist, { cwd: dirname(src), parents: true, overwrite: true })
26
- }
27
-
28
- const getSrcGlob = async function (src, srcBasename) {
29
- const srcStat = await fs.stat(src)
30
-
31
- if (srcStat.isDirectory()) {
32
- return `${srcBasename}/**`
33
- }
34
-
35
- return srcBasename
36
- }
37
-
38
- export const list = async function (functionsSrc, { fail = defaultFail } = {}) {
39
- if (functionsSrc === undefined || functionsSrc.length === 0) {
40
- return fail('No function directory was specified')
41
- }
42
-
43
- try {
44
- return await listFunctions(functionsSrc)
45
- } catch (error) {
46
- fail('Could not list Netlify Functions', { error })
47
- }
48
- }
49
-
50
- export const listAll = async function (functionsSrc, { fail = defaultFail } = {}) {
51
- if (functionsSrc === undefined || functionsSrc.length === 0) {
52
- return fail('No function directory was specified')
53
- }
54
-
55
- try {
56
- return await listFunctionsFiles(functionsSrc)
57
- } catch (error) {
58
- fail('Could not list Netlify Functions files', { error })
59
- }
60
- }
61
-
62
- const defaultFail = function (message) {
63
- throw new Error(message)
64
- }