pgflow 0.9.1 → 0.10.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/dist/commands/install/index.d.ts.map +1 -1
- package/dist/commands/install/index.js +2 -8
- package/dist/package.json +6 -1
- package/package.json +7 -2
- package/dist/commands/install/update-env-file.d.ts +0 -12
- package/dist/commands/install/update-env-file.d.ts.map +0 -1
- package/dist/commands/install/update-env-file.js +0 -86
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/install/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/install/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;yBAUzB,SAAS,OAAO;AAAhC,wBAuHE"}
|
|
@@ -2,7 +2,6 @@ import { intro, log, confirm, cancel, outro } from '@clack/prompts';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { copyMigrations } from './copy-migrations.js';
|
|
4
4
|
import { updateConfigToml } from './update-config-toml.js';
|
|
5
|
-
import { updateEnvFile } from './update-env-file.js';
|
|
6
5
|
import { createEdgeFunction } from './create-edge-function.js';
|
|
7
6
|
import { createFlowsDirectory } from './create-flows-directory.js';
|
|
8
7
|
import { createExampleWorker } from './create-example-worker.js';
|
|
@@ -33,7 +32,6 @@ export default (program) => {
|
|
|
33
32
|
` • Create ${chalk.cyan('supabase/flows/')} ${chalk.dim('(flow definitions with GreetUser example)')}`,
|
|
34
33
|
` • Create Control Plane in ${chalk.cyan('supabase/functions/pgflow/')}`,
|
|
35
34
|
` • Create ${chalk.cyan('supabase/functions/greet-user-worker/')} ${chalk.dim('(example worker)')}`,
|
|
36
|
-
` • Configure ${chalk.cyan('supabase/functions/.env')}`,
|
|
37
35
|
'',
|
|
38
36
|
` ${chalk.green('✓ Safe to re-run - completed steps will be skipped')}`,
|
|
39
37
|
].join('\n');
|
|
@@ -74,13 +72,9 @@ export default (program) => {
|
|
|
74
72
|
supabasePath,
|
|
75
73
|
autoConfirm: true,
|
|
76
74
|
});
|
|
77
|
-
const envFile = await updateEnvFile({
|
|
78
|
-
supabasePath,
|
|
79
|
-
autoConfirm: true,
|
|
80
|
-
});
|
|
81
75
|
// Step 4: Show completion message
|
|
82
76
|
const outroMessages = [];
|
|
83
|
-
if (migrations || configUpdate || flowsDirectory || edgeFunction || exampleWorker
|
|
77
|
+
if (migrations || configUpdate || flowsDirectory || edgeFunction || exampleWorker) {
|
|
84
78
|
outroMessages.push(chalk.green.bold('✓ Installation complete!'));
|
|
85
79
|
}
|
|
86
80
|
else {
|
|
@@ -90,7 +84,7 @@ export default (program) => {
|
|
|
90
84
|
outroMessages.push('');
|
|
91
85
|
outroMessages.push('Next steps:');
|
|
92
86
|
let stepNumber = 1;
|
|
93
|
-
if (configUpdate
|
|
87
|
+
if (configUpdate) {
|
|
94
88
|
outroMessages.push(` ${stepNumber}. Restart Supabase: ${chalk.cyan('supabase stop && supabase start')}`);
|
|
95
89
|
stepNumber++;
|
|
96
90
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/pgflow-dev/pgflow",
|
|
8
|
+
"directory": "pkgs/cli"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"main": "./dist/index.js",
|
|
7
12
|
"typings": "./dist/index.d.ts",
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/pgflow-dev/pgflow",
|
|
8
|
+
"directory": "pkgs/cli"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"main": "./dist/index.js",
|
|
7
12
|
"typings": "./dist/index.d.ts",
|
|
@@ -25,7 +30,7 @@
|
|
|
25
30
|
"@decimalturn/toml-patch": "0.3.7",
|
|
26
31
|
"chalk": "^5.4.1",
|
|
27
32
|
"commander": "^13.1.0",
|
|
28
|
-
"@pgflow/core": "0.
|
|
33
|
+
"@pgflow/core": "0.10.0"
|
|
29
34
|
},
|
|
30
35
|
"publishConfig": {
|
|
31
36
|
"access": "public"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Updates the functions/.env file with required environment variables for pgflow
|
|
3
|
-
*
|
|
4
|
-
* @param options.supabasePath - Path to the supabase directory
|
|
5
|
-
* @param options.autoConfirm - Whether to automatically confirm changes
|
|
6
|
-
* @returns Promise<boolean> - True if changes were made, false otherwise
|
|
7
|
-
*/
|
|
8
|
-
export declare function updateEnvFile({ supabasePath, autoConfirm, }: {
|
|
9
|
-
supabasePath: string;
|
|
10
|
-
autoConfirm?: boolean;
|
|
11
|
-
}): Promise<boolean>;
|
|
12
|
-
//# sourceMappingURL=update-env-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-env-file.d.ts","sourceRoot":"","sources":["../../../src/commands/install/update-env-file.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,EAClC,YAAY,EACZ,WAAmB,GACpB,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,OAAO,CAAC,CAyFnB"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { log, confirm } from '@clack/prompts';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
/**
|
|
6
|
-
* Updates the functions/.env file with required environment variables for pgflow
|
|
7
|
-
*
|
|
8
|
-
* @param options.supabasePath - Path to the supabase directory
|
|
9
|
-
* @param options.autoConfirm - Whether to automatically confirm changes
|
|
10
|
-
* @returns Promise<boolean> - True if changes were made, false otherwise
|
|
11
|
-
*/
|
|
12
|
-
export async function updateEnvFile({ supabasePath, autoConfirm = false, }) {
|
|
13
|
-
// Check environment variables
|
|
14
|
-
const functionsDir = path.join(supabasePath, 'functions');
|
|
15
|
-
const envFilePath = path.join(functionsDir, '.env');
|
|
16
|
-
// Create functions directory if it doesn't exist
|
|
17
|
-
if (!fs.existsSync(functionsDir)) {
|
|
18
|
-
fs.mkdirSync(functionsDir, { recursive: true });
|
|
19
|
-
}
|
|
20
|
-
// Variables to add
|
|
21
|
-
const envVars = {
|
|
22
|
-
EDGE_WORKER_LOG_LEVEL: 'info',
|
|
23
|
-
};
|
|
24
|
-
// Check if file exists and read its content
|
|
25
|
-
let currentContent = '';
|
|
26
|
-
let isNewFile = false;
|
|
27
|
-
if (fs.existsSync(envFilePath)) {
|
|
28
|
-
currentContent = fs.readFileSync(envFilePath, 'utf8');
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
isNewFile = true;
|
|
32
|
-
}
|
|
33
|
-
// Prepare new content
|
|
34
|
-
let newContent = currentContent;
|
|
35
|
-
// Check which variables need to be added
|
|
36
|
-
const missingVars = [];
|
|
37
|
-
for (const [key, value] of Object.entries(envVars)) {
|
|
38
|
-
if (!newContent.includes(`${key}=`)) {
|
|
39
|
-
missingVars.push({ key, value });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// If no changes needed, return early
|
|
43
|
-
if (missingVars.length === 0) {
|
|
44
|
-
log.success('Environment variables already configured');
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
// Show preview and ask for confirmation only when not auto-confirming
|
|
48
|
-
if (!autoConfirm) {
|
|
49
|
-
const summaryParts = [
|
|
50
|
-
isNewFile
|
|
51
|
-
? `Create ${chalk.cyan('functions/.env')} ${chalk.dim('(worker configuration)')}:`
|
|
52
|
-
: `Update ${chalk.cyan('functions/.env')} ${chalk.dim('(worker configuration)')}:`,
|
|
53
|
-
'',
|
|
54
|
-
...missingVars.map(({ key, value }) => ` ${chalk.bold(key)}="${value}"`),
|
|
55
|
-
];
|
|
56
|
-
log.info(summaryParts.join('\n'));
|
|
57
|
-
const confirmResult = await confirm({
|
|
58
|
-
message: isNewFile ? `Create functions/.env?` : `Update functions/.env?`,
|
|
59
|
-
});
|
|
60
|
-
if (confirmResult !== true) {
|
|
61
|
-
log.warn('Environment variable update skipped');
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Update environment variables
|
|
66
|
-
// Apply changes if confirmed
|
|
67
|
-
for (const { key, value } of missingVars) {
|
|
68
|
-
// Add a newline at the end if the file doesn't end with one and isn't empty
|
|
69
|
-
if (newContent && !newContent.endsWith('\n')) {
|
|
70
|
-
newContent += '\n';
|
|
71
|
-
}
|
|
72
|
-
// Add the new variable
|
|
73
|
-
newContent += `${key}="${value}"\n`;
|
|
74
|
-
}
|
|
75
|
-
// Write the file if changes were made
|
|
76
|
-
try {
|
|
77
|
-
fs.writeFileSync(envFilePath, newContent);
|
|
78
|
-
log.success('Environment variables configured');
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
83
|
-
log.error(`Failed to update environment variables: ${errorMessage}`);
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|