codify-plugin-lib 1.0.182-beta54 → 1.0.182-beta56

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.
@@ -1,6 +1,6 @@
1
1
  import { Ajv } from 'ajv';
2
2
  import addFormats from 'ajv-formats';
3
- import { ApplyRequestDataSchema, ApplyResponseDataSchema, EmptyResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, IpcMessageSchema, IpcMessageV2Schema, MatchRequestDataSchema, MatchResponseDataSchema, MessageStatus, PlanRequestDataSchema, PlanResponseDataSchema, ResourceSchema, SetVerbosityRequestDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema } from 'codify-schemas';
3
+ import { ApplyRequestDataSchema, EmptyResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, IpcMessageSchema, IpcMessageV2Schema, MatchRequestDataSchema, MatchResponseDataSchema, MessageStatus, PlanRequestDataSchema, PlanResponseDataSchema, ResourceSchema, SetVerbosityRequestDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema } from 'codify-schemas';
4
4
  import { SudoError } from '../errors.js';
5
5
  const SupportedRequests = {
6
6
  'initialize': {
@@ -19,9 +19,12 @@ const SupportedRequests = {
19
19
  responseValidator: GetResourceInfoResponseDataSchema
20
20
  },
21
21
  'setVerbosityLevel': {
22
- handler: async (plugin, data) => plugin.setVerbosityLevel(data),
22
+ async handler(plugin, data) {
23
+ await plugin.setVerbosityLevel(data);
24
+ return null;
25
+ },
23
26
  requestValidator: SetVerbosityRequestDataSchema,
24
- responseValidator: EmptyResponseDataSchema
27
+ responseValidator: EmptyResponseDataSchema,
25
28
  },
26
29
  'match': {
27
30
  handler: async (plugin, data) => plugin.match(data),
@@ -44,7 +47,7 @@ const SupportedRequests = {
44
47
  return null;
45
48
  },
46
49
  requestValidator: ApplyRequestDataSchema,
47
- responseValidator: ApplyResponseDataSchema
50
+ responseValidator: EmptyResponseDataSchema
48
51
  },
49
52
  };
50
53
  export class MessageHandler {
@@ -20,6 +20,7 @@ export class BackgroundPty {
20
20
  historyIgnore = Utils.getShell() === Shell.ZSH ? { HISTORY_IGNORE: '*' } : { HISTIGNORE: '*' };
21
21
  basePty = pty.spawn(this.getDefaultShell(), ['-i'], {
22
22
  env: { ...process.env, ...this.historyIgnore },
23
+ cols: 10_000, // Set to a really large value to prevent wrapping
23
24
  name: nanoid(6),
24
25
  handleFlowControl: true
25
26
  });
@@ -49,7 +49,7 @@ export class SequentialPty {
49
49
  ...historyIgnore
50
50
  };
51
51
  // Initial terminal dimensions
52
- const initialCols = process.stdout.columns ?? 80;
52
+ const initialCols = 10_000; // Set to a really large value to prevent wrapping
53
53
  const initialRows = process.stdout.rows ?? 24;
54
54
  const args = options?.interactive ? ['-i', '-c', cmd] : ['-c', cmd];
55
55
  // Run the command in a pty for interactivity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta54",
3
+ "version": "1.0.182-beta56",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "ajv": "^8.12.0",
23
23
  "ajv-formats": "^2.1.1",
24
24
  "clean-deep": "^3.4.0",
25
- "codify-schemas": "1.0.86-beta9",
25
+ "codify-schemas": "1.0.86-beta10",
26
26
  "lodash.isequal": "^4.5.0",
27
27
  "nanoid": "^5.0.9",
28
28
  "strip-ansi": "^7.1.0",
package/rollup.config.js CHANGED
@@ -7,7 +7,7 @@ import typescript from '@rollup/plugin-typescript';
7
7
  export default {
8
8
  input: 'src/index.ts',
9
9
  output: {
10
- dir:'dist',
10
+ dir: 'dist',
11
11
  format: 'cjs',
12
12
  inlineDynamicImports: true,
13
13
  },
@@ -15,7 +15,7 @@ export default {
15
15
  plugins: [
16
16
  json(),
17
17
  nodeResolve({ exportConditions: ['node'] }),
18
- typescript({
18
+ typescript({
19
19
  exclude: ['**/*.test.ts', '**/*.d.ts', 'test']
20
20
  }),
21
21
  commonjs(),
@@ -235,6 +235,29 @@ describe('Message handler tests', () => {
235
235
  process.send = undefined;
236
236
  })
237
237
 
238
+ it('handles changing the verbosity level', async () => {
239
+ const resource = new TestResource()
240
+ const plugin = testPlugin(resource);
241
+ const handler = new MessageHandler(plugin);
242
+
243
+ process.send = (message) => {
244
+ expect(message).toMatchObject({
245
+ cmd: 'setVerbosityLevel_Response',
246
+ status: MessageStatus.SUCCESS,
247
+ })
248
+ return true;
249
+ }
250
+
251
+ expect(async () => await handler.onMessage({
252
+ cmd: 'setVerbosityLevel',
253
+ data: {
254
+ verbosityLevel: 2,
255
+ }
256
+ })).rejects.to.not.throw;
257
+
258
+ process.send = undefined;
259
+ })
260
+
238
261
  it('Supports ipc message v2 (success)', async () => {
239
262
  const resource = new TestResource()
240
263
  const plugin = testPlugin(resource);
@@ -2,7 +2,7 @@ import { Ajv, SchemaObject, ValidateFunction } from 'ajv';
2
2
  import addFormats from 'ajv-formats';
3
3
  import {
4
4
  ApplyRequestDataSchema,
5
- ApplyResponseDataSchema, EmptyResponseDataSchema,
5
+ EmptyResponseDataSchema,
6
6
  GetResourceInfoRequestDataSchema,
7
7
  GetResourceInfoResponseDataSchema,
8
8
  ImportRequestDataSchema,
@@ -44,9 +44,12 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
44
44
  responseValidator: GetResourceInfoResponseDataSchema
45
45
  },
46
46
  'setVerbosityLevel': {
47
- handler: async (plugin: Plugin, data: any) => plugin.setVerbosityLevel(data),
47
+ async handler(plugin: Plugin, data: any) {
48
+ await plugin.setVerbosityLevel(data)
49
+ return null;
50
+ },
48
51
  requestValidator: SetVerbosityRequestDataSchema,
49
- responseValidator: EmptyResponseDataSchema
52
+ responseValidator: EmptyResponseDataSchema,
50
53
  },
51
54
  'match': {
52
55
  handler: async (plugin: Plugin, data: any) => plugin.match(data),
@@ -69,7 +72,7 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
69
72
  return null;
70
73
  },
71
74
  requestValidator: ApplyRequestDataSchema,
72
- responseValidator: ApplyResponseDataSchema
75
+ responseValidator: EmptyResponseDataSchema
73
76
  },
74
77
  }
75
78
 
@@ -23,6 +23,7 @@ export class BackgroundPty implements IPty {
23
23
  private historyIgnore = Utils.getShell() === Shell.ZSH ? { HISTORY_IGNORE: '*' } : { HISTIGNORE: '*' };
24
24
  private basePty = pty.spawn(this.getDefaultShell(), ['-i'], {
25
25
  env: { ...process.env, ...this.historyIgnore },
26
+ cols: 10_000, // Set to a really large value to prevent wrapping
26
27
  name: nanoid(6),
27
28
  handleFlowControl: true
28
29
  });
@@ -62,7 +62,7 @@ export class SequentialPty implements IPty {
62
62
  }
63
63
 
64
64
  // Initial terminal dimensions
65
- const initialCols = process.stdout.columns ?? 80;
65
+ const initialCols = 10_000; // Set to a really large value to prevent wrapping
66
66
  const initialRows = process.stdout.rows ?? 24;
67
67
 
68
68
  const args = options?.interactive ? ['-i', '-c', cmd] : ['-c', cmd]