codify-plugin-lib 1.0.180 → 1.0.182-beta1

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 (44) hide show
  1. package/dist/bin/build.d.ts +1 -0
  2. package/dist/bin/build.js +80 -0
  3. package/dist/bin/deploy-plugin.d.ts +2 -0
  4. package/dist/bin/deploy-plugin.js +8 -0
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/plugin/plugin.js +5 -2
  8. package/dist/pty/background-pty.d.ts +1 -0
  9. package/dist/pty/background-pty.js +17 -3
  10. package/dist/pty/index.d.ts +17 -1
  11. package/dist/pty/seqeuntial-pty.d.ts +16 -0
  12. package/dist/pty/seqeuntial-pty.js +84 -0
  13. package/dist/resource/parsed-resource-settings.d.ts +3 -1
  14. package/dist/resource/parsed-resource-settings.js +4 -6
  15. package/dist/resource/resource-settings.d.ts +5 -1
  16. package/dist/resource/resource-settings.js +4 -3
  17. package/dist/scripts/deploy.d.ts +1 -0
  18. package/dist/scripts/deploy.js +2 -0
  19. package/dist/utils/codify-spawn.d.ts +29 -0
  20. package/dist/utils/codify-spawn.js +136 -0
  21. package/dist/utils/index.d.ts +25 -0
  22. package/dist/utils/index.js +108 -0
  23. package/dist/utils/internal-utils.d.ts +18 -0
  24. package/dist/utils/internal-utils.js +86 -0
  25. package/dist/utils/pty-local-storage.d.ts +0 -1
  26. package/package.json +17 -12
  27. package/src/index.ts +1 -1
  28. package/src/plan/plan.test.ts +6 -1
  29. package/src/plugin/plugin.test.ts +11 -2
  30. package/src/plugin/plugin.ts +5 -2
  31. package/src/pty/background-pty.ts +20 -3
  32. package/src/pty/index.test.ts +7 -4
  33. package/src/pty/index.ts +17 -1
  34. package/src/pty/seqeuntial-pty.ts +105 -0
  35. package/src/pty/sequential-pty.test.ts +61 -0
  36. package/src/resource/parsed-resource-settings.ts +8 -7
  37. package/src/resource/resource-controller-stateful-mode.test.ts +2 -1
  38. package/src/resource/resource-controller.test.ts +22 -4
  39. package/src/resource/resource-settings.test.ts +29 -2
  40. package/src/resource/resource-settings.ts +16 -4
  41. package/src/utils/index.ts +140 -0
  42. package/src/utils/{utils.test.ts → internal-utils.test.ts} +1 -1
  43. package/src/utils/test-utils.test.ts +5 -2
  44. /package/src/utils/{utils.ts → internal-utils.ts} +0 -0
