rampway 0.2.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 (143) hide show
  1. package/README.md +183 -0
  2. package/build/src/cli.d.ts +3 -0
  3. package/build/src/cli.d.ts.map +1 -0
  4. package/build/src/cli.js +104 -0
  5. package/build/src/cli.js.map +1 -0
  6. package/build/src/commands/context.d.ts +12 -0
  7. package/build/src/commands/context.d.ts.map +1 -0
  8. package/build/src/commands/context.js +16 -0
  9. package/build/src/commands/context.js.map +1 -0
  10. package/build/src/commands/deploy.d.ts +6 -0
  11. package/build/src/commands/deploy.d.ts.map +1 -0
  12. package/build/src/commands/deploy.js +14 -0
  13. package/build/src/commands/deploy.js.map +1 -0
  14. package/build/src/commands/doctor.d.ts +14 -0
  15. package/build/src/commands/doctor.d.ts.map +1 -0
  16. package/build/src/commands/doctor.js +54 -0
  17. package/build/src/commands/doctor.js.map +1 -0
  18. package/build/src/commands/init.d.ts +8 -0
  19. package/build/src/commands/init.d.ts.map +1 -0
  20. package/build/src/commands/init.js +42 -0
  21. package/build/src/commands/init.js.map +1 -0
  22. package/build/src/commands/plan.d.ts +6 -0
  23. package/build/src/commands/plan.d.ts.map +1 -0
  24. package/build/src/commands/plan.js +24 -0
  25. package/build/src/commands/plan.js.map +1 -0
  26. package/build/src/commands/releases.d.ts +27 -0
  27. package/build/src/commands/releases.d.ts.map +1 -0
  28. package/build/src/commands/releases.js +91 -0
  29. package/build/src/commands/releases.js.map +1 -0
  30. package/build/src/commands/rollback.d.ts +6 -0
  31. package/build/src/commands/rollback.d.ts.map +1 -0
  32. package/build/src/commands/rollback.js +12 -0
  33. package/build/src/commands/rollback.js.map +1 -0
  34. package/build/src/commands/rollbridge.d.ts +21 -0
  35. package/build/src/commands/rollbridge.d.ts.map +1 -0
  36. package/build/src/commands/rollbridge.js +69 -0
  37. package/build/src/commands/rollbridge.js.map +1 -0
  38. package/build/src/commands/validate.d.ts +6 -0
  39. package/build/src/commands/validate.d.ts.map +1 -0
  40. package/build/src/commands/validate.js +12 -0
  41. package/build/src/commands/validate.js.map +1 -0
  42. package/build/src/config/load-config.d.ts +10 -0
  43. package/build/src/config/load-config.d.ts.map +1 -0
  44. package/build/src/config/load-config.js +71 -0
  45. package/build/src/config/load-config.js.map +1 -0
  46. package/build/src/config/validate-config.d.ts +7 -0
  47. package/build/src/config/validate-config.d.ts.map +1 -0
  48. package/build/src/config/validate-config.js +117 -0
  49. package/build/src/config/validate-config.js.map +1 -0
  50. package/build/src/core/deploy-runner.d.ts +46 -0
  51. package/build/src/core/deploy-runner.d.ts.map +1 -0
  52. package/build/src/core/deploy-runner.js +221 -0
  53. package/build/src/core/deploy-runner.js.map +1 -0
  54. package/build/src/core/expo-web-artifacts.d.ts +10 -0
  55. package/build/src/core/expo-web-artifacts.d.ts.map +1 -0
  56. package/build/src/core/expo-web-artifacts.js +16 -0
  57. package/build/src/core/expo-web-artifacts.js.map +1 -0
  58. package/build/src/core/git-source.d.ts +22 -0
  59. package/build/src/core/git-source.d.ts.map +1 -0
  60. package/build/src/core/git-source.js +63 -0
  61. package/build/src/core/git-source.js.map +1 -0
  62. package/build/src/core/health-checks.d.ts +8 -0
  63. package/build/src/core/health-checks.d.ts.map +1 -0
  64. package/build/src/core/health-checks.js +19 -0
  65. package/build/src/core/health-checks.js.map +1 -0
  66. package/build/src/core/hooks.d.ts +12 -0
  67. package/build/src/core/hooks.d.ts.map +1 -0
  68. package/build/src/core/hooks.js +26 -0
  69. package/build/src/core/hooks.js.map +1 -0
  70. package/build/src/core/locks.d.ts +16 -0
  71. package/build/src/core/locks.d.ts.map +1 -0
  72. package/build/src/core/locks.js +32 -0
  73. package/build/src/core/locks.js.map +1 -0
  74. package/build/src/core/node-package-tasks.d.ts +26 -0
  75. package/build/src/core/node-package-tasks.d.ts.map +1 -0
  76. package/build/src/core/node-package-tasks.js +143 -0
  77. package/build/src/core/node-package-tasks.js.map +1 -0
  78. package/build/src/core/path-change-gate.d.ts +15 -0
  79. package/build/src/core/path-change-gate.d.ts.map +1 -0
  80. package/build/src/core/path-change-gate.js +95 -0
  81. package/build/src/core/path-change-gate.js.map +1 -0
  82. package/build/src/core/paths.d.ts +7 -0
  83. package/build/src/core/paths.d.ts.map +1 -0
  84. package/build/src/core/paths.js +20 -0
  85. package/build/src/core/paths.js.map +1 -0
  86. package/build/src/core/redaction.d.ts +22 -0
  87. package/build/src/core/redaction.d.ts.map +1 -0
  88. package/build/src/core/redaction.js +39 -0
  89. package/build/src/core/redaction.js.map +1 -0
  90. package/build/src/core/release-id.d.ts +6 -0
  91. package/build/src/core/release-id.d.ts.map +1 -0
  92. package/build/src/core/release-id.js +20 -0
  93. package/build/src/core/release-id.js.map +1 -0
  94. package/build/src/core/release-manager.d.ts +49 -0
  95. package/build/src/core/release-manager.d.ts.map +1 -0
  96. package/build/src/core/release-manager.js +115 -0
  97. package/build/src/core/release-manager.js.map +1 -0
  98. package/build/src/core/task-runner.d.ts +38 -0
  99. package/build/src/core/task-runner.d.ts.map +1 -0
  100. package/build/src/core/task-runner.js +102 -0
  101. package/build/src/core/task-runner.js.map +1 -0
  102. package/build/src/core/velocious-migrate.d.ts +11 -0
  103. package/build/src/core/velocious-migrate.d.ts.map +1 -0
  104. package/build/src/core/velocious-migrate.js +20 -0
  105. package/build/src/core/velocious-migrate.js.map +1 -0
  106. package/build/src/runtimes/index.d.ts +56 -0
  107. package/build/src/runtimes/index.d.ts.map +1 -0
  108. package/build/src/runtimes/index.js +132 -0
  109. package/build/src/runtimes/index.js.map +1 -0
  110. package/build/src/runtimes/none-runtime.d.ts +22 -0
  111. package/build/src/runtimes/none-runtime.d.ts.map +1 -0
  112. package/build/src/runtimes/none-runtime.js +23 -0
  113. package/build/src/runtimes/none-runtime.js.map +1 -0
  114. package/build/src/runtimes/rollbridge-runtime.d.ts +137 -0
  115. package/build/src/runtimes/rollbridge-runtime.d.ts.map +1 -0
  116. package/build/src/runtimes/rollbridge-runtime.js +224 -0
  117. package/build/src/runtimes/rollbridge-runtime.js.map +1 -0
  118. package/build/src/tasks.d.ts +5 -0
  119. package/build/src/tasks.d.ts.map +1 -0
  120. package/build/src/tasks.js +5 -0
  121. package/build/src/tasks.js.map +1 -0
  122. package/build/src/test-helpers.d.ts +25 -0
  123. package/build/src/test-helpers.d.ts.map +1 -0
  124. package/build/src/test-helpers.js +40 -0
  125. package/build/src/test-helpers.js.map +1 -0
  126. package/build/src/transports/local-transport.d.ts +67 -0
  127. package/build/src/transports/local-transport.d.ts.map +1 -0
  128. package/build/src/transports/local-transport.js +121 -0
  129. package/build/src/transports/local-transport.js.map +1 -0
  130. package/build/src/transports/ssh-transport.d.ts +189 -0
  131. package/build/src/transports/ssh-transport.d.ts.map +1 -0
  132. package/build/src/transports/ssh-transport.js +369 -0
  133. package/build/src/transports/ssh-transport.js.map +1 -0
  134. package/build/src/types.d.ts +290 -0
  135. package/build/src/types.d.ts.map +1 -0
  136. package/build/src/types.js +8 -0
  137. package/build/src/types.js.map +1 -0
  138. package/docs/config-reference.md +264 -0
  139. package/docs/migration-from-capistrano.md +167 -0
  140. package/docs/roadmap.md +27 -0
  141. package/examples/local/rampway.config.mjs +20 -0
  142. package/examples/monorepo/rampway.config.mjs +73 -0
  143. package/package.json +92 -0
