@flowcore/cli 4.13.5 → 4.14.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/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  * added description to start that includes week ([58687a7](https://github.com/flowcore-io/flowcore-cli/commit/58687a7bbb66aaa5d6da26af88e555cbb1e72467))
12
12
 
13
+ ## [4.14.0](https://github.com/flowcore-io/flowcore-cli/compare/v4.13.5...v4.14.0) (2025-05-22)
14
+
15
+
16
+ ### Features
17
+
18
+ * **update:** :sparkles: add update command and check for updates hook ([0ef3af6](https://github.com/flowcore-io/flowcore-cli/commit/0ef3af694909aec6dad5081f57ddd70cb876be30))
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **update:** :art: simplify error handling in update command and check-updates hook ([abaf50d](https://github.com/flowcore-io/flowcore-cli/commit/abaf50d392ff83e467328c81f271a1e4b968a94a))
24
+
13
25
  ## [4.13.5](https://github.com/flowcore-io/flowcore-cli/compare/v4.13.4...v4.13.5) (2025-05-22)
14
26
 
15
27
 
package/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @flowcore/cli
18
18
  $ flowcore COMMAND
19
19
  running command...
20
20
  $ flowcore (--version)
21
- @flowcore/cli/4.13.5 linux-x64 node-v20.16.0
21
+ @flowcore/cli/4.14.0 linux-x64 node-v20.16.0
22
22
  $ flowcore --help [COMMAND]
23
23
  USAGE
24
24
  $ flowcore COMMAND
@@ -84,6 +84,7 @@ USAGE
84
84
  * [`flowcore scenario local`](#flowcore-scenario-local)
85
85
  * [`flowcore stream STREAM`](#flowcore-stream-stream)
86
86
  * [`flowcore stream http STREAM`](#flowcore-stream-http-stream)
87
+ * [`flowcore update`](#flowcore-update)
87
88
  * [`flowcore version`](#flowcore-version)
88
89
  * [`flowcore whoami`](#flowcore-whoami)
89
90
 
@@ -108,7 +109,7 @@ EXAMPLES
108
109
  $ flowcore apply -f ./path/to/manifest.yml
109
110
  ```
110
111
 
111
- _See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.13.5/src/commands/apply.ts)_
112
+ _See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.14.0/src/commands/apply.ts)_
112
113
 
113
114
  ## `flowcore auth delete key API_KEY_NAME`
114
115
 
@@ -561,7 +562,7 @@ EXAMPLES
561
562
  cat ./path/to/manifest.yml | flowcore delete -f -
562
563
  ```
563
564
 
564
- _See code: [src/commands/delete.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.13.5/src/commands/delete.ts)_
565
+ _See code: [src/commands/delete.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.14.0/src/commands/delete.ts)_
565
566
 
566
567
  ## `flowcore delete policy NAME`
567
568
 
@@ -628,7 +629,7 @@ EXAMPLES
628
629
  $ flowcore diff -f ./path/to/manifest.yml
629
630
  ```
630
631
 
631
- _See code: [src/commands/diff.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.13.5/src/commands/diff.ts)_
632
+ _See code: [src/commands/diff.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.14.0/src/commands/diff.ts)_
632
633
 
633
634
  ## `flowcore edit policy NAME`
634
635
 
@@ -872,7 +873,7 @@ EXAMPLES
872
873
  $ flowcore info
873
874
  ```
874
875
 
875
- _See code: [src/commands/info.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.13.5/src/commands/info.ts)_
876
+ _See code: [src/commands/info.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.14.0/src/commands/info.ts)_
876
877
 
877
878
  ## `flowcore login`
878
879
 
@@ -1601,6 +1602,23 @@ EXAMPLES
1601
1602
 
1602
1603
  _See code: [@flowcore/cli-plugin-core](https://github.com/flowcore/flowcore-cli-plugin-core/blob/v5.5.0/src/commands/stream/http.ts)_
1603
1604
 
1605
+ ## `flowcore update`
1606
+
1607
+ Update the Flowcore CLI to the latest version
1608
+
1609
+ ```
1610
+ USAGE
1611
+ $ flowcore update
1612
+
1613
+ DESCRIPTION
1614
+ Update the Flowcore CLI to the latest version
1615
+
1616
+ EXAMPLES
1617
+ $ flowcore update
1618
+ ```
1619
+
1620
+ _See code: [src/commands/update.ts](https://github.com/flowcore-io/flowcore-cli/blob/v4.14.0/src/commands/update.ts)_
1621
+
1604
1622
  ## `flowcore version`
1605
1623
 
1606
1624
  ```
@@ -0,0 +1,6 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Update extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,41 @@
1
+ import { Command } from '@oclif/core';
2
+ import { exec } from 'node:child_process';
3
+ import { promisify } from 'node:util';
4
+ const execAsync = promisify(exec);
5
+ export default class Update extends Command {
6
+ static description = 'Update the Flowcore CLI to the latest version';
7
+ static examples = [
8
+ '$ flowcore update',
9
+ ];
10
+ async run() {
11
+ const { config } = this;
12
+ const packageName = config.pjson.name;
13
+ this.log('Checking for updates...');
14
+ try {
15
+ // Get current and latest version
16
+ const currentVersion = config.version;
17
+ const { stdout: latestVersionStdout } = await execAsync(`npm view ${packageName} version`);
18
+ const latestVersion = latestVersionStdout.trim();
19
+ if (latestVersion === currentVersion) {
20
+ this.log(`You're already using the latest version (${currentVersion}).`);
21
+ return;
22
+ }
23
+ this.log(`Updating from ${currentVersion} to ${latestVersion}...`);
24
+ // Check if global or local installation and update accordingly
25
+ try {
26
+ await execAsync(`npm list -g ${packageName}`);
27
+ // If we reached here, it's a global installation
28
+ await execAsync(`npm install -g ${packageName}@latest`);
29
+ }
30
+ catch {
31
+ // It's a local installation or error occurred
32
+ await execAsync(`npm install ${packageName}@latest`);
33
+ }
34
+ this.log(`✅ Successfully updated to version ${latestVersion}!`);
35
+ this.log('Please restart any running CLI processes to use the new version.');
36
+ }
37
+ catch (error) {
38
+ this.error(`Failed to update: ${error instanceof Error ? error.message : String(error)}`);
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,3 @@
1
+ import { Hook } from '@oclif/core';
2
+ declare const hook: Hook<'init'>;
3
+ export default hook;
@@ -0,0 +1,57 @@
1
+ import { exec } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { promisify } from 'node:util';
5
+ const execAsync = promisify(exec);
6
+ // The update check is done by the @oclif/plugin-warn-if-update-available plugin
7
+ // This hook just ensures it runs each time and can add custom behavior
8
+ const hook = async function ({ config }) {
9
+ // Only run this hook if not in a test environment
10
+ if (process.env.NODE_ENV === 'test')
11
+ return;
12
+ try {
13
+ // Get current package info
14
+ const pkg = config.pjson;
15
+ const currentVersion = pkg.version;
16
+ // Check if we've recently looked for updates (to avoid checking on every command)
17
+ const cacheDir = path.join(config.cacheDir, 'update-check');
18
+ const cacheFile = path.join(cacheDir, 'last-check');
19
+ let lastCheck = 0;
20
+ try {
21
+ if (fs.existsSync(cacheFile)) {
22
+ lastCheck = Number.parseInt(fs.readFileSync(cacheFile, 'utf8'), 10);
23
+ }
24
+ }
25
+ catch {
26
+ // If we can't read the cache file, continue with check
27
+ }
28
+ const now = Date.now();
29
+ const checkInterval = 1000 * 60 * 60 * 24; // 1 day in milliseconds
30
+ // Only check once per day
31
+ if (now - lastCheck < checkInterval) {
32
+ return;
33
+ }
34
+ // Write the current time to the cache file
35
+ try {
36
+ if (!fs.existsSync(cacheDir)) {
37
+ fs.mkdirSync(cacheDir, { recursive: true });
38
+ }
39
+ fs.writeFileSync(cacheFile, now.toString());
40
+ }
41
+ catch {
42
+ // If we can't write to the cache file, continue anyway
43
+ }
44
+ // Make a request to npm to get the latest version
45
+ const { stdout } = await execAsync(`npm view ${pkg.name} version`);
46
+ const latestVersion = stdout.trim();
47
+ // Compare versions
48
+ if (latestVersion !== currentVersion) {
49
+ // The @oclif/plugin-warn-if-update-available plugin will handle the notification
50
+ // This hook just makes sure the check happens regularly
51
+ }
52
+ }
53
+ catch {
54
+ // Silently fail on error - we don't want to break the CLI if update check fails
55
+ }
56
+ };
57
+ export default hook;
@@ -171,7 +171,30 @@
171
171
  "commands",
172
172
  "info.js"
173
173
  ]
174
+ },
175
+ "update": {
176
+ "aliases": [],
177
+ "args": {},
178
+ "description": "Update the Flowcore CLI to the latest version",
179
+ "examples": [
180
+ "$ flowcore update"
181
+ ],
182
+ "flags": {},
183
+ "hasDynamicHelp": false,
184
+ "hiddenAliases": [],
185
+ "id": "update",
186
+ "pluginAlias": "@flowcore/cli",
187
+ "pluginName": "@flowcore/cli",
188
+ "pluginType": "core",
189
+ "strict": true,
190
+ "enableJsonFlag": false,
191
+ "isESM": true,
192
+ "relativePath": [
193
+ "dist",
194
+ "commands",
195
+ "update.js"
196
+ ]
174
197
  }
175
198
  },
176
- "version": "4.13.5"
199
+ "version": "4.14.0"
177
200
  }
package/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  },
6
6
  "dependencies": {
7
7
  "@datastructures-js/queue": "^4.2.3",
8
+ "@flowcore/cli": "^4.13.5",
8
9
  "@flowcore/cli-plugin-ai": "^1.1.2",
9
10
  "@flowcore/cli-plugin-auth-management": "^1.4.0",
10
11
  "@flowcore/cli-plugin-config": "^2.5.0",
@@ -98,7 +99,10 @@
98
99
  },
99
100
  "topicSeparator": " ",
100
101
  "hooks": {
101
- "init": "./dist/hooks/init/add-jsr"
102
+ "init": [
103
+ "./dist/hooks/init/add-jsr",
104
+ "./dist/hooks/init/check-updates"
105
+ ]
102
106
  }
103
107
  },
104
108
  "repository": "flowcore-io/flowcore-cli",
@@ -115,7 +119,7 @@
115
119
  "prestart": "npm run build",
116
120
  "update-schema": "rover graph introspect https://graph.api.staging.flowcore.io/graphql -o schema.gql"
117
121
  },
118
- "version": "4.13.5",
122
+ "version": "4.14.0",
119
123
  "bugs": "https://github.com/flowcore-io/flowcore-cli/issues",
120
124
  "keywords": [
121
125
  "flowcore",