do-functions-cli 1.4.0 → 1.5.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/README.md +34 -1
- package/dist/cli.js +1 -5
- package/dist/cli.js.map +1 -1
- package/dist/schemas/doFunction.d.ts +4 -1
- package/dist/schemas/doFunction.d.ts.map +1 -1
- package/dist/schemas/doFunction.js +7 -2
- package/dist/schemas/doFunction.js.map +1 -1
- package/dist/schemas/doPackage.d.ts +4 -2
- package/dist/schemas/doPackage.d.ts.map +1 -1
- package/dist/schemas/doPackage.js +6 -2
- package/dist/schemas/doPackage.js.map +1 -1
- package/dist/schemas/doProjectYml.d.ts +6 -3
- package/dist/schemas/doProjectYml.d.ts.map +1 -1
- package/dist/schemas/doProjectYml.js +7 -2
- package/dist/schemas/doProjectYml.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"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Zod schema for validating a DigitalOcean function entry in project.yml
|
|
4
|
+
*
|
|
5
|
+
* Uses .passthrough() to preserve custom properties (e.g., environment variables,
|
|
6
|
+
* limits, annotations) that may exist in function configurations
|
|
4
7
|
*/
|
|
5
8
|
export declare const DOFunctionSchema: z.ZodObject<{
|
|
6
9
|
name: z.ZodString;
|
|
7
10
|
runtime: z.ZodOptional<z.ZodString>;
|
|
8
11
|
web: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
9
|
-
}, z.core.$
|
|
12
|
+
}, z.core.$loose>;
|
|
10
13
|
/**
|
|
11
14
|
* TypeScript type derived from the DOFunctionSchema
|
|
12
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doFunction.d.ts","sourceRoot":"","sources":["../../src/schemas/doFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB
|
|
1
|
+
{"version":3,"file":"doFunction.d.ts","sourceRoot":"","sources":["../../src/schemas/doFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;iBAMb,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Zod schema for validating a DigitalOcean function entry in project.yml
|
|
4
|
+
*
|
|
5
|
+
* Uses .passthrough() to preserve custom properties (e.g., environment variables,
|
|
6
|
+
* limits, annotations) that may exist in function configurations
|
|
4
7
|
*/
|
|
5
|
-
export const DOFunctionSchema = z
|
|
8
|
+
export const DOFunctionSchema = z
|
|
9
|
+
.object({
|
|
6
10
|
name: z.string(),
|
|
7
11
|
runtime: z.string().optional(),
|
|
8
12
|
web: z.boolean().optional().default(true),
|
|
9
|
-
})
|
|
13
|
+
})
|
|
14
|
+
.passthrough();
|
|
10
15
|
//# sourceMappingURL=doFunction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doFunction.js","sourceRoot":"","sources":["../../src/schemas/doFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB
|
|
1
|
+
{"version":3,"file":"doFunction.js","sourceRoot":"","sources":["../../src/schemas/doFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CAC1C,CAAC;KACD,WAAW,EAAE,CAAC"}
|
|
@@ -5,6 +5,8 @@ import * as z from 'zod';
|
|
|
5
5
|
* Properties:
|
|
6
6
|
* - name: The package name (required, used for namespacing functions)
|
|
7
7
|
* - functions: Array of functions belonging to this package (defaults to empty array)
|
|
8
|
+
*
|
|
9
|
+
* Uses .passthrough() to preserve custom properties that may exist in package configurations
|
|
8
10
|
*/
|
|
9
11
|
export declare const DOPackageSchema: z.ZodObject<{
|
|
10
12
|
name: z.ZodString;
|
|
@@ -12,8 +14,8 @@ export declare const DOPackageSchema: z.ZodObject<{
|
|
|
12
14
|
name: z.ZodString;
|
|
13
15
|
runtime: z.ZodOptional<z.ZodString>;
|
|
14
16
|
web: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
|
-
}, z.core.$
|
|
16
|
-
}, z.core.$
|
|
17
|
+
}, z.core.$loose>>>>;
|
|
18
|
+
}, z.core.$loose>;
|
|
17
19
|
/**
|
|
18
20
|
* TypeScript type derived from the DOPackageSchema
|
|
19
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doPackage.d.ts","sourceRoot":"","sources":["../../src/schemas/doPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB
|
|
1
|
+
{"version":3,"file":"doPackage.d.ts","sourceRoot":"","sources":["../../src/schemas/doPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;;;;;iBAKZ,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -6,9 +6,13 @@ import { DOFunctionSchema } from './doFunction.js';
|
|
|
6
6
|
* Properties:
|
|
7
7
|
* - name: The package name (required, used for namespacing functions)
|
|
8
8
|
* - functions: Array of functions belonging to this package (defaults to empty array)
|
|
9
|
+
*
|
|
10
|
+
* Uses .passthrough() to preserve custom properties that may exist in package configurations
|
|
9
11
|
*/
|
|
10
|
-
export const DOPackageSchema = z
|
|
12
|
+
export const DOPackageSchema = z
|
|
13
|
+
.object({
|
|
11
14
|
name: z.string(),
|
|
12
15
|
functions: z.array(DOFunctionSchema).optional().default([]),
|
|
13
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.passthrough();
|
|
14
18
|
//# sourceMappingURL=doPackage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doPackage.js","sourceRoot":"","sources":["../../src/schemas/doPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"doPackage.js","sourceRoot":"","sources":["../../src/schemas/doPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC5D,CAAC;KACD,WAAW,EAAE,CAAC"}
|
|
@@ -4,6 +4,9 @@ import * as z from 'zod';
|
|
|
4
4
|
*
|
|
5
5
|
* Properties:
|
|
6
6
|
* - packages: Array of packages that make up the project (defaults to empty array)
|
|
7
|
+
*
|
|
8
|
+
* Uses .passthrough() to preserve custom properties (e.g., environment, targetNamespace)
|
|
9
|
+
* that may exist in the project.yml file
|
|
7
10
|
*/
|
|
8
11
|
export declare const DOProjectYmlSchema: z.ZodObject<{
|
|
9
12
|
packages: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -12,9 +15,9 @@ export declare const DOProjectYmlSchema: z.ZodObject<{
|
|
|
12
15
|
name: z.ZodString;
|
|
13
16
|
runtime: z.ZodOptional<z.ZodString>;
|
|
14
17
|
web: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
|
-
}, z.core.$
|
|
16
|
-
}, z.core.$
|
|
17
|
-
}, z.core.$
|
|
18
|
+
}, z.core.$loose>>>>;
|
|
19
|
+
}, z.core.$loose>>>>;
|
|
20
|
+
}, z.core.$loose>;
|
|
18
21
|
/**
|
|
19
22
|
* TypeScript type derived from the DOProjectYmlSchema
|
|
20
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doProjectYml.d.ts","sourceRoot":"","sources":["../../src/schemas/doProjectYml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB
|
|
1
|
+
{"version":3,"file":"doProjectYml.d.ts","sourceRoot":"","sources":["../../src/schemas/doProjectYml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;iBAIf,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -5,8 +5,13 @@ import { DOPackageSchema } from './doPackage.js';
|
|
|
5
5
|
*
|
|
6
6
|
* Properties:
|
|
7
7
|
* - packages: Array of packages that make up the project (defaults to empty array)
|
|
8
|
+
*
|
|
9
|
+
* Uses .passthrough() to preserve custom properties (e.g., environment, targetNamespace)
|
|
10
|
+
* that may exist in the project.yml file
|
|
8
11
|
*/
|
|
9
|
-
export const DOProjectYmlSchema = z
|
|
12
|
+
export const DOProjectYmlSchema = z
|
|
13
|
+
.object({
|
|
10
14
|
packages: z.array(DOPackageSchema).optional().default([]),
|
|
11
|
-
})
|
|
15
|
+
})
|
|
16
|
+
.passthrough();
|
|
12
17
|
//# sourceMappingURL=doProjectYml.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doProjectYml.js","sourceRoot":"","sources":["../../src/schemas/doProjectYml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"doProjectYml.js","sourceRoot":"","sources":["../../src/schemas/doProjectYml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC1D,CAAC;KACD,WAAW,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "do-functions-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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
|
}
|