@@ -0,0 +1,189 @@
1
+ /**
2
+ * @param {import('#types').TransportConfig} host
3
+ * @returns {string}
4
+ */
5
+ export function sshDestination(host: import("#types").TransportConfig): string;
6
+ /**
7
+ * @param {import('#types').TransportConfig} host
8
+ * @param {string} command
9
+ * @returns {string[]}
10
+ */
11
+ export function sshArgs(host: import("#types").TransportConfig, command: string): string[];
12
+ /**
13
+ * @param {unknown} value
14
+ * @returns {string}
15
+ */
16
+ export function shellQuote(value: unknown): string;
17
+ /**
18
+ * @param {unknown} key
19
+ * @returns {string}
20
+ */
21
+ export function shellEnvKey(key: unknown): string;
22
+ /**
23
+ * @param {unknown} value
24
+ * @returns {string}
25
+ */
26
+ export function remotePath(value: unknown): string;
27
+ export class SshTransport {
28
+ /**
29
+ * @param {import('#types').StageConfig} stage
30
+ * @returns {SshTransport}
31
+ */
32
+ static fromStage(stage: import("#types").StageConfig): SshTransport;
33
+ /**
34
+ * @param {{host: import('#types').TransportConfig}} opts
35
+ */
36
+ constructor({ host }: {
37
+ host: import("#types").TransportConfig;
38
+ });
39
+ /** @type {import('#types').TransportConfig} */
40
+ host: import("#types").TransportConfig;
41
+ /**
42
+ * @param {string} targetPath
43
+ * @returns {Promise<void>}
44
+ */
45
+ mkdirp(targetPath: string): Promise<void>;
46
+ /**
47
+ * @param {string} targetPath
48
+ * @returns {Promise<boolean>}
49
+ */
50
+ exists(targetPath: string): Promise<boolean>;
51
+ /**
52
+ * @param {string} target
53
+ * @param {string} linkPath
54
+ * @returns {Promise<void>}
55
+ */
56
+ symlink(target: string, linkPath: string): Promise<void>;
57
+ /**
58
+ * @param {string} linkPath
59
+ * @returns {Promise<string>}
60
+ */
61
+ readlink(linkPath: string): Promise<string>;
62
+ /**
63
+ * @param {string} targetPath
64
+ * @returns {Promise<void>}
65
+ */
66
+ rm(targetPath: string): Promise<void>;
67
+ /**
68
+ * @param {string} from
69
+ * @param {string} to
70
+ * @returns {Promise<void>}
71
+ */
72
+ rename(from: string, to: string): Promise<void>;
73
+ /**
74
+ * @param {string} filePath
75
+ * @param {string} content
76
+ * @returns {Promise<void>}
77
+ */
78
+ writeFile(filePath: string, content: string): Promise<void>;
79
+ /**
80
+ * @param {string} filePath
81
+ * @returns {Promise<string>}
82
+ */
83
+ readFile(filePath: string): Promise<string>;
84
+ /**
85
+ * @param {string} targetPath
86
+ * @returns {Promise<string[]>}
87
+ */
88
+ list(targetPath: string): Promise<string[]>;
89
+ /**
90
+ * @param {string} from
91
+ * @param {string} to
92
+ * @returns {Promise<void>}
93
+ */
94
+ copyDir(from: string, to: string): Promise<void>;
95
+ /**
96
+ * @param {string} command
97
+ * @param {{cwd?: string, env?: Record<string, string>}} [opts]
98
+ * @returns {Promise<import('#types').SpawnResult>}
99
+ */
100
+ run(command: string, { cwd, env }?: {
101
+ cwd?: string;
102
+ env?: Record<string, string>;
103
+ }): Promise<import("#types").SpawnResult>;
104
+ /**
105
+ * @param {string} targetPath
106
+ * @returns {import('#types').CommandPlan}
107
+ */
108
+ commandPlanForMkdirp(targetPath: string): import("#types").CommandPlan;
109
+ /**
110
+ * @param {string} targetPath
111
+ * @returns {import('#types').CommandPlan}
112
+ */
113
+ commandPlanForExists(targetPath: string): import("#types").CommandPlan;
114
+ /**
115
+ * @param {string} target
116
+ * @param {string} linkPath
117
+ * @returns {import('#types').CommandPlan}
118
+ */
119
+ commandPlanForSymlink(target: string, linkPath: string): import("#types").CommandPlan;
120
+ /**
121
+ * @param {string} linkPath
122
+ * @returns {import('#types').CommandPlan}
123
+ */
124
+ commandPlanForReadlink(linkPath: string): import("#types").CommandPlan;
125
+ /**
126
+ * @param {string} targetPath
127
+ * @returns {import('#types').CommandPlan}
128
+ */
129
+ commandPlanForRm(targetPath: string): import("#types").CommandPlan;
130
+ /**
131
+ * @param {string} from
132
+ * @param {string} to
133
+ * @returns {import('#types').CommandPlan}
134
+ */
135
+ commandPlanForRename(from: string, to: string): import("#types").CommandPlan;
136
+ /**
137
+ * @param {string} filePath
138
+ * @returns {import('#types').CommandPlan}
139
+ */
140
+ commandPlanForWriteFile(filePath: string): import("#types").CommandPlan;
141
+ /**
142
+ * @param {string} filePath
143
+ * @returns {import('#types').CommandPlan}
144
+ */
145
+ commandPlanForReadFile(filePath: string): import("#types").CommandPlan;
146
+ /**
147
+ * @param {string} targetPath
148
+ * @returns {import('#types').CommandPlan}
149
+ */
150
+ commandPlanForList(targetPath: string): import("#types").CommandPlan;
151
+ /**
152
+ * @param {string} from
153
+ * @param {string} to
154
+ * @returns {import('#types').CommandPlan}
155
+ */
156
+ commandPlanForCopyDir(from: string, to: string): import("#types").CommandPlan;
157
+ /**
158
+ * @param {string} command
159
+ * @param {{cwd?: string, env?: Record<string, string>}} [opts]
160
+ * @returns {import('#types').CommandPlan}
161
+ */
162
+ commandPlanForRun(command: string, { cwd, env }?: {
163
+ cwd?: string;
164
+ env?: Record<string, string>;
165
+ }): import("#types").CommandPlan;
166
+ /**
167
+ * @param {string} command
168
+ * @returns {import('#types').CommandPlan}
169
+ */
170
+ remoteCommandPlan(command: string): import("#types").CommandPlan;
171
+ /**
172
+ * @param {import('#types').CommandPlan} plan
173
+ * @param {{input?: string, stream?: boolean}} [opts]
174
+ * @returns {Promise<import('#types').SpawnResult>}
175
+ */
176
+ runCommandPlan(plan: import("#types").CommandPlan, { input, stream }?: {
177
+ input?: string;
178
+ stream?: boolean;
179
+ }): Promise<import("#types").SpawnResult>;
180
+ /**
181
+ * @param {import('#types').CommandPlan} plan
182
+ * @param {{stream?: boolean}} [opts]
183
+ * @returns {Promise<import('#types').SpawnResult>}
184
+ */
185
+ runPipedCommandPlan(plan: import("#types").CommandPlan, { stream }?: {
186
+ stream?: boolean;
187
+ }): Promise<import("#types").SpawnResult>;
188
+ }
189
+ //# sourceMappingURL=ssh-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/ssh-transport.js"],"names":[],"mappings":"AA2UA;;;GAGG;AACH,qCAHW,OAAO,QAAQ,EAAE,eAAe,GAC9B,MAAM,CAKlB;AAED;;;;GAIG;AACH,8BAJW,OAAO,QAAQ,EAAE,eAAe,WAChC,MAAM,GACJ,MAAM,EAAE,CASpB;AAED;;;GAGG;AACH,kCAHW,OAAO,GACL,MAAM,CAMlB;AAED;;;GAGG;AACH,iCAHW,OAAO,GACL,MAAM,CAOlB;AAED;;;GAGG;AACH,kCAHW,OAAO,GACL,MAAM,CAIlB;AAzXD;IASE;;;OAGG;IACH,wBAHW,OAAO,QAAQ,EAAE,WAAW,GAC1B,YAAY,CAIxB;IAdD;;OAEG;IACH,sBAFW;QAAC,IAAI,EAAE,OAAO,QAAQ,EAAE,eAAe,CAAA;KAAC,EAKlD;IAFC,+CAA+C;IA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AAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAIxC;IAED;;;OAGG;IACH,6BAHW,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAIxC;IAED;;;;OAIG;IACH,2BAJW,MAAM,MACN,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAIxC;IAED;;;OAGG;IACH,kCAHW,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAKxC;IAED;;;OAGG;IACH,iCAHW,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAIxC;IAED;;;OAGG;IACH,+BAHW,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAKxC;IAED;;;;OAIG;IACH,4BAJW,MAAM,MACN,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAQxC;IAED;;;;OAIG;IACH,2BAJW,MAAM,iBACN;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAC,GAC1C,OAAO,QAAQ,EAAE,WAAW,CASxC;IAED;;;OAGG;IACH,2BAHW,MAAM,GACJ,OAAO,QAAQ,EAAE,WAAW,CAIxC;IAED;;;;OAIG;IACH,qBAJW,OAAO,QAAQ,EAAE,WAAW,sBAC5B;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAC,GAChC,OAAO,CAAC,OAAO,QAAQ,EAAE,WAAW,CAAC,CAoCjD;IAED;;;;OAIG;IACH,0BAJW,OAAO,QAAQ,EAAE,WAAW,eAC5B;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAC,GAChB,OAAO,CAAC,OAAO,QAAQ,EAAE,WAAW,CAAC,CAkDjD;CACF"}
@@ -0,0 +1,369 @@
1
+ import { spawn } from "node:child_process";
2
+ import path from "node:path";
3
+ import { isSecretKey, redactText } from "../core/redaction.js";
4
+ export class SshTransport {
5
+ /**
6
+ * @param {{host: import('#types').TransportConfig}} opts
7
+ */
8
+ constructor({ host }) {
9
+ /** @type {import('#types').TransportConfig} */
10
+ this.host = host;
11
+ }
12
+ /**
13
+ * @param {import('#types').StageConfig} stage
14
+ * @returns {SshTransport}
15
+ */
16
+ static fromStage(stage) {
17
+ return new SshTransport({ host: stage.transport });
18
+ }
19
+ /**
20
+ * @param {string} targetPath
21
+ * @returns {Promise<void>}
22
+ */
23
+ async mkdirp(targetPath) {
24
+ await this.runCommandPlan(this.commandPlanForMkdirp(targetPath));
25
+ }
26
+ /**
27
+ * @param {string} targetPath
28
+ * @returns {Promise<boolean>}
29
+ */
30
+ async exists(targetPath) {
31
+ try {
32
+ await this.runCommandPlan(this.commandPlanForExists(targetPath));
33
+ return true;
34
+ }
35
+ catch (error) {
36
+ if ( /** @type {{exitCode?: number}} */(error).exitCode === 1)
37
+ return false;
38
+ throw error;
39
+ }
40
+ }
41
+ /**
42
+ * @param {string} target
43
+ * @param {string} linkPath
44
+ * @returns {Promise<void>}
45
+ */
46
+ async symlink(target, linkPath) {
47
+ await this.runCommandPlan(this.commandPlanForSymlink(target, linkPath));
48
+ }
49
+ /**
50
+ * @param {string} linkPath
51
+ * @returns {Promise<string>}
52
+ */
53
+ async readlink(linkPath) {
54
+ const result = await this.runCommandPlan(this.commandPlanForReadlink(linkPath), { stream: false });
55
+ return result.output.trim();
56
+ }
57
+ /**
58
+ * @param {string} targetPath
59
+ * @returns {Promise<void>}
60
+ */
61
+ async rm(targetPath) {
62
+ await this.runCommandPlan(this.commandPlanForRm(targetPath));
63
+ }
64
+ /**
65
+ * @param {string} from
66
+ * @param {string} to
67
+ * @returns {Promise<void>}
68
+ */
69
+ async rename(from, to) {
70
+ await this.runCommandPlan(this.commandPlanForRename(from, to));
71
+ }
72
+ /**
73
+ * @param {string} filePath
74
+ * @param {string} content
75
+ * @returns {Promise<void>}
76
+ */
77
+ async writeFile(filePath, content) {
78
+ await this.runCommandPlan(this.commandPlanForWriteFile(filePath), { input: content });
79
+ }
80
+ /**
81
+ * @param {string} filePath
82
+ * @returns {Promise<string>}
83
+ */
84
+ async readFile(filePath) {
85
+ const result = await this.runCommandPlan(this.commandPlanForReadFile(filePath), { stream: false });
86
+ return result.output;
87
+ }
88
+ /**
89
+ * @param {string} targetPath
90
+ * @returns {Promise<string[]>}
91
+ */
92
+ async list(targetPath) {
93
+ const result = await this.runCommandPlan(this.commandPlanForList(targetPath), { stream: false });
94
+ return result.output.split("\n").map(line => line.trim()).filter(Boolean);
95
+ }
96
+ /**
97
+ * @param {string} from
98
+ * @param {string} to
99
+ * @returns {Promise<void>}
100
+ */
101
+ async copyDir(from, to) {
102
+ await this.runCommandPlan(this.commandPlanForCopyDir(from, to));
103
+ }
104
+ /**
105
+ * @param {string} command
106
+ * @param {{cwd?: string, env?: Record<string, string>}} [opts]
107
+ * @returns {Promise<import('#types').SpawnResult>}
108
+ */
109
+ async run(command, { cwd, env = {} } = {}) {
110
+ return await this.runCommandPlan(this.commandPlanForRun(command, { cwd, env }));
111
+ }
112
+ /**
113
+ * @param {string} targetPath
114
+ * @returns {import('#types').CommandPlan}
115
+ */
116
+ commandPlanForMkdirp(targetPath) {
117
+ return this.remoteCommandPlan(`mkdir -p ${shellQuote(remotePath(targetPath))}`);
118
+ }
119
+ /**
120
+ * @param {string} targetPath
121
+ * @returns {import('#types').CommandPlan}
122
+ */
123
+ commandPlanForExists(targetPath) {
124
+ return this.remoteCommandPlan(`test -e ${shellQuote(remotePath(targetPath))}`);
125
+ }
126
+ /**
127
+ * @param {string} target
128
+ * @param {string} linkPath
129
+ * @returns {import('#types').CommandPlan}
130
+ */
131
+ commandPlanForSymlink(target, linkPath) {
132
+ return this.remoteCommandPlan(`ln -sfn ${shellQuote(remotePath(target))} ${shellQuote(remotePath(linkPath))}`);
133
+ }
134
+ /**
135
+ * @param {string} linkPath
136
+ * @returns {import('#types').CommandPlan}
137
+ */
138
+ commandPlanForReadlink(linkPath) {
139
+ return this.remoteCommandPlan(`readlink ${shellQuote(remotePath(linkPath))}`);
140
+ }
141
+ /**
142
+ * @param {string} targetPath
143
+ * @returns {import('#types').CommandPlan}
144
+ */
145
+ commandPlanForRm(targetPath) {
146
+ return this.remoteCommandPlan(`rm -rf ${shellQuote(remotePath(targetPath))}`);
147
+ }
148
+ /**
149
+ * @param {string} from
150
+ * @param {string} to
151
+ * @returns {import('#types').CommandPlan}
152
+ */
153
+ commandPlanForRename(from, to) {
154
+ return this.remoteCommandPlan(`mv -Tf ${shellQuote(remotePath(from))} ${shellQuote(remotePath(to))}`);
155
+ }
156
+ /**
157
+ * @param {string} filePath
158
+ * @returns {import('#types').CommandPlan}
159
+ */
160
+ commandPlanForWriteFile(filePath) {
161
+ const normalizedPath = remotePath(filePath);
162
+ return this.remoteCommandPlan(`mkdir -p ${shellQuote(path.posix.dirname(normalizedPath))} && cat > ${shellQuote(normalizedPath)}`);
163
+ }
164
+ /**
165
+ * @param {string} filePath
166
+ * @returns {import('#types').CommandPlan}
167
+ */
168
+ commandPlanForReadFile(filePath) {
169
+ return this.remoteCommandPlan(`cat ${shellQuote(remotePath(filePath))}`);
170
+ }
171
+ /**
172
+ * @param {string} targetPath
173
+ * @returns {import('#types').CommandPlan}
174
+ */
175
+ commandPlanForList(targetPath) {
176
+ const normalizedPath = remotePath(targetPath);
177
+ return this.remoteCommandPlan(`if test -d ${shellQuote(normalizedPath)}; then ls -1 ${shellQuote(normalizedPath)}; fi`);
178
+ }
179
+ /**
180
+ * @param {string} from
181
+ * @param {string} to
182
+ * @returns {import('#types').CommandPlan}
183
+ */
184
+ commandPlanForCopyDir(from, to) {
185
+ return {
186
+ command: "tar",
187
+ args: ["-C", from, "-cf", "-", "."],
188
+ pipeTo: this.remoteCommandPlan(`mkdir -p ${shellQuote(remotePath(to))} && tar -C ${shellQuote(remotePath(to))} -xf -`)
189
+ };
190
+ }
191
+ /**
192
+ * @param {string} command
193
+ * @param {{cwd?: string, env?: Record<string, string>}} [opts]
194
+ * @returns {import('#types').CommandPlan}
195
+ */
196
+ commandPlanForRun(command, { cwd, env = {} } = {}) {
197
+ const envPrefix = Object.entries(env).map(([key, value]) => `${shellEnvKey(key)}=${shellQuote(String(value))}`).join(" ");
198
+ const commandParts = [];
199
+ if (cwd)
200
+ commandParts.push(`cd ${shellQuote(remotePath(cwd))}`);
201
+ if (envPrefix)
202
+ commandParts.push(`export ${envPrefix}`);
203
+ commandParts.push(command);
204
+ return this.remoteCommandPlan(commandParts.join(" && "));
205
+ }
206
+ /**
207
+ * @param {string} command
208
+ * @returns {import('#types').CommandPlan}
209
+ */
210
+ remoteCommandPlan(command) {
211
+ return { command: "ssh", args: sshArgs(this.host, command) };
212
+ }
213
+ /**
214
+ * @param {import('#types').CommandPlan} plan
215
+ * @param {{input?: string, stream?: boolean}} [opts]
216
+ * @returns {Promise<import('#types').SpawnResult>}
217
+ */
218
+ async runCommandPlan(plan, { input, stream = true } = {}) {
219
+ if (plan.pipeTo)
220
+ return await this.runPipedCommandPlan(plan, { stream });
221
+ return await new Promise((resolve, reject) => {
222
+ const child = spawn(plan.command, plan.args);
223
+ let output = "";
224
+ let outputFlushed = false;
225
+ const flushOutput = () => {
226
+ if (!stream || outputFlushed)
227
+ return;
228
+ outputFlushed = true;
229
+ if (output)
230
+ process.stderr.write(redactText(output));
231
+ };
232
+ child.stdout.on("data", /** @param {Buffer|string} chunk */ /** @param {Buffer|string} chunk */ chunk => {
233
+ output += chunk.toString();
234
+ });
235
+ child.stderr.on("data", /** @param {Buffer|string} chunk */ /** @param {Buffer|string} chunk */ chunk => {
236
+ output += chunk.toString();
237
+ });
238
+ child.on("error", /** @param {Error} error */ /** @param {Error} error */ error => {
239
+ flushOutput();
240
+ reject(error);
241
+ });
242
+ child.on("close", /** @param {number|null} code */ /** @param {number|null} code */ code => {
243
+ flushOutput();
244
+ if (code === 0) {
245
+ resolve({ code, output });
246
+ }
247
+ else {
248
+ const error = /** @type {Error & {exitCode?: number}} */ (new Error(`Command failed with exit ${code}: ${redactText([plan.command, ...plan.args].join(" "))}\n${redactText(output)}`));
249
+ error.exitCode = code ?? undefined;
250
+ reject(error);
251
+ }
252
+ });
253
+ child.stdin.end(input ?? "");
254
+ });
255
+ }
256
+ /**
257
+ * @param {import('#types').CommandPlan} plan
258
+ * @param {{stream?: boolean}} [opts]
259
+ * @returns {Promise<import('#types').SpawnResult>}
260
+ */
261
+ async runPipedCommandPlan(plan, { stream = true } = {}) {
262
+ const pipeTo = /** @type {import('#types').CommandPlan} */ (plan.pipeTo);
263
+ return await new Promise((resolve, reject) => {
264
+ const source = spawn(plan.command, plan.args);
265
+ const target = spawn(pipeTo.command, pipeTo.args);
266
+ let output = "";
267
+ let outputFlushed = false;
268
+ const flushOutput = () => {
269
+ if (!stream || outputFlushed)
270
+ return;
271
+ outputFlushed = true;
272
+ if (output)
273
+ process.stderr.write(redactText(output));
274
+ };
275
+ let settled = false;
276
+ const fail = /** @param {Error} error */ /** @param {Error} error */ error => {
277
+ if (settled)
278
+ return;
279
+ flushOutput();
280
+ settled = true;
281
+ reject(error);
282
+ };
283
+ const append = /** @param {Buffer|string} chunk */ /** @param {Buffer|string} chunk */ chunk => {
284
+ output += chunk.toString();
285
+ };
286
+ source.stderr.on("data", append);
287
+ target.stdout.on("data", append);
288
+ target.stderr.on("data", append);
289
+ source.on("error", fail);
290
+ target.on("error", fail);
291
+ source.stdout.pipe(target.stdin);
292
+ /** @type {number|null} */
293
+ let sourceCode = null;
294
+ /** @type {number|null} */
295
+ let targetCode = null;
296
+ const finish = () => {
297
+ if (settled || sourceCode == null || targetCode == null)
298
+ return;
299
+ if (sourceCode === 0 && targetCode === 0) {
300
+ flushOutput();
301
+ settled = true;
302
+ resolve({ code: 0, output });
303
+ }
304
+ else {
305
+ const command = `${[plan.command, ...plan.args].join(" ")} | ${[pipeTo.command, ...pipeTo.args].join(" ")}`;
306
+ const error = /** @type {Error & {exitCode?: number}} */ (new Error(`Command failed with exit ${sourceCode || targetCode}: ${redactText(command)}\n${redactText(output)}`));
307
+ error.exitCode = sourceCode || targetCode;
308
+ fail(error);
309
+ }
310
+ };
311
+ source.on("close", /** @param {number|null} code */ /** @param {number|null} code */ code => { sourceCode = code; finish(); });
312
+ target.on("close", /** @param {number|null} code */ /** @param {number|null} code */ code => { targetCode = code; finish(); });
313
+ });
314
+ }
315
+ }
316
+ /**
317
+ * @param {import('#types').TransportConfig} host
318
+ * @returns {string}
319
+ */
320
+ export function sshDestination(host) {
321
+ const userPrefix = host.user ? `${host.user}@` : "";
322
+ return `${userPrefix}${host.host}`;
323
+ }
324
+ /**
325
+ * @param {import('#types').TransportConfig} host
326
+ * @param {string} command
327
+ * @returns {string[]}
328
+ */
329
+ export function sshArgs(host, command) {
330
+ const args = [];
331
+ if (host.port)
332
+ args.push("-p", String(host.port));
333
+ if (host.identityFile)
334
+ args.push("-i", host.identityFile);
335
+ for (const option of host.sshOptions ?? [])
336
+ args.push("-o", option);
337
+ args.push(sshDestination(host), command);
338
+ return args;
339
+ }
340
+ /**
341
+ * @param {unknown} value
342
+ * @returns {string}
343
+ */
344
+ export function shellQuote(value) {
345
+ const text = String(value);
346
+ if (/^[A-Za-z0-9_./:=@%+-]+$/.test(text))
347
+ return text;
348
+ return `'${text.replaceAll("'", "'\\''")}'`;
349
+ }
350
+ /**
351
+ * @param {unknown} key
352
+ * @returns {string}
353
+ */
354
+ export function shellEnvKey(key) {
355
+ const text = String(key);
356
+ if (isSecretKey(text))
357
+ throw new Error(`Secret-like environment variable cannot be passed through ssh command argv: ${text}`);
358
+ if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(text))
359
+ return text;
360
+ throw new Error(`Invalid environment variable name for ssh command: ${text}`);
361
+ }
362
+ /**
363
+ * @param {unknown} value
364
+ * @returns {string}
365
+ */
366
+ export function remotePath(value) {
367
+ return String(value).replaceAll("\\", "/");
368
+ }
369
+ //# sourceMappingURL=ssh-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh-transport.js","sourceRoot":"","sources":["../../../src/transports/ssh-transport.js"],"names":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