do-functions-cli 1.4.0 → 1.5.0
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 +34 -1
- package/dist/cli.js +1 -5
- package/dist/cli.js.map +1 -1
- package/package.json +22 -7
package/README.md
CHANGED
|
@@ -82,6 +82,39 @@ your-project/
|
|
|
82
82
|
└── project.yml # DigitalOcean project configuration
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
## Bundling with esbuild
|
|
86
|
+
|
|
87
|
+
The generated function templates include [esbuild](https://esbuild.github.io/) for bundling your code. This ensures compatibility with DigitalOcean Functions by:
|
|
88
|
+
|
|
89
|
+
- **Bundling all dependencies** — All `node_modules` are bundled into a single file (`dist/bundle.js`)
|
|
90
|
+
- **CommonJS output** — Code is transpiled to CommonJS format (`--format=cjs`) for compatibility with the DigitalOcean Functions runtime
|
|
91
|
+
- **Node.js 18 targeting** — The bundle is optimized for Node.js 18 (`--target=node18`)
|
|
92
|
+
- **Minification** — Output is minified to reduce file size and improve cold start times
|
|
93
|
+
|
|
94
|
+
### Build Script
|
|
95
|
+
|
|
96
|
+
Each function includes a `build` script in `package.json`:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# JavaScript
|
|
100
|
+
esbuild ./index.js --bundle --platform=node --target=node18 --format=cjs --outfile=./dist/bundle.js --minify
|
|
101
|
+
|
|
102
|
+
# TypeScript (includes type checking)
|
|
103
|
+
tsc --noEmit && esbuild ./index.ts --bundle --platform=node --target=node18 --format=cjs --outfile=./dist/bundle.js --minify
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
DigitalOcean automatically runs `npm run build` during deployment, so you don't need to build manually before deploying.
|
|
107
|
+
|
|
108
|
+
### The .include File
|
|
109
|
+
|
|
110
|
+
Each function contains a `.include` file that tells DigitalOcean which files to include in the deployed function. By default, it points to the bundled output:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
dist/bundle.js
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
This means only the bundled file is deployed, keeping your function package small and fast.
|
|
117
|
+
|
|
85
118
|
## project.yml Configuration
|
|
86
119
|
|
|
87
120
|
The CLI automatically manages your `project.yml` file:
|
|
@@ -97,7 +130,7 @@ packages:
|
|
|
97
130
|
|
|
98
131
|
## Requirements
|
|
99
132
|
|
|
100
|
-
- Node.js
|
|
133
|
+
- Node.js 20.12.0 or later
|
|
101
134
|
- npm or compatible package manager
|
|
102
135
|
|
|
103
136
|
## Roadmap
|
package/dist/cli.js
CHANGED
|
@@ -3,13 +3,9 @@ import { Command } from 'commander';
|
|
|
3
3
|
import fs from 'fs-extra/esm';
|
|
4
4
|
import createCommand from './commands/create.js';
|
|
5
5
|
const packageJson = await fs.readJSON(new URL('../package.json', import.meta.url));
|
|
6
|
-
const cliVersion = packageJson.version;
|
|
7
6
|
// Initialize the main CLI program
|
|
8
7
|
const program = new Command();
|
|
9
|
-
program
|
|
10
|
-
.name('do-functions-cli')
|
|
11
|
-
.description('CLI tool for managing DigitalOcean serverless functions')
|
|
12
|
-
.version(cliVersion);
|
|
8
|
+
program.name(packageJson.name).description(packageJson.description).version(packageJson.version);
|
|
13
9
|
// Register the 'create' command for creating new serverless functions
|
|
14
10
|
program.addCommand(createCommand);
|
|
15
11
|
// Parse command-line arguments and execute
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,cAAc,CAAC;AAE9B,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,cAAc,CAAC;AAE9B,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnF,kCAAkC;AAClC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEjG,sEAAsE;AACtE,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAElC,2CAA2C;AAC3C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B;;;;GAIG;AACH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;IACxC,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "do-functions-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "CLI tool for scaffolding DigitalOcean Serverless Functions with JavaScript and TypeScript templates, automatic dependency installation, and project.yml configuration.",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/grantchatterton/do-functions-cli.git"
|
|
8
9
|
},
|
|
10
|
+
"homepage": "https://github.com/grantchatterton/do-functions-cli#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/grantchatterton/do-functions-cli/issues"
|
|
13
|
+
},
|
|
9
14
|
"author": "Grant Chatterton",
|
|
10
15
|
"license": "MIT",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20.12.0"
|
|
18
|
+
},
|
|
11
19
|
"bin": {
|
|
12
20
|
"do-functions-cli": "dist/cli.js"
|
|
13
21
|
},
|
|
@@ -48,13 +56,20 @@
|
|
|
48
56
|
"templates"
|
|
49
57
|
],
|
|
50
58
|
"keywords": [
|
|
59
|
+
"digitalocean",
|
|
60
|
+
"serverless",
|
|
51
61
|
"functions",
|
|
52
|
-
"
|
|
53
|
-
"typescript",
|
|
62
|
+
"faas",
|
|
54
63
|
"cli",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
64
|
+
"scaffold",
|
|
65
|
+
"generator",
|
|
66
|
+
"typescript",
|
|
67
|
+
"javascript",
|
|
68
|
+
"nodejs",
|
|
69
|
+
"cloud-functions",
|
|
70
|
+
"serverless-functions",
|
|
71
|
+
"do-functions",
|
|
72
|
+
"function-template",
|
|
73
|
+
"project-generator"
|
|
59
74
|
]
|
|
60
75
|
}
|