pgflow 0.6.1 → 0.7.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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pgflow CLI
|
|
2
2
|
|
|
3
3
|
The Command Line Interface for pgflow - a PostgreSQL-native workflow engine.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ The Command Line Interface for pgflow - a PostgreSQL-native workflow engine.
|
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This package provides essential tools for setting up, managing, and deploying pgflow workflows in your Supabase environment. The CLI handles:
|
|
11
11
|
|
|
12
12
|
- Installing pgflow in your Supabase project
|
|
13
13
|
- Compiling TypeScript workflow definitions into SQL migrations
|
|
@@ -70,7 +70,7 @@ npx pgflow@latest compile supabase/functions/_flows/my_flow.ts
|
|
|
70
70
|
|
|
71
71
|
Options:
|
|
72
72
|
|
|
73
|
-
- `--deno-json <path>` - Path to custom deno.json
|
|
73
|
+
- `--deno-json <path>` - Path to custom deno.json configuration file
|
|
74
74
|
- `--supabase-path <path>` - Path to custom Supabase directory
|
|
75
75
|
|
|
76
76
|
The compiler will:
|
|
@@ -14,8 +14,8 @@ const __dirname = path.dirname(__filename);
|
|
|
14
14
|
function formatCommand(command, args) {
|
|
15
15
|
const cmd = chalk.cyan(command);
|
|
16
16
|
const formattedArgs = args.map((arg) => {
|
|
17
|
-
// Highlight
|
|
18
|
-
if (arg.startsWith('--
|
|
17
|
+
// Highlight config and file paths differently
|
|
18
|
+
if (arg.startsWith('--config=')) {
|
|
19
19
|
const [flag, value] = arg.split('=');
|
|
20
20
|
return ` ${chalk.yellow(flag)}=${chalk.green(value)}`;
|
|
21
21
|
}
|
|
@@ -46,7 +46,7 @@ export default (program) => {
|
|
|
46
46
|
.command('compile')
|
|
47
47
|
.description('Compiles a TypeScript-defined flow into SQL migration')
|
|
48
48
|
.argument('<flowPath>', 'Path to the flow TypeScript file')
|
|
49
|
-
.option('--deno-json <denoJsonPath>', 'Path to deno.json
|
|
49
|
+
.option('--deno-json <denoJsonPath>', 'Path to deno.json configuration file')
|
|
50
50
|
.option('--supabase-path <supabasePath>', 'Path to the Supabase folder')
|
|
51
51
|
.action(async (flowPath, options) => {
|
|
52
52
|
intro('pgflow - Compile Flow to SQL');
|
|
@@ -162,9 +162,9 @@ async function runDenoCompilation(scriptPath, flowPath, denoJsonPath) {
|
|
|
162
162
|
}
|
|
163
163
|
// Build the command arguments array
|
|
164
164
|
const args = ['run', '--allow-read', '--allow-net', '--allow-env'];
|
|
165
|
-
// Only add the
|
|
165
|
+
// Only add the config argument if denoJsonPath is provided and valid
|
|
166
166
|
if (denoJsonPath && typeof denoJsonPath === 'string') {
|
|
167
|
-
args.push(`--
|
|
167
|
+
args.push(`--config=${denoJsonPath}`);
|
|
168
168
|
}
|
|
169
169
|
// Add the script path and flow path
|
|
170
170
|
args.push(scriptPath, flowPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-config-toml.d.ts","sourceRoot":"","sources":["../../../src/commands/install/update-config-toml.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,YAAY,EACZ,WAAmB,GACpB,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"update-config-toml.d.ts","sourceRoot":"","sources":["../../../src/commands/install/update-config-toml.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,YAAY,EACZ,WAAmB,GACpB,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,OAAO,CAAC,CAwHnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { log, confirm, note } from '@clack/prompts';
|
|
4
|
-
import * as TOML from 'toml-patch';
|
|
4
|
+
import * as TOML from '@decimalturn/toml-patch';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
/**
|
|
7
7
|
* Updates the config.toml file with necessary configurations for EdgeWorker
|
|
@@ -27,7 +27,15 @@ export async function updateConfigToml({ supabasePath, autoConfirm = false, }) {
|
|
|
27
27
|
throw new Error(`config.toml not found at ${configPath}`);
|
|
28
28
|
}
|
|
29
29
|
const configContent = fs.readFileSync(configPath, 'utf8');
|
|
30
|
-
|
|
30
|
+
let config;
|
|
31
|
+
try {
|
|
32
|
+
config = TOML.parse(configContent);
|
|
33
|
+
}
|
|
34
|
+
catch (parseError) {
|
|
35
|
+
const errorMsg = parseError instanceof Error ? parseError.message : String(parseError);
|
|
36
|
+
log.error(`Invalid TOML syntax in ${configPath}: ${errorMsg}`);
|
|
37
|
+
throw new Error(`Invalid TOML syntax in ${configPath}: ${errorMsg}`);
|
|
38
|
+
}
|
|
31
39
|
const currentSettings = {
|
|
32
40
|
poolerEnabled: config.db?.pooler?.enabled ?? false,
|
|
33
41
|
poolMode: config.db?.pooler?.pool_mode ?? 'none',
|
|
@@ -82,31 +90,25 @@ ${chalk.green('+ policy = "per_worker"')}`);
|
|
|
82
90
|
updatedConfig.db.pooler.enabled = true;
|
|
83
91
|
updatedConfig.db.pooler.pool_mode = 'transaction';
|
|
84
92
|
updatedConfig.edge_runtime.policy = 'per_worker';
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// Fix db.pooler.pool_mode line - transforms "pool_mode = "transaction"," into "pool_mode = "transaction""
|
|
105
|
-
/pool_mode = "transaction",(\s*$|\s*#|\s*\n)/g, 'pool_mode = "transaction"$1')
|
|
106
|
-
.replace(
|
|
107
|
-
// Fix edge_runtime.policy line - transforms "policy = "per_worker"," into "policy = "per_worker""
|
|
108
|
-
/policy = "per_worker",(\s*$|\s*#|\s*\n)/g, 'policy = "per_worker"$1');
|
|
109
|
-
fs.writeFileSync(configPath, updatedContent);
|
|
93
|
+
let updatedContent;
|
|
94
|
+
try {
|
|
95
|
+
updatedContent = TOML.patch(configContent, updatedConfig, {
|
|
96
|
+
trailingComma: false,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (stringifyError) {
|
|
100
|
+
const errorMsg = stringifyError instanceof Error ? stringifyError.message : String(stringifyError);
|
|
101
|
+
log.error(`Failed to generate TOML for ${configPath}: ${errorMsg}`);
|
|
102
|
+
throw new Error(`Failed to generate TOML for ${configPath}: ${errorMsg}`);
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
fs.writeFileSync(configPath, updatedContent);
|
|
106
|
+
}
|
|
107
|
+
catch (writeError) {
|
|
108
|
+
const errorMsg = writeError instanceof Error ? writeError.message : String(writeError);
|
|
109
|
+
log.error(`Failed to write ${configPath}: ${errorMsg}`);
|
|
110
|
+
throw new Error(`Failed to write ${configPath}: ${errorMsg}`);
|
|
111
|
+
}
|
|
110
112
|
log.success('Supabase configuration updated successfully');
|
|
111
113
|
return true;
|
|
112
114
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@clack/prompts": "^0.10.1",
|
|
23
23
|
"@commander-js/extra-typings": "^13.1.0",
|
|
24
|
+
"@decimalturn/toml-patch": "0.3.7",
|
|
24
25
|
"@pgflow/core": "workspace:*",
|
|
25
26
|
"chalk": "^5.4.1",
|
|
26
|
-
"commander": "^13.1.0"
|
|
27
|
-
"toml-patch": "^0.2.3"
|
|
27
|
+
"commander": "^13.1.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@clack/prompts": "^0.10.1",
|
|
23
23
|
"@commander-js/extra-typings": "^13.1.0",
|
|
24
|
+
"@decimalturn/toml-patch": "0.3.7",
|
|
24
25
|
"chalk": "^5.4.1",
|
|
25
26
|
"commander": "^13.1.0",
|
|
26
|
-
"
|
|
27
|
-
"@pgflow/core": "0.6.1"
|
|
27
|
+
"@pgflow/core": "0.7.1"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|