@beyondwork/wb-cli 0.1.0 → 0.1.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/out/cli.js +45 -6
  2. package/package.json +4 -3
package/out/cli.js CHANGED
@@ -38,7 +38,6 @@ const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
39
  const commander_1 = require("commander");
40
40
  const lib_1 = require("./lib");
41
- // Setup logger
42
41
  const logger = new lib_1.ConsoleLogger();
43
42
  // Define CLI
44
43
  commander_1.program
@@ -51,22 +50,17 @@ commander_1.program
51
50
  .option('-o, --output <file>', 'Output file (defaults to stdout)')
52
51
  .action(async (directory, options) => {
53
52
  try {
54
- // Resolve absolute path
55
53
  const dirPath = path.resolve(directory);
56
- // Check if directory exists
57
54
  if (!fs.existsSync(dirPath)) {
58
55
  logger.error(`Directory does not exist: ${dirPath}`);
59
56
  process.exit(1);
60
57
  }
61
- // Assemble workblock
62
58
  const workblock = await (0, lib_1.assembleWorkblock)(dirPath, logger);
63
59
  if (!workblock) {
64
60
  logger.error('Failed to assemble workblock');
65
61
  process.exit(1);
66
62
  }
67
- // Format output
68
63
  const output = JSON.stringify(workblock, null, 2);
69
- // Write to file or stdout
70
64
  if (options.output) {
71
65
  const outputPath = path.resolve(options.output);
72
66
  fs.writeFileSync(outputPath, output);
@@ -81,5 +75,50 @@ commander_1.program
81
75
  process.exit(1);
82
76
  }
83
77
  });
78
+ commander_1.program
79
+ .command('submit <directory> <url>')
80
+ .description('Assemble a workblock and POST it to a URL')
81
+ .action(async (directory, url) => {
82
+ try {
83
+ const dirPath = path.resolve(directory);
84
+ if (!fs.existsSync(dirPath)) {
85
+ logger.error(`Directory does not exist: ${dirPath}`);
86
+ process.exit(1);
87
+ }
88
+ const workblock = await (0, lib_1.assembleWorkblock)(dirPath, logger);
89
+ if (!workblock) {
90
+ logger.error('Failed to assemble workblock');
91
+ process.exit(1);
92
+ }
93
+ const output = JSON.stringify(workblock, null, 2);
94
+ logger.log(`Submitting workblock to ${url}...`);
95
+ const response = await fetch(url, {
96
+ method: 'POST',
97
+ headers: {
98
+ 'Content-Type': 'application/json',
99
+ },
100
+ body: output,
101
+ });
102
+ if (response.ok) {
103
+ logger.log(`Workblock submitted successfully to ${url}. Status: ${response.status}`);
104
+ const responseBody = await response.text();
105
+ if (responseBody) {
106
+ logger.log(`Response: ${responseBody}`);
107
+ }
108
+ }
109
+ else {
110
+ logger.error(`Failed to submit workblock. Status: ${response.status}`);
111
+ const errorBody = await response.text();
112
+ if (errorBody) {
113
+ logger.error(`Error details: ${errorBody}`);
114
+ }
115
+ process.exit(1);
116
+ }
117
+ }
118
+ catch (error) {
119
+ logger.error(`Error: ${error}`);
120
+ process.exit(1);
121
+ }
122
+ });
84
123
  commander_1.program.parse();
85
124
  //# sourceMappingURL=cli.js.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publisher": "beyondwork",
4
4
  "displayName": "Beyond Work",
5
5
  "description": "Beyond Work is a tool for managing your work in a way that is easy to use and understand.",
6
- "version": "0.1.0",
6
+ "version": "0.1.1",
7
7
  "engines": {
8
8
  "vscode": "^1.94.0",
9
9
  "node": ">=16.0.0"
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "files": [
18
18
  "out/lib/**/*",
19
- "out/cli.js"
19
+ "out/cli.js",
20
+ "out/extension.js"
20
21
  ],
21
22
  "main": "./out/extension.js",
22
23
  "private": false,
@@ -77,7 +78,7 @@
77
78
  "explorer": [
78
79
  {
79
80
  "id": "beyondworkConnections",
80
- "name": "Beyond Work"
81
+ "name": "@beyondwork/wb-cli"
81
82
  }
82
83
  ]
83
84
  }