@uxland/harmonix-cli 0.0.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.
Files changed (2) hide show
  1. package/index.js +44 -0
  2. package/package.json +26 -0
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require('commander');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const axios = require('axios');
7
+ const FormData = require('form-data');
8
+
9
+ console.log("reached index");
10
+
11
+ program
12
+ .command('publish')
13
+ .option('--url <url>', 'Backend URL', 'https://preproduccio.componentssiscat.hes.catsalut.intranet.gencat.cat/api/plugins/version')
14
+ .action(async (opts) => {
15
+ try {
16
+ const filePath = path.resolve(process.cwd(), "dist", "index.js");
17
+ const packageJsonPath = path.resolve(process.cwd(), "package.json");
18
+
19
+ if (!fs.existsSync(filePath)) {
20
+ console.error(`File not found: ${filePath}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ if (!fs.existsSync(packageJsonPath)) {
25
+ console.error(`package.json not found in: ${process.cwd()}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const { name: pluginId, version: versionNumber } = require(packageJsonPath);
30
+ const formData = new FormData();
31
+ formData.append("versionNumber", versionNumber);
32
+ formData.append("pluginId", pluginId);
33
+ formData.append('file', fs.createReadStream(filePath));
34
+
35
+
36
+ const response = await axios.post(opts.url, formData);
37
+
38
+ console.log('✅ Plugin published:', response.data);
39
+ } catch (err) {
40
+ console.error('❌ Failed to publish:', err.message);
41
+ }
42
+ });
43
+
44
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@uxland/harmonix-cli",
3
+ "version": "0.0.1",
4
+ "bin": {
5
+ "harmonix": "index.js"
6
+ },
7
+ "files": [
8
+ "index.js"
9
+ ],
10
+ "main": "index.js",
11
+ "description": "CLI tool for Harmonix",
12
+ "author": "Cristian Payet <cpayet@uxland.cat>",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "license": "MIT",
17
+ "keywords": [
18
+ "cli",
19
+ "harmonix"
20
+ ],
21
+ "dependencies": {
22
+ "axios": "^1.0.0",
23
+ "commander": "^9.4.0",
24
+ "form-data": "^4.0.0"
25
+ }
26
+ }