@@ -0,0 +1,140 @@
1
+ import { OS } from 'codify-schemas';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+
5
+ export enum Shell {
6
+ ZSH = 'zsh',
7
+ BASH = 'bash',
8
+ SH = 'sh',
9
+ KSH = 'ksh',
10
+ CSH = 'csh',
11
+ FISH = 'fish',
12
+ }
13
+
14
+ export interface SystemInfo {
15
+ os: OS;
16
+ shell: Shell;
17
+ }
18
+
19
+ export const Utils = {
20
+ getUser(): string {
21
+ return os.userInfo().username;
22
+ },
23
+
24
+ getSystemInfo() {
25
+ return {
26
+ os: os.type(),
27
+ shell: this.getShell(),
28
+ }
29
+ },
30
+
31
+ isMacOS(): boolean {
32
+ return os.platform() === 'darwin';
33
+ },
34
+
35
+ isLinux(): boolean {
36
+ return os.platform() === 'linux';
37
+ },
38
+
39
+ getShell(): Shell | undefined {
40
+ const shell = process.env.SHELL || '';
41
+
42
+ if (shell.endsWith('bash')) {
43
+ return Shell.BASH
44
+ }
45
+
46
+ if (shell.endsWith('zsh')) {
47
+ return Shell.ZSH
48
+ }
49
+
50
+ if (shell.endsWith('sh')) {
51
+ return Shell.SH
52
+ }
53
+
54
+ if (shell.endsWith('csh')) {
55
+ return Shell.CSH
56
+ }
57
+
58
+ if (shell.endsWith('ksh')) {
59
+ return Shell.KSH
60
+ }
61
+
62
+ if (shell.endsWith('fish')) {
63
+ return Shell.FISH
64
+ }
65
+
66
+ return undefined;
67
+ },
68
+
69
+
70
+ getPrimaryShellRc(): string {
71
+ return this.getShellRcFiles()[0];
72
+ },
73
+
74
+ getShellRcFiles(): string[] {
75
+ const shell = process.env.SHELL || '';
76
+ const homeDir = os.homedir();
77
+
78
+ if (shell.endsWith('bash')) {
79
+ // Linux typically uses .bashrc, macOS uses .bash_profile
80
+ if (Utils.isLinux()) {
81
+ return [
82
+ path.join(homeDir, '.bashrc'),
83
+ path.join(homeDir, '.bash_profile'),
84
+ path.join(homeDir, '.profile'),
85
+ ];
86
+ }
87
+
88
+ return [
89
+ path.join(homeDir, '.bash_profile'),
90
+ path.join(homeDir, '.bashrc'),
91
+ path.join(homeDir, '.profile'),
92
+ ];
93
+ }
94
+
95
+ if (shell.endsWith('zsh')) {
96
+ return [
97
+ path.join(homeDir, '.zshrc'),
98
+ path.join(homeDir, '.zprofile'),
99
+ path.join(homeDir, '.zshenv'),
100
+ ];
101
+ }
102
+
103
+ if (shell.endsWith('sh')) {
104
+ return [
105
+ path.join(homeDir, '.profile'),
106
+ ]
107
+ }
108
+
109
+ if (shell.endsWith('ksh')) {
110
+ return [
111
+ path.join(homeDir, '.profile'),
112
+ path.join(homeDir, '.kshrc'),
113
+ ]
114
+ }
115
+
116
+ if (shell.endsWith('csh')) {
117
+ return [
118
+ path.join(homeDir, '.cshrc'),
119
+ path.join(homeDir, '.login'),
120
+ path.join(homeDir, '.logout'),
121
+ ]
122
+ }
123
+
124
+ if (shell.endsWith('fish')) {
125
+ return [
126
+ path.join(homeDir, '.config/fish/config.fish'),
127
+ ]
128
+ }
129
+
130
+ // Default to bash-style files
131
+ return [
132
+ path.join(homeDir, '.bashrc'),
133
+ path.join(homeDir, '.bash_profile'),
134
+ path.join(homeDir, '.profile'),
135
+ ];
136
+ },
137
+ };
138
+
139
+
140
+
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { addVariablesToPath, resolvePathWithVariables, splitUserConfig } from './utils.js';
2
+ import { addVariablesToPath, resolvePathWithVariables, splitUserConfig } from './internal-utils.js';
3
3
  import os from 'node:os';
4
4
 
5
5
  describe('Utils tests', () => {
@@ -1,4 +1,4 @@
1
- import { ResourceConfig, StringIndexedObject } from 'codify-schemas';
1
+ import { OS, ResourceConfig, StringIndexedObject } from 'codify-schemas';
2
2
  import { ResourceSettings } from '../resource/resource-settings.js';
3
3
  import { Plan } from '../plan/plan.js';
4
4
  import { Resource } from '../resource/resource.js';
@@ -35,7 +35,10 @@ export interface TestConfig extends StringIndexedObject {
35
35
 
36
36
  export class TestResource extends Resource<TestConfig> {
37
37
  getSettings(): ResourceSettings<TestConfig> {
38
- return { id: 'type' }
38
+ return {
39
+ id: 'type',
40
+ operatingSystems: [OS.Darwin]
41
+ }
39
42
  }
40
43
 
41
44
  create(plan: CreatePlan<TestConfig>): Promise<void> {
File without